documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. */
  1123. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1124. /**
  1125. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1126. * @param data contains the texture data
  1127. * @param texture defines the BabylonJS internal texture
  1128. * @param callback defines the method to call once ready to upload
  1129. */
  1130. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1131. }
  1132. }
  1133. declare module BABYLON {
  1134. /**
  1135. * Class used to store and describe the pipeline context associated with an effect
  1136. */
  1137. export interface IPipelineContext {
  1138. /**
  1139. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1140. */
  1141. isAsync: boolean;
  1142. /**
  1143. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1144. */
  1145. isReady: boolean;
  1146. /** @hidden */
  1147. _getVertexShaderCode(): string | null;
  1148. /** @hidden */
  1149. _getFragmentShaderCode(): string | null;
  1150. /** @hidden */
  1151. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1152. }
  1153. }
  1154. declare module BABYLON {
  1155. /**
  1156. * Class used to store gfx data (like WebGLBuffer)
  1157. */
  1158. export class DataBuffer {
  1159. /**
  1160. * Gets or sets the number of objects referencing this buffer
  1161. */
  1162. references: number;
  1163. /** Gets or sets the size of the underlying buffer */
  1164. capacity: number;
  1165. /**
  1166. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1167. */
  1168. is32Bits: boolean;
  1169. /**
  1170. * Gets the underlying buffer
  1171. */
  1172. get underlyingResource(): any;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export interface IShaderProcessor {
  1178. attributeProcessor?: (attribute: string) => string;
  1179. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1180. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1181. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1182. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1183. lineProcessor?: (line: string, isFragment: boolean) => string;
  1184. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1185. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export interface ProcessingOptions {
  1191. defines: string[];
  1192. indexParameters: any;
  1193. isFragment: boolean;
  1194. shouldUseHighPrecisionShader: boolean;
  1195. supportsUniformBuffers: boolean;
  1196. shadersRepository: string;
  1197. includesShadersStore: {
  1198. [key: string]: string;
  1199. };
  1200. processor?: IShaderProcessor;
  1201. version: string;
  1202. platformName: string;
  1203. lookForClosingBracketForUniformBuffer?: boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeNode {
  1209. line: string;
  1210. children: ShaderCodeNode[];
  1211. additionalDefineKey?: string;
  1212. additionalDefineValue?: string;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. process(preprocessors: {
  1217. [key: string]: string;
  1218. }, options: ProcessingOptions): string;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /** @hidden */
  1223. export class ShaderCodeCursor {
  1224. private _lines;
  1225. lineIndex: number;
  1226. get currentLine(): string;
  1227. get canRead(): boolean;
  1228. set lines(value: string[]);
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /** @hidden */
  1253. export class ShaderCodeTestNode extends ShaderCodeNode {
  1254. testExpression: ShaderDefineExpression;
  1255. isValid(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module BABYLON {
  1261. /** @hidden */
  1262. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1263. define: string;
  1264. not: boolean;
  1265. constructor(define: string, not?: boolean);
  1266. isTrue(preprocessors: {
  1267. [key: string]: string;
  1268. }): boolean;
  1269. }
  1270. }
  1271. declare module BABYLON {
  1272. /** @hidden */
  1273. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1274. leftOperand: ShaderDefineExpression;
  1275. rightOperand: ShaderDefineExpression;
  1276. isTrue(preprocessors: {
  1277. [key: string]: string;
  1278. }): boolean;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /** @hidden */
  1283. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1284. leftOperand: ShaderDefineExpression;
  1285. rightOperand: ShaderDefineExpression;
  1286. isTrue(preprocessors: {
  1287. [key: string]: string;
  1288. }): boolean;
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /** @hidden */
  1293. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1294. define: string;
  1295. operand: string;
  1296. testValue: string;
  1297. constructor(define: string, operand: string, testValue: string);
  1298. isTrue(preprocessors: {
  1299. [key: string]: string;
  1300. }): boolean;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /**
  1305. * Class used to enable access to offline support
  1306. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1307. */
  1308. export interface IOfflineProvider {
  1309. /**
  1310. * Gets a boolean indicating if scene must be saved in the database
  1311. */
  1312. enableSceneOffline: boolean;
  1313. /**
  1314. * Gets a boolean indicating if textures must be saved in the database
  1315. */
  1316. enableTexturesOffline: boolean;
  1317. /**
  1318. * Open the offline support and make it available
  1319. * @param successCallback defines the callback to call on success
  1320. * @param errorCallback defines the callback to call on error
  1321. */
  1322. open(successCallback: () => void, errorCallback: () => void): void;
  1323. /**
  1324. * Loads an image from the offline support
  1325. * @param url defines the url to load from
  1326. * @param image defines the target DOM image
  1327. */
  1328. loadImage(url: string, image: HTMLImageElement): void;
  1329. /**
  1330. * Loads a file from offline support
  1331. * @param url defines the URL to load from
  1332. * @param sceneLoaded defines a callback to call on success
  1333. * @param progressCallBack defines a callback to call when progress changed
  1334. * @param errorCallback defines a callback to call on error
  1335. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1336. */
  1337. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1338. }
  1339. }
  1340. declare module BABYLON {
  1341. /**
  1342. * Class used to help managing file picking and drag'n'drop
  1343. * File Storage
  1344. */
  1345. export class FilesInputStore {
  1346. /**
  1347. * List of files ready to be loaded
  1348. */
  1349. static FilesToLoad: {
  1350. [key: string]: File;
  1351. };
  1352. }
  1353. }
  1354. declare module BABYLON {
  1355. /**
  1356. * Class used to define a retry strategy when error happens while loading assets
  1357. */
  1358. export class RetryStrategy {
  1359. /**
  1360. * Function used to defines an exponential back off strategy
  1361. * @param maxRetries defines the maximum number of retries (3 by default)
  1362. * @param baseInterval defines the interval between retries
  1363. * @returns the strategy function to use
  1364. */
  1365. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1366. }
  1367. }
  1368. declare module BABYLON {
  1369. /**
  1370. * @ignore
  1371. * Application error to support additional information when loading a file
  1372. */
  1373. export abstract class BaseError extends Error {
  1374. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1375. }
  1376. }
  1377. declare module BABYLON {
  1378. /** @ignore */
  1379. export class LoadFileError extends BaseError {
  1380. request?: WebRequest;
  1381. file?: File;
  1382. /**
  1383. * Creates a new LoadFileError
  1384. * @param message defines the message of the error
  1385. * @param request defines the optional web request
  1386. * @param file defines the optional file
  1387. */
  1388. constructor(message: string, object?: WebRequest | File);
  1389. }
  1390. /** @ignore */
  1391. export class RequestFileError extends BaseError {
  1392. request: WebRequest;
  1393. /**
  1394. * Creates a new LoadFileError
  1395. * @param message defines the message of the error
  1396. * @param request defines the optional web request
  1397. */
  1398. constructor(message: string, request: WebRequest);
  1399. }
  1400. /** @ignore */
  1401. export class ReadFileError extends BaseError {
  1402. file: File;
  1403. /**
  1404. * Creates a new ReadFileError
  1405. * @param message defines the message of the error
  1406. * @param file defines the optional file
  1407. */
  1408. constructor(message: string, file: File);
  1409. }
  1410. /**
  1411. * @hidden
  1412. */
  1413. export class FileTools {
  1414. /**
  1415. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1416. */
  1417. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1418. /**
  1419. * Gets or sets the base URL to use to load assets
  1420. */
  1421. static BaseUrl: string;
  1422. /**
  1423. * Default behaviour for cors in the application.
  1424. * It can be a string if the expected behavior is identical in the entire app.
  1425. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1426. */
  1427. static CorsBehavior: string | ((url: string | string[]) => string);
  1428. /**
  1429. * Gets or sets a function used to pre-process url before using them to load assets
  1430. */
  1431. static PreprocessUrl: (url: string) => string;
  1432. /**
  1433. * Removes unwanted characters from an url
  1434. * @param url defines the url to clean
  1435. * @returns the cleaned url
  1436. */
  1437. private static _CleanUrl;
  1438. /**
  1439. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1440. * @param url define the url we are trying
  1441. * @param element define the dom element where to configure the cors policy
  1442. */
  1443. static SetCorsBehavior(url: string | string[], element: {
  1444. crossOrigin: string | null;
  1445. }): void;
  1446. /**
  1447. * Loads an image as an HTMLImageElement.
  1448. * @param input url string, ArrayBuffer, or Blob to load
  1449. * @param onLoad callback called when the image successfully loads
  1450. * @param onError callback called when the image fails to load
  1451. * @param offlineProvider offline provider for caching
  1452. * @param mimeType optional mime type
  1453. * @returns the HTMLImageElement of the loaded image
  1454. */
  1455. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1456. /**
  1457. * Reads a file from a File object
  1458. * @param file defines the file to load
  1459. * @param onSuccess defines the callback to call when data is loaded
  1460. * @param onProgress defines the callback to call during loading process
  1461. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1462. * @param onError defines the callback to call when an error occurs
  1463. * @returns a file request object
  1464. */
  1465. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1466. /**
  1467. * Loads a file from a url
  1468. * @param url url to load
  1469. * @param onSuccess callback called when the file successfully loads
  1470. * @param onProgress callback called while file is loading (if the server supports this mode)
  1471. * @param offlineProvider defines the offline provider for caching
  1472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1473. * @param onError callback called when the file fails to load
  1474. * @returns a file request object
  1475. */
  1476. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1477. /**
  1478. * Loads a file
  1479. * @param url url to load
  1480. * @param onSuccess callback called when the file successfully loads
  1481. * @param onProgress callback called while file is loading (if the server supports this mode)
  1482. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1483. * @param onError callback called when the file fails to load
  1484. * @param onOpened callback called when the web request is opened
  1485. * @returns a file request object
  1486. */
  1487. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1488. /**
  1489. * Checks if the loaded document was accessed via `file:`-Protocol.
  1490. * @returns boolean
  1491. */
  1492. static IsFileURL(): boolean;
  1493. }
  1494. }
  1495. declare module BABYLON {
  1496. /** @hidden */
  1497. export class ShaderProcessor {
  1498. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1499. private static _ProcessPrecision;
  1500. private static _ExtractOperation;
  1501. private static _BuildSubExpression;
  1502. private static _BuildExpression;
  1503. private static _MoveCursorWithinIf;
  1504. private static _MoveCursor;
  1505. private static _EvaluatePreProcessors;
  1506. private static _PreparePreProcessors;
  1507. private static _ProcessShaderConversion;
  1508. private static _ProcessIncludes;
  1509. /**
  1510. * Loads a file from a url
  1511. * @param url url to load
  1512. * @param onSuccess callback called when the file successfully loads
  1513. * @param onProgress callback called while file is loading (if the server supports this mode)
  1514. * @param offlineProvider defines the offline provider for caching
  1515. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1516. * @param onError callback called when the file fails to load
  1517. * @returns a file request object
  1518. * @hidden
  1519. */
  1520. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1521. }
  1522. }
  1523. declare module BABYLON {
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IColor4Like {
  1528. r: float;
  1529. g: float;
  1530. b: float;
  1531. a: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IColor3Like {
  1537. r: float;
  1538. g: float;
  1539. b: float;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IVector4Like {
  1545. x: float;
  1546. y: float;
  1547. z: float;
  1548. w: float;
  1549. }
  1550. /**
  1551. * @hidden
  1552. */
  1553. export interface IVector3Like {
  1554. x: float;
  1555. y: float;
  1556. z: float;
  1557. }
  1558. /**
  1559. * @hidden
  1560. */
  1561. export interface IVector2Like {
  1562. x: float;
  1563. y: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IMatrixLike {
  1569. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1570. updateFlag: int;
  1571. }
  1572. /**
  1573. * @hidden
  1574. */
  1575. export interface IViewportLike {
  1576. x: float;
  1577. y: float;
  1578. width: float;
  1579. height: float;
  1580. }
  1581. /**
  1582. * @hidden
  1583. */
  1584. export interface IPlaneLike {
  1585. normal: IVector3Like;
  1586. d: float;
  1587. normalize(): void;
  1588. }
  1589. }
  1590. declare module BABYLON {
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module BABYLON {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module BABYLON {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module BABYLON {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. }
  1895. declare module BABYLON {
  1896. /**
  1897. * Class used to represent a viewport on screen
  1898. */
  1899. export class Viewport {
  1900. /** viewport left coordinate */
  1901. x: number;
  1902. /** viewport top coordinate */
  1903. y: number;
  1904. /**viewport width */
  1905. width: number;
  1906. /** viewport height */
  1907. height: number;
  1908. /**
  1909. * Creates a Viewport object located at (x, y) and sized (width, height)
  1910. * @param x defines viewport left coordinate
  1911. * @param y defines viewport top coordinate
  1912. * @param width defines the viewport width
  1913. * @param height defines the viewport height
  1914. */
  1915. constructor(
  1916. /** viewport left coordinate */
  1917. x: number,
  1918. /** viewport top coordinate */
  1919. y: number,
  1920. /**viewport width */
  1921. width: number,
  1922. /** viewport height */
  1923. height: number);
  1924. /**
  1925. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1926. * @param renderWidth defines the rendering width
  1927. * @param renderHeight defines the rendering height
  1928. * @returns a new Viewport
  1929. */
  1930. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1931. /**
  1932. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1933. * @param renderWidth defines the rendering width
  1934. * @param renderHeight defines the rendering height
  1935. * @param ref defines the target viewport
  1936. * @returns the current viewport
  1937. */
  1938. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1939. /**
  1940. * Returns a new Viewport copied from the current one
  1941. * @returns a new Viewport
  1942. */
  1943. clone(): Viewport;
  1944. }
  1945. }
  1946. declare module BABYLON {
  1947. /**
  1948. * Class containing a set of static utilities functions for arrays.
  1949. */
  1950. export class ArrayTools {
  1951. /**
  1952. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1953. * @param size the number of element to construct and put in the array
  1954. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1955. * @returns a new array filled with new objects
  1956. */
  1957. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1958. }
  1959. }
  1960. declare module BABYLON {
  1961. /**
  1962. * Represents a plane by the equation ax + by + cz + d = 0
  1963. */
  1964. export class Plane {
  1965. private static _TmpMatrix;
  1966. /**
  1967. * Normal of the plane (a,b,c)
  1968. */
  1969. normal: Vector3;
  1970. /**
  1971. * d component of the plane
  1972. */
  1973. d: number;
  1974. /**
  1975. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1976. * @param a a component of the plane
  1977. * @param b b component of the plane
  1978. * @param c c component of the plane
  1979. * @param d d component of the plane
  1980. */
  1981. constructor(a: number, b: number, c: number, d: number);
  1982. /**
  1983. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1984. */
  1985. asArray(): number[];
  1986. /**
  1987. * @returns a new plane copied from the current Plane.
  1988. */
  1989. clone(): Plane;
  1990. /**
  1991. * @returns the string "Plane".
  1992. */
  1993. getClassName(): string;
  1994. /**
  1995. * @returns the Plane hash code.
  1996. */
  1997. getHashCode(): number;
  1998. /**
  1999. * Normalize the current Plane in place.
  2000. * @returns the updated Plane.
  2001. */
  2002. normalize(): Plane;
  2003. /**
  2004. * Applies a transformation the plane and returns the result
  2005. * @param transformation the transformation matrix to be applied to the plane
  2006. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2007. */
  2008. transform(transformation: DeepImmutable<Matrix>): Plane;
  2009. /**
  2010. * Compute the dot product between the point and the plane normal
  2011. * @param point point to calculate the dot product with
  2012. * @returns the dot product (float) of the point coordinates and the plane normal.
  2013. */
  2014. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2015. /**
  2016. * Updates the current Plane from the plane defined by the three given points.
  2017. * @param point1 one of the points used to contruct the plane
  2018. * @param point2 one of the points used to contruct the plane
  2019. * @param point3 one of the points used to contruct the plane
  2020. * @returns the updated Plane.
  2021. */
  2022. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2023. /**
  2024. * Checks if the plane is facing a given direction
  2025. * @param direction the direction to check if the plane is facing
  2026. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2027. * @returns True is the vector "direction" is the same side than the plane normal.
  2028. */
  2029. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2030. /**
  2031. * Calculates the distance to a point
  2032. * @param point point to calculate distance to
  2033. * @returns the signed distance (float) from the given point to the Plane.
  2034. */
  2035. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2036. /**
  2037. * Creates a plane from an array
  2038. * @param array the array to create a plane from
  2039. * @returns a new Plane from the given array.
  2040. */
  2041. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2042. /**
  2043. * Creates a plane from three points
  2044. * @param point1 point used to create the plane
  2045. * @param point2 point used to create the plane
  2046. * @param point3 point used to create the plane
  2047. * @returns a new Plane defined by the three given points.
  2048. */
  2049. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2050. /**
  2051. * Creates a plane from an origin point and a normal
  2052. * @param origin origin of the plane to be constructed
  2053. * @param normal normal of the plane to be constructed
  2054. * @returns a new Plane the normal vector to this plane at the given origin point.
  2055. * Note : the vector "normal" is updated because normalized.
  2056. */
  2057. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2058. /**
  2059. * Calculates the distance from a plane and a point
  2060. * @param origin origin of the plane to be constructed
  2061. * @param normal normal of the plane to be constructed
  2062. * @param point point to calculate distance to
  2063. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2064. */
  2065. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2066. }
  2067. }
  2068. declare module BABYLON {
  2069. /** @hidden */
  2070. export class PerformanceConfigurator {
  2071. /** @hidden */
  2072. static MatrixUse64Bits: boolean;
  2073. /** @hidden */
  2074. static MatrixTrackPrecisionChange: boolean;
  2075. /** @hidden */
  2076. static MatrixCurrentType: any;
  2077. /** @hidden */
  2078. static MatrixTrackedMatrices: Array<any> | null;
  2079. /** @hidden */
  2080. static SetMatrixPrecision(use64bits: boolean): void;
  2081. }
  2082. }
  2083. declare module BABYLON {
  2084. /**
  2085. * Class representing a vector containing 2 coordinates
  2086. */
  2087. export class Vector2 {
  2088. /** defines the first coordinate */
  2089. x: number;
  2090. /** defines the second coordinate */
  2091. y: number;
  2092. /**
  2093. * Creates a new Vector2 from the given x and y coordinates
  2094. * @param x defines the first coordinate
  2095. * @param y defines the second coordinate
  2096. */
  2097. constructor(
  2098. /** defines the first coordinate */
  2099. x?: number,
  2100. /** defines the second coordinate */
  2101. y?: number);
  2102. /**
  2103. * Gets a string with the Vector2 coordinates
  2104. * @returns a string with the Vector2 coordinates
  2105. */
  2106. toString(): string;
  2107. /**
  2108. * Gets class name
  2109. * @returns the string "Vector2"
  2110. */
  2111. getClassName(): string;
  2112. /**
  2113. * Gets current vector hash code
  2114. * @returns the Vector2 hash code as a number
  2115. */
  2116. getHashCode(): number;
  2117. /**
  2118. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2119. * @param array defines the source array
  2120. * @param index defines the offset in source array
  2121. * @returns the current Vector2
  2122. */
  2123. toArray(array: FloatArray, index?: number): Vector2;
  2124. /**
  2125. * Update the current vector from an array
  2126. * @param array defines the destination array
  2127. * @param index defines the offset in the destination array
  2128. * @returns the current Vector3
  2129. */
  2130. fromArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Copy the current vector to an array
  2133. * @returns a new array with 2 elements: the Vector2 coordinates.
  2134. */
  2135. asArray(): number[];
  2136. /**
  2137. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2138. * @param source defines the source Vector2
  2139. * @returns the current updated Vector2
  2140. */
  2141. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2142. /**
  2143. * Sets the Vector2 coordinates with the given floats
  2144. * @param x defines the first coordinate
  2145. * @param y defines the second coordinate
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFromFloats(x: number, y: number): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. set(x: number, y: number): Vector2;
  2156. /**
  2157. * Add another vector with the current one
  2158. * @param otherVector defines the other vector
  2159. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2160. */
  2161. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2162. /**
  2163. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @param result defines the target vector
  2166. * @returns the unmodified current Vector2
  2167. */
  2168. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2169. /**
  2170. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. addVector3(otherVector: Vector3): Vector2;
  2181. /**
  2182. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2183. * @param otherVector defines the other vector
  2184. * @returns a new Vector2
  2185. */
  2186. subtract(otherVector: Vector2): Vector2;
  2187. /**
  2188. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2189. * @param otherVector defines the other vector
  2190. * @param result defines the target vector
  2191. * @returns the unmodified current Vector2
  2192. */
  2193. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2194. /**
  2195. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns the current updated Vector2
  2198. */
  2199. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Multiplies in place the current Vector2 coordinates by the given ones
  2202. * @param otherVector defines the other vector
  2203. * @returns the current updated Vector2
  2204. */
  2205. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2208. * @param otherVector defines the other vector
  2209. * @returns a new Vector2
  2210. */
  2211. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2214. * @param otherVector defines the other vector
  2215. * @param result defines the target vector
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2221. * @param x defines the first coordinate
  2222. * @param y defines the second coordinate
  2223. * @returns a new Vector2
  2224. */
  2225. multiplyByFloats(x: number, y: number): Vector2;
  2226. /**
  2227. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2228. * @param otherVector defines the other vector
  2229. * @returns a new Vector2
  2230. */
  2231. divide(otherVector: Vector2): Vector2;
  2232. /**
  2233. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @param result defines the target vector
  2236. * @returns the unmodified current Vector2
  2237. */
  2238. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2239. /**
  2240. * Divides the current Vector2 coordinates by the given ones
  2241. * @param otherVector defines the other vector
  2242. * @returns the current updated Vector2
  2243. */
  2244. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 with current Vector2 negated coordinates
  2247. * @returns a new Vector2
  2248. */
  2249. negate(): Vector2;
  2250. /**
  2251. * Negate this vector in place
  2252. * @returns this
  2253. */
  2254. negateInPlace(): Vector2;
  2255. /**
  2256. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2257. * @param result defines the Vector3 object where to store the result
  2258. * @returns the current Vector2
  2259. */
  2260. negateToRef(result: Vector2): Vector2;
  2261. /**
  2262. * Multiply the Vector2 coordinates by scale
  2263. * @param scale defines the scaling factor
  2264. * @returns the current updated Vector2
  2265. */
  2266. scaleInPlace(scale: number): Vector2;
  2267. /**
  2268. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2269. * @param scale defines the scaling factor
  2270. * @returns a new Vector2
  2271. */
  2272. scale(scale: number): Vector2;
  2273. /**
  2274. * Scale the current Vector2 values by a factor to a given Vector2
  2275. * @param scale defines the scale factor
  2276. * @param result defines the Vector2 object where to store the result
  2277. * @returns the unmodified current Vector2
  2278. */
  2279. scaleToRef(scale: number, result: Vector2): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Gets a boolean if two vectors are equals
  2289. * @param otherVector defines the other vector
  2290. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2291. */
  2292. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2293. /**
  2294. * Gets a boolean if two vectors are equals (using an epsilon value)
  2295. * @param otherVector defines the other vector
  2296. * @param epsilon defines the minimal distance to consider equality
  2297. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2298. */
  2299. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2300. /**
  2301. * Gets a new Vector2 from current Vector2 floored values
  2302. * @returns a new Vector2
  2303. */
  2304. floor(): Vector2;
  2305. /**
  2306. * Gets a new Vector2 from current Vector2 floored values
  2307. * @returns a new Vector2
  2308. */
  2309. fract(): Vector2;
  2310. /**
  2311. * Gets the length of the vector
  2312. * @returns the vector length (float)
  2313. */
  2314. length(): number;
  2315. /**
  2316. * Gets the vector squared length
  2317. * @returns the vector squared length (float)
  2318. */
  2319. lengthSquared(): number;
  2320. /**
  2321. * Normalize the vector
  2322. * @returns the current updated Vector2
  2323. */
  2324. normalize(): Vector2;
  2325. /**
  2326. * Gets a new Vector2 copied from the Vector2
  2327. * @returns a new Vector2
  2328. */
  2329. clone(): Vector2;
  2330. /**
  2331. * Gets a new Vector2(0, 0)
  2332. * @returns a new Vector2
  2333. */
  2334. static Zero(): Vector2;
  2335. /**
  2336. * Gets a new Vector2(1, 1)
  2337. * @returns a new Vector2
  2338. */
  2339. static One(): Vector2;
  2340. /**
  2341. * Gets a new Vector2 set from the given index element of the given array
  2342. * @param array defines the data source
  2343. * @param offset defines the offset in the data source
  2344. * @returns a new Vector2
  2345. */
  2346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2347. /**
  2348. * Sets "result" from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @param result defines the target vector
  2352. */
  2353. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2354. /**
  2355. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2356. * @param value1 defines 1st point of control
  2357. * @param value2 defines 2nd point of control
  2358. * @param value3 defines 3rd point of control
  2359. * @param value4 defines 4th point of control
  2360. * @param amount defines the interpolation factor
  2361. * @returns a new Vector2
  2362. */
  2363. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2364. /**
  2365. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2366. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2367. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2368. * @param value defines the value to clamp
  2369. * @param min defines the lower limit
  2370. * @param max defines the upper limit
  2371. * @returns a new Vector2
  2372. */
  2373. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2376. * @param value1 defines the 1st control point
  2377. * @param tangent1 defines the outgoing tangent
  2378. * @param value2 defines the 2nd control point
  2379. * @param tangent2 defines the incoming tangent
  2380. * @param amount defines the interpolation factor
  2381. * @returns a new Vector2
  2382. */
  2383. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2384. /**
  2385. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2386. * @param start defines the start vector
  2387. * @param end defines the end vector
  2388. * @param amount defines the interpolation factor
  2389. * @returns a new Vector2
  2390. */
  2391. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2392. /**
  2393. * Gets the dot product of the vector "left" and the vector "right"
  2394. * @param left defines first vector
  2395. * @param right defines second vector
  2396. * @returns the dot product (float)
  2397. */
  2398. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2399. /**
  2400. * Returns a new Vector2 equal to the normalized given vector
  2401. * @param vector defines the vector to normalize
  2402. * @returns a new Vector2
  2403. */
  2404. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2405. /**
  2406. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2407. * @param left defines 1st vector
  2408. * @param right defines 2nd vector
  2409. * @returns a new Vector2
  2410. */
  2411. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2421. * @param vector defines the vector to transform
  2422. * @param transformation defines the matrix to apply
  2423. * @returns a new Vector2
  2424. */
  2425. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2426. /**
  2427. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @param result defines the target vector
  2431. */
  2432. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2433. /**
  2434. * Determines if a given vector is included in a triangle
  2435. * @param p defines the vector to test
  2436. * @param p0 defines 1st triangle point
  2437. * @param p1 defines 2nd triangle point
  2438. * @param p2 defines 3rd triangle point
  2439. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2440. */
  2441. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2442. /**
  2443. * Gets the distance between the vectors "value1" and "value2"
  2444. * @param value1 defines first vector
  2445. * @param value2 defines second vector
  2446. * @returns the distance between vectors
  2447. */
  2448. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2449. /**
  2450. * Returns the squared distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the squared distance between vectors
  2454. */
  2455. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns a new Vector2
  2461. */
  2462. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2463. /**
  2464. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2465. * @param p defines the middle point
  2466. * @param segA defines one point of the segment
  2467. * @param segB defines the other point of the segment
  2468. * @returns the shortest distance
  2469. */
  2470. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2471. }
  2472. /**
  2473. * Class used to store (x,y,z) vector representation
  2474. * A Vector3 is the main object used in 3D geometry
  2475. * It can represent etiher the coordinates of a point the space, either a direction
  2476. * Reminder: js uses a left handed forward facing system
  2477. */
  2478. export class Vector3 {
  2479. private static _UpReadOnly;
  2480. private static _ZeroReadOnly;
  2481. /** @hidden */
  2482. _x: number;
  2483. /** @hidden */
  2484. _y: number;
  2485. /** @hidden */
  2486. _z: number;
  2487. /** @hidden */
  2488. _isDirty: boolean;
  2489. /** Gets or sets the x coordinate */
  2490. get x(): number;
  2491. set x(value: number);
  2492. /** Gets or sets the y coordinate */
  2493. get y(): number;
  2494. set y(value: number);
  2495. /** Gets or sets the z coordinate */
  2496. get z(): number;
  2497. set z(value: number);
  2498. /**
  2499. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2500. * @param x defines the first coordinates (on X axis)
  2501. * @param y defines the second coordinates (on Y axis)
  2502. * @param z defines the third coordinates (on Z axis)
  2503. */
  2504. constructor(x?: number, y?: number, z?: number);
  2505. /**
  2506. * Creates a string representation of the Vector3
  2507. * @returns a string with the Vector3 coordinates.
  2508. */
  2509. toString(): string;
  2510. /**
  2511. * Gets the class name
  2512. * @returns the string "Vector3"
  2513. */
  2514. getClassName(): string;
  2515. /**
  2516. * Creates the Vector3 hash code
  2517. * @returns a number which tends to be unique between Vector3 instances
  2518. */
  2519. getHashCode(): number;
  2520. /**
  2521. * Creates an array containing three elements : the coordinates of the Vector3
  2522. * @returns a new array of numbers
  2523. */
  2524. asArray(): number[];
  2525. /**
  2526. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2527. * @param array defines the destination array
  2528. * @param index defines the offset in the destination array
  2529. * @returns the current Vector3
  2530. */
  2531. toArray(array: FloatArray, index?: number): Vector3;
  2532. /**
  2533. * Update the current vector from an array
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. fromArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2541. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2542. */
  2543. toQuaternion(): Quaternion;
  2544. /**
  2545. * Adds the given vector to the current Vector3
  2546. * @param otherVector defines the second operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2550. /**
  2551. * Adds the given coordinates to the current Vector3
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2560. * @param otherVector defines the second operand
  2561. * @returns the resulting Vector3
  2562. */
  2563. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2566. * @param otherVector defines the second operand
  2567. * @param result defines the Vector3 object where to store the result
  2568. * @returns the current Vector3
  2569. */
  2570. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2571. /**
  2572. * Subtract the given vector from the current Vector3
  2573. * @param otherVector defines the second operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2579. * @param otherVector defines the second operand
  2580. * @returns the resulting Vector3
  2581. */
  2582. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2583. /**
  2584. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2585. * @param otherVector defines the second operand
  2586. * @param result defines the Vector3 object where to store the result
  2587. * @returns the current Vector3
  2588. */
  2589. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2590. /**
  2591. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2592. * @param x defines the x coordinate of the operand
  2593. * @param y defines the y coordinate of the operand
  2594. * @param z defines the z coordinate of the operand
  2595. * @returns the resulting Vector3
  2596. */
  2597. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2598. /**
  2599. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2600. * @param x defines the x coordinate of the operand
  2601. * @param y defines the y coordinate of the operand
  2602. * @param z defines the z coordinate of the operand
  2603. * @param result defines the Vector3 object where to store the result
  2604. * @returns the current Vector3
  2605. */
  2606. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2607. /**
  2608. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2609. * @returns a new Vector3
  2610. */
  2611. negate(): Vector3;
  2612. /**
  2613. * Negate this vector in place
  2614. * @returns this
  2615. */
  2616. negateInPlace(): Vector3;
  2617. /**
  2618. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2619. * @param result defines the Vector3 object where to store the result
  2620. * @returns the current Vector3
  2621. */
  2622. negateToRef(result: Vector3): Vector3;
  2623. /**
  2624. * Multiplies the Vector3 coordinates by the float "scale"
  2625. * @param scale defines the multiplier factor
  2626. * @returns the current updated Vector3
  2627. */
  2628. scaleInPlace(scale: number): Vector3;
  2629. /**
  2630. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2631. * @param scale defines the multiplier factor
  2632. * @returns a new Vector3
  2633. */
  2634. scale(scale: number): Vector3;
  2635. /**
  2636. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2637. * @param scale defines the multiplier factor
  2638. * @param result defines the Vector3 object where to store the result
  2639. * @returns the current Vector3
  2640. */
  2641. scaleToRef(scale: number, result: Vector3): Vector3;
  2642. /**
  2643. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2644. * @param scale defines the scale factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the unmodified current Vector3
  2647. */
  2648. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2651. * @param origin defines the origin of the projection ray
  2652. * @param plane defines the plane to project to
  2653. * @returns the projected vector3
  2654. */
  2655. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @param result defines the Vector3 where to store the result
  2661. */
  2662. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2663. /**
  2664. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2665. * @param otherVector defines the second operand
  2666. * @returns true if both vectors are equals
  2667. */
  2668. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2669. /**
  2670. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2671. * @param otherVector defines the second operand
  2672. * @param epsilon defines the minimal distance to define values as equals
  2673. * @returns true if both vectors are distant less than epsilon
  2674. */
  2675. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 coordinates equals the given floats
  2678. * @param x defines the x coordinate of the operand
  2679. * @param y defines the y coordinate of the operand
  2680. * @param z defines the z coordinate of the operand
  2681. * @returns true if both vectors are equals
  2682. */
  2683. equalsToFloats(x: number, y: number, z: number): boolean;
  2684. /**
  2685. * Multiplies the current Vector3 coordinates by the given ones
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2690. /**
  2691. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2692. * @param otherVector defines the second operand
  2693. * @returns the new Vector3
  2694. */
  2695. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2698. * @param otherVector defines the second operand
  2699. * @param result defines the Vector3 object where to store the result
  2700. * @returns the current Vector3
  2701. */
  2702. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2705. * @param x defines the x coordinate of the operand
  2706. * @param y defines the y coordinate of the operand
  2707. * @param z defines the z coordinate of the operand
  2708. * @returns the new Vector3
  2709. */
  2710. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2713. * @param otherVector defines the second operand
  2714. * @returns the new Vector3
  2715. */
  2716. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2717. /**
  2718. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2719. * @param otherVector defines the second operand
  2720. * @param result defines the Vector3 object where to store the result
  2721. * @returns the current Vector3
  2722. */
  2723. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones.
  2726. * @param otherVector defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. divideInPlace(otherVector: Vector3): Vector3;
  2730. /**
  2731. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2732. * @param other defines the second operand
  2733. * @returns the current updated Vector3
  2734. */
  2735. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2738. * @param other defines the second operand
  2739. * @returns the current updated Vector3
  2740. */
  2741. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2742. /**
  2743. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2744. * @param x defines the x coordinate of the operand
  2745. * @param y defines the y coordinate of the operand
  2746. * @param z defines the z coordinate of the operand
  2747. * @returns the current updated Vector3
  2748. */
  2749. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2750. /**
  2751. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2752. * @param x defines the x coordinate of the operand
  2753. * @param y defines the y coordinate of the operand
  2754. * @param z defines the z coordinate of the operand
  2755. * @returns the current updated Vector3
  2756. */
  2757. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2758. /**
  2759. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2760. * Check if is non uniform within a certain amount of decimal places to account for this
  2761. * @param epsilon the amount the values can differ
  2762. * @returns if the the vector is non uniform to a certain number of decimal places
  2763. */
  2764. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2765. /**
  2766. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2767. */
  2768. get isNonUniform(): boolean;
  2769. /**
  2770. * Gets a new Vector3 from current Vector3 floored values
  2771. * @returns a new Vector3
  2772. */
  2773. floor(): Vector3;
  2774. /**
  2775. * Gets a new Vector3 from current Vector3 floored values
  2776. * @returns a new Vector3
  2777. */
  2778. fract(): Vector3;
  2779. /**
  2780. * Gets the length of the Vector3
  2781. * @returns the length of the Vector3
  2782. */
  2783. length(): number;
  2784. /**
  2785. * Gets the squared length of the Vector3
  2786. * @returns squared length of the Vector3
  2787. */
  2788. lengthSquared(): number;
  2789. /**
  2790. * Normalize the current Vector3.
  2791. * Please note that this is an in place operation.
  2792. * @returns the current updated Vector3
  2793. */
  2794. normalize(): Vector3;
  2795. /**
  2796. * Reorders the x y z properties of the vector in place
  2797. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2798. * @returns the current updated vector
  2799. */
  2800. reorderInPlace(order: string): this;
  2801. /**
  2802. * Rotates the vector around 0,0,0 by a quaternion
  2803. * @param quaternion the rotation quaternion
  2804. * @param result vector to store the result
  2805. * @returns the resulting vector
  2806. */
  2807. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2808. /**
  2809. * Rotates a vector around a given point
  2810. * @param quaternion the rotation quaternion
  2811. * @param point the point to rotate around
  2812. * @param result vector to store the result
  2813. * @returns the resulting vector
  2814. */
  2815. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2816. /**
  2817. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2818. * The cross product is then orthogonal to both current and "other"
  2819. * @param other defines the right operand
  2820. * @returns the cross product
  2821. */
  2822. cross(other: Vector3): Vector3;
  2823. /**
  2824. * Normalize the current Vector3 with the given input length.
  2825. * Please note that this is an in place operation.
  2826. * @param len the length of the vector
  2827. * @returns the current updated Vector3
  2828. */
  2829. normalizeFromLength(len: number): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 to a new vector
  2832. * @returns the new Vector3
  2833. */
  2834. normalizeToNew(): Vector3;
  2835. /**
  2836. * Normalize the current Vector3 to the reference
  2837. * @param reference define the Vector3 to update
  2838. * @returns the updated Vector3
  2839. */
  2840. normalizeToRef(reference: Vector3): Vector3;
  2841. /**
  2842. * Creates a new Vector3 copied from the current Vector3
  2843. * @returns the new Vector3
  2844. */
  2845. clone(): Vector3;
  2846. /**
  2847. * Copies the given vector coordinates to the current Vector3 ones
  2848. * @param source defines the source Vector3
  2849. * @returns the current updated Vector3
  2850. */
  2851. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2852. /**
  2853. * Copies the given floats to the current Vector3 coordinates
  2854. * @param x defines the x coordinate of the operand
  2855. * @param y defines the y coordinate of the operand
  2856. * @param z defines the z coordinate of the operand
  2857. * @returns the current updated Vector3
  2858. */
  2859. copyFromFloats(x: number, y: number, z: number): Vector3;
  2860. /**
  2861. * Copies the given floats to the current Vector3 coordinates
  2862. * @param x defines the x coordinate of the operand
  2863. * @param y defines the y coordinate of the operand
  2864. * @param z defines the z coordinate of the operand
  2865. * @returns the current updated Vector3
  2866. */
  2867. set(x: number, y: number, z: number): Vector3;
  2868. /**
  2869. * Copies the given float to the current Vector3 coordinates
  2870. * @param v defines the x, y and z coordinates of the operand
  2871. * @returns the current updated Vector3
  2872. */
  2873. setAll(v: number): Vector3;
  2874. /**
  2875. * Get the clip factor between two vectors
  2876. * @param vector0 defines the first operand
  2877. * @param vector1 defines the second operand
  2878. * @param axis defines the axis to use
  2879. * @param size defines the size along the axis
  2880. * @returns the clip factor
  2881. */
  2882. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2883. /**
  2884. * Get angle between two vectors
  2885. * @param vector0 angle between vector0 and vector1
  2886. * @param vector1 angle between vector0 and vector1
  2887. * @param normal direction of the normal
  2888. * @return the angle between vector0 and vector1
  2889. */
  2890. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2891. /**
  2892. * Returns a new Vector3 set from the index "offset" of the given array
  2893. * @param array defines the source array
  2894. * @param offset defines the offset in the source array
  2895. * @returns the new Vector3
  2896. */
  2897. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. * @deprecated Please use FromArray instead.
  2904. */
  2905. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2906. /**
  2907. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2908. * @param array defines the source array
  2909. * @param offset defines the offset in the source array
  2910. * @param result defines the Vector3 where to store the result
  2911. */
  2912. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. * @deprecated Please use FromArrayToRef instead.
  2919. */
  2920. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2921. /**
  2922. * Sets the given vector "result" with the given floats.
  2923. * @param x defines the x coordinate of the source
  2924. * @param y defines the y coordinate of the source
  2925. * @param z defines the z coordinate of the source
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2931. * @returns a new empty Vector3
  2932. */
  2933. static Zero(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2936. * @returns a new unit Vector3
  2937. */
  2938. static One(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2941. * @returns a new up Vector3
  2942. */
  2943. static Up(): Vector3;
  2944. /**
  2945. * Gets a up Vector3 that must not be updated
  2946. */
  2947. static get UpReadOnly(): DeepImmutable<Vector3>;
  2948. /**
  2949. * Gets a zero Vector3 that must not be updated
  2950. */
  2951. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2952. /**
  2953. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2954. * @returns a new down Vector3
  2955. */
  2956. static Down(): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2959. * @param rightHandedSystem is the scene right-handed (negative z)
  2960. * @returns a new forward Vector3
  2961. */
  2962. static Forward(rightHandedSystem?: boolean): Vector3;
  2963. /**
  2964. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2965. * @param rightHandedSystem is the scene right-handed (negative-z)
  2966. * @returns a new forward Vector3
  2967. */
  2968. static Backward(rightHandedSystem?: boolean): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2971. * @returns a new right Vector3
  2972. */
  2973. static Right(): Vector3;
  2974. /**
  2975. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2976. * @returns a new left Vector3
  2977. */
  2978. static Left(): Vector3;
  2979. /**
  2980. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2981. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2982. * @param vector defines the Vector3 to transform
  2983. * @param transformation defines the transformation matrix
  2984. * @returns the transformed Vector3
  2985. */
  2986. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2989. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2990. * @param vector defines the Vector3 to transform
  2991. * @param transformation defines the transformation matrix
  2992. * @param result defines the Vector3 where to store the result
  2993. */
  2994. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2995. /**
  2996. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2997. * This method computes tranformed coordinates only, not transformed direction vectors
  2998. * @param x define the x coordinate of the source vector
  2999. * @param y define the y coordinate of the source vector
  3000. * @param z define the z coordinate of the source vector
  3001. * @param transformation defines the transformation matrix
  3002. * @param result defines the Vector3 where to store the result
  3003. */
  3004. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3007. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the new Vector3
  3011. */
  3012. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3015. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3023. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3033. * @param value1 defines the first control point
  3034. * @param value2 defines the second control point
  3035. * @param value3 defines the third control point
  3036. * @param value4 defines the fourth control point
  3037. * @param amount defines the amount on the spline to use
  3038. * @returns the new Vector3
  3039. */
  3040. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3041. /**
  3042. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3043. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3044. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3045. * @param value defines the current value
  3046. * @param min defines the lower range value
  3047. * @param max defines the upper range value
  3048. * @returns the new Vector3
  3049. */
  3050. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3053. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3054. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3055. * @param value defines the current value
  3056. * @param min defines the lower range value
  3057. * @param max defines the upper range value
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Checks if a given vector is inside a specific range
  3063. * @param v defines the vector to test
  3064. * @param min defines the minimum range
  3065. * @param max defines the maximum range
  3066. */
  3067. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3068. /**
  3069. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3070. * @param value1 defines the first control point
  3071. * @param tangent1 defines the first tangent vector
  3072. * @param value2 defines the second control point
  3073. * @param tangent2 defines the second tangent vector
  3074. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3075. * @returns the new Vector3
  3076. */
  3077. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3078. /**
  3079. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3080. * @param start defines the start value
  3081. * @param end defines the end value
  3082. * @param amount max defines amount between both (between 0 and 1)
  3083. * @returns the new Vector3
  3084. */
  3085. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3086. /**
  3087. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3088. * @param start defines the start value
  3089. * @param end defines the end value
  3090. * @param amount max defines amount between both (between 0 and 1)
  3091. * @param result defines the Vector3 where to store the result
  3092. */
  3093. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3094. /**
  3095. * Returns the dot product (float) between the vectors "left" and "right"
  3096. * @param left defines the left operand
  3097. * @param right defines the right operand
  3098. * @returns the dot product
  3099. */
  3100. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3101. /**
  3102. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3103. * The cross product is then orthogonal to both "left" and "right"
  3104. * @param left defines the left operand
  3105. * @param right defines the right operand
  3106. * @returns the cross product
  3107. */
  3108. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3109. /**
  3110. * Sets the given vector "result" with the cross product of "left" and "right"
  3111. * The cross product is then orthogonal to both "left" and "right"
  3112. * @param left defines the left operand
  3113. * @param right defines the right operand
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3117. /**
  3118. * Returns a new Vector3 as the normalization of the given vector
  3119. * @param vector defines the Vector3 to normalize
  3120. * @returns the new Vector3
  3121. */
  3122. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Sets the given vector "result" with the normalization of the given first vector
  3125. * @param vector defines the Vector3 to normalize
  3126. * @param result defines the Vector3 where to store the result
  3127. */
  3128. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3129. /**
  3130. * Project a Vector3 onto screen space
  3131. * @param vector defines the Vector3 to project
  3132. * @param world defines the world matrix to use
  3133. * @param transform defines the transform (view x projection) matrix to use
  3134. * @param viewport defines the screen viewport to use
  3135. * @returns the new Vector3
  3136. */
  3137. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3138. /**
  3139. * Project a Vector3 onto screen space to reference
  3140. * @param vector defines the Vector3 to project
  3141. * @param world defines the world matrix to use
  3142. * @param transform defines the transform (view x projection) matrix to use
  3143. * @param viewport defines the screen viewport to use
  3144. * @param result the vector in which the screen space will be stored
  3145. * @returns the new Vector3
  3146. */
  3147. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3148. /** @hidden */
  3149. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3150. /**
  3151. * Unproject from screen space to object space
  3152. * @param source defines the screen space Vector3 to use
  3153. * @param viewportWidth defines the current width of the viewport
  3154. * @param viewportHeight defines the current height of the viewport
  3155. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3156. * @param transform defines the transform (view x projection) matrix to use
  3157. * @returns the new Vector3
  3158. */
  3159. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3160. /**
  3161. * Unproject from screen space to object space
  3162. * @param source defines the screen space Vector3 to use
  3163. * @param viewportWidth defines the current width of the viewport
  3164. * @param viewportHeight defines the current height of the viewport
  3165. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3166. * @param view defines the view matrix to use
  3167. * @param projection defines the projection matrix to use
  3168. * @returns the new Vector3
  3169. */
  3170. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3171. /**
  3172. * Unproject from screen space to object space
  3173. * @param source defines the screen space Vector3 to use
  3174. * @param viewportWidth defines the current width of the viewport
  3175. * @param viewportHeight defines the current height of the viewport
  3176. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3177. * @param view defines the view matrix to use
  3178. * @param projection defines the projection matrix to use
  3179. * @param result defines the Vector3 where to store the result
  3180. */
  3181. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3182. /**
  3183. * Unproject from screen space to object space
  3184. * @param sourceX defines the screen space x coordinate to use
  3185. * @param sourceY defines the screen space y coordinate to use
  3186. * @param sourceZ defines the screen space z coordinate to use
  3187. * @param viewportWidth defines the current width of the viewport
  3188. * @param viewportHeight defines the current height of the viewport
  3189. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3190. * @param view defines the view matrix to use
  3191. * @param projection defines the projection matrix to use
  3192. * @param result defines the Vector3 where to store the result
  3193. */
  3194. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3195. /**
  3196. * Gets the minimal coordinate values between two Vector3
  3197. * @param left defines the first operand
  3198. * @param right defines the second operand
  3199. * @returns the new Vector3
  3200. */
  3201. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * Gets the maximal coordinate values between two Vector3
  3204. * @param left defines the first operand
  3205. * @param right defines the second operand
  3206. * @returns the new Vector3
  3207. */
  3208. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3209. /**
  3210. * Returns the distance between the vectors "value1" and "value2"
  3211. * @param value1 defines the first operand
  3212. * @param value2 defines the second operand
  3213. * @returns the distance
  3214. */
  3215. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3216. /**
  3217. * Returns the squared distance between the vectors "value1" and "value2"
  3218. * @param value1 defines the first operand
  3219. * @param value2 defines the second operand
  3220. * @returns the squared distance
  3221. */
  3222. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3223. /**
  3224. * Returns a new Vector3 located at the center between "value1" and "value2"
  3225. * @param value1 defines the first operand
  3226. * @param value2 defines the second operand
  3227. * @returns the new Vector3
  3228. */
  3229. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3230. /**
  3231. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3232. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3233. * to something in order to rotate it from its local system to the given target system
  3234. * Note: axis1, axis2 and axis3 are normalized during this operation
  3235. * @param axis1 defines the first axis
  3236. * @param axis2 defines the second axis
  3237. * @param axis3 defines the third axis
  3238. * @returns a new Vector3
  3239. */
  3240. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3241. /**
  3242. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3243. * @param axis1 defines the first axis
  3244. * @param axis2 defines the second axis
  3245. * @param axis3 defines the third axis
  3246. * @param ref defines the Vector3 where to store the result
  3247. */
  3248. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3249. }
  3250. /**
  3251. * Vector4 class created for EulerAngle class conversion to Quaternion
  3252. */
  3253. export class Vector4 {
  3254. /** x value of the vector */
  3255. x: number;
  3256. /** y value of the vector */
  3257. y: number;
  3258. /** z value of the vector */
  3259. z: number;
  3260. /** w value of the vector */
  3261. w: number;
  3262. /**
  3263. * Creates a Vector4 object from the given floats.
  3264. * @param x x value of the vector
  3265. * @param y y value of the vector
  3266. * @param z z value of the vector
  3267. * @param w w value of the vector
  3268. */
  3269. constructor(
  3270. /** x value of the vector */
  3271. x: number,
  3272. /** y value of the vector */
  3273. y: number,
  3274. /** z value of the vector */
  3275. z: number,
  3276. /** w value of the vector */
  3277. w: number);
  3278. /**
  3279. * Returns the string with the Vector4 coordinates.
  3280. * @returns a string containing all the vector values
  3281. */
  3282. toString(): string;
  3283. /**
  3284. * Returns the string "Vector4".
  3285. * @returns "Vector4"
  3286. */
  3287. getClassName(): string;
  3288. /**
  3289. * Returns the Vector4 hash code.
  3290. * @returns a unique hash code
  3291. */
  3292. getHashCode(): number;
  3293. /**
  3294. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3295. * @returns the resulting array
  3296. */
  3297. asArray(): number[];
  3298. /**
  3299. * Populates the given array from the given index with the Vector4 coordinates.
  3300. * @param array array to populate
  3301. * @param index index of the array to start at (default: 0)
  3302. * @returns the Vector4.
  3303. */
  3304. toArray(array: FloatArray, index?: number): Vector4;
  3305. /**
  3306. * Update the current vector from an array
  3307. * @param array defines the destination array
  3308. * @param index defines the offset in the destination array
  3309. * @returns the current Vector3
  3310. */
  3311. fromArray(array: FloatArray, index?: number): Vector4;
  3312. /**
  3313. * Adds the given vector to the current Vector4.
  3314. * @param otherVector the vector to add
  3315. * @returns the updated Vector4.
  3316. */
  3317. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3318. /**
  3319. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3320. * @param otherVector the vector to add
  3321. * @returns the resulting vector
  3322. */
  3323. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3324. /**
  3325. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3326. * @param otherVector the vector to add
  3327. * @param result the vector to store the result
  3328. * @returns the current Vector4.
  3329. */
  3330. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3331. /**
  3332. * Subtract in place the given vector from the current Vector4.
  3333. * @param otherVector the vector to subtract
  3334. * @returns the updated Vector4.
  3335. */
  3336. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3337. /**
  3338. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3339. * @param otherVector the vector to add
  3340. * @returns the new vector with the result
  3341. */
  3342. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3343. /**
  3344. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3345. * @param otherVector the vector to subtract
  3346. * @param result the vector to store the result
  3347. * @returns the current Vector4.
  3348. */
  3349. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. */
  3353. /**
  3354. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3355. * @param x value to subtract
  3356. * @param y value to subtract
  3357. * @param z value to subtract
  3358. * @param w value to subtract
  3359. * @returns new vector containing the result
  3360. */
  3361. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3362. /**
  3363. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3364. * @param x value to subtract
  3365. * @param y value to subtract
  3366. * @param z value to subtract
  3367. * @param w value to subtract
  3368. * @param result the vector to store the result in
  3369. * @returns the current Vector4.
  3370. */
  3371. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3374. * @returns a new vector with the negated values
  3375. */
  3376. negate(): Vector4;
  3377. /**
  3378. * Negate this vector in place
  3379. * @returns this
  3380. */
  3381. negateInPlace(): Vector4;
  3382. /**
  3383. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3384. * @param result defines the Vector3 object where to store the result
  3385. * @returns the current Vector4
  3386. */
  3387. negateToRef(result: Vector4): Vector4;
  3388. /**
  3389. * Multiplies the current Vector4 coordinates by scale (float).
  3390. * @param scale the number to scale with
  3391. * @returns the updated Vector4.
  3392. */
  3393. scaleInPlace(scale: number): Vector4;
  3394. /**
  3395. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3396. * @param scale the number to scale with
  3397. * @returns a new vector with the result
  3398. */
  3399. scale(scale: number): Vector4;
  3400. /**
  3401. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3402. * @param scale the number to scale with
  3403. * @param result a vector to store the result in
  3404. * @returns the current Vector4.
  3405. */
  3406. scaleToRef(scale: number, result: Vector4): Vector4;
  3407. /**
  3408. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3409. * @param scale defines the scale factor
  3410. * @param result defines the Vector4 object where to store the result
  3411. * @returns the unmodified current Vector4
  3412. */
  3413. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3414. /**
  3415. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3416. * @param otherVector the vector to compare against
  3417. * @returns true if they are equal
  3418. */
  3419. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3420. /**
  3421. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3422. * @param otherVector vector to compare against
  3423. * @param epsilon (Default: very small number)
  3424. * @returns true if they are equal
  3425. */
  3426. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3427. /**
  3428. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3429. * @param x x value to compare against
  3430. * @param y y value to compare against
  3431. * @param z z value to compare against
  3432. * @param w w value to compare against
  3433. * @returns true if equal
  3434. */
  3435. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3436. /**
  3437. * Multiplies in place the current Vector4 by the given one.
  3438. * @param otherVector vector to multiple with
  3439. * @returns the updated Vector4.
  3440. */
  3441. multiplyInPlace(otherVector: Vector4): Vector4;
  3442. /**
  3443. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3444. * @param otherVector vector to multiple with
  3445. * @returns resulting new vector
  3446. */
  3447. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3448. /**
  3449. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3450. * @param otherVector vector to multiple with
  3451. * @param result vector to store the result
  3452. * @returns the current Vector4.
  3453. */
  3454. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3455. /**
  3456. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3457. * @param x x value multiply with
  3458. * @param y y value multiply with
  3459. * @param z z value multiply with
  3460. * @param w w value multiply with
  3461. * @returns resulting new vector
  3462. */
  3463. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3464. /**
  3465. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3466. * @param otherVector vector to devide with
  3467. * @returns resulting new vector
  3468. */
  3469. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3470. /**
  3471. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3472. * @param otherVector vector to devide with
  3473. * @param result vector to store the result
  3474. * @returns the current Vector4.
  3475. */
  3476. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3477. /**
  3478. * Divides the current Vector3 coordinates by the given ones.
  3479. * @param otherVector vector to devide with
  3480. * @returns the updated Vector3.
  3481. */
  3482. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3483. /**
  3484. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3485. * @param other defines the second operand
  3486. * @returns the current updated Vector4
  3487. */
  3488. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3489. /**
  3490. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3491. * @param other defines the second operand
  3492. * @returns the current updated Vector4
  3493. */
  3494. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3495. /**
  3496. * Gets a new Vector4 from current Vector4 floored values
  3497. * @returns a new Vector4
  3498. */
  3499. floor(): Vector4;
  3500. /**
  3501. * Gets a new Vector4 from current Vector3 floored values
  3502. * @returns a new Vector4
  3503. */
  3504. fract(): Vector4;
  3505. /**
  3506. * Returns the Vector4 length (float).
  3507. * @returns the length
  3508. */
  3509. length(): number;
  3510. /**
  3511. * Returns the Vector4 squared length (float).
  3512. * @returns the length squared
  3513. */
  3514. lengthSquared(): number;
  3515. /**
  3516. * Normalizes in place the Vector4.
  3517. * @returns the updated Vector4.
  3518. */
  3519. normalize(): Vector4;
  3520. /**
  3521. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3522. * @returns this converted to a new vector3
  3523. */
  3524. toVector3(): Vector3;
  3525. /**
  3526. * Returns a new Vector4 copied from the current one.
  3527. * @returns the new cloned vector
  3528. */
  3529. clone(): Vector4;
  3530. /**
  3531. * Updates the current Vector4 with the given one coordinates.
  3532. * @param source the source vector to copy from
  3533. * @returns the updated Vector4.
  3534. */
  3535. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3536. /**
  3537. * Updates the current Vector4 coordinates with the given floats.
  3538. * @param x float to copy from
  3539. * @param y float to copy from
  3540. * @param z float to copy from
  3541. * @param w float to copy from
  3542. * @returns the updated Vector4.
  3543. */
  3544. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3545. /**
  3546. * Updates the current Vector4 coordinates with the given floats.
  3547. * @param x float to set from
  3548. * @param y float to set from
  3549. * @param z float to set from
  3550. * @param w float to set from
  3551. * @returns the updated Vector4.
  3552. */
  3553. set(x: number, y: number, z: number, w: number): Vector4;
  3554. /**
  3555. * Copies the given float to the current Vector3 coordinates
  3556. * @param v defines the x, y, z and w coordinates of the operand
  3557. * @returns the current updated Vector3
  3558. */
  3559. setAll(v: number): Vector4;
  3560. /**
  3561. * Returns a new Vector4 set from the starting index of the given array.
  3562. * @param array the array to pull values from
  3563. * @param offset the offset into the array to start at
  3564. * @returns the new vector
  3565. */
  3566. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the starting index of the given array.
  3569. * @param array the array to pull values from
  3570. * @param offset the offset into the array to start at
  3571. * @param result the vector to store the result in
  3572. */
  3573. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3574. /**
  3575. * Updates the given vector "result" from the starting index of the given Float32Array.
  3576. * @param array the array to pull values from
  3577. * @param offset the offset into the array to start at
  3578. * @param result the vector to store the result in
  3579. */
  3580. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3581. /**
  3582. * Updates the given vector "result" coordinates from the given floats.
  3583. * @param x float to set from
  3584. * @param y float to set from
  3585. * @param z float to set from
  3586. * @param w float to set from
  3587. * @param result the vector to the floats in
  3588. */
  3589. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3590. /**
  3591. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3592. * @returns the new vector
  3593. */
  3594. static Zero(): Vector4;
  3595. /**
  3596. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3597. * @returns the new vector
  3598. */
  3599. static One(): Vector4;
  3600. /**
  3601. * Returns a new normalized Vector4 from the given one.
  3602. * @param vector the vector to normalize
  3603. * @returns the vector
  3604. */
  3605. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3606. /**
  3607. * Updates the given vector "result" from the normalization of the given one.
  3608. * @param vector the vector to normalize
  3609. * @param result the vector to store the result in
  3610. */
  3611. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3612. /**
  3613. * Returns a vector with the minimum values from the left and right vectors
  3614. * @param left left vector to minimize
  3615. * @param right right vector to minimize
  3616. * @returns a new vector with the minimum of the left and right vector values
  3617. */
  3618. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3619. /**
  3620. * Returns a vector with the maximum values from the left and right vectors
  3621. * @param left left vector to maximize
  3622. * @param right right vector to maximize
  3623. * @returns a new vector with the maximum of the left and right vector values
  3624. */
  3625. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3626. /**
  3627. * Returns the distance (float) between the vectors "value1" and "value2".
  3628. * @param value1 value to calulate the distance between
  3629. * @param value2 value to calulate the distance between
  3630. * @return the distance between the two vectors
  3631. */
  3632. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3633. /**
  3634. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3635. * @param value1 value to calulate the distance between
  3636. * @param value2 value to calulate the distance between
  3637. * @return the distance between the two vectors squared
  3638. */
  3639. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3640. /**
  3641. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3642. * @param value1 value to calulate the center between
  3643. * @param value2 value to calulate the center between
  3644. * @return the center between the two vectors
  3645. */
  3646. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3647. /**
  3648. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3649. * This methods computes transformed normalized direction vectors only.
  3650. * @param vector the vector to transform
  3651. * @param transformation the transformation matrix to apply
  3652. * @returns the new vector
  3653. */
  3654. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3655. /**
  3656. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3657. * This methods computes transformed normalized direction vectors only.
  3658. * @param vector the vector to transform
  3659. * @param transformation the transformation matrix to apply
  3660. * @param result the vector to store the result in
  3661. */
  3662. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3663. /**
  3664. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param x value to transform
  3667. * @param y value to transform
  3668. * @param z value to transform
  3669. * @param w value to transform
  3670. * @param transformation the transformation matrix to apply
  3671. * @param result the vector to store the results in
  3672. */
  3673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3674. /**
  3675. * Creates a new Vector4 from a Vector3
  3676. * @param source defines the source data
  3677. * @param w defines the 4th component (default is 0)
  3678. * @returns a new Vector4
  3679. */
  3680. static FromVector3(source: Vector3, w?: number): Vector4;
  3681. }
  3682. /**
  3683. * Class used to store quaternion data
  3684. * @see https://en.wikipedia.org/wiki/Quaternion
  3685. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3686. */
  3687. export class Quaternion {
  3688. /** @hidden */
  3689. _x: number;
  3690. /** @hidden */
  3691. _y: number;
  3692. /** @hidden */
  3693. _z: number;
  3694. /** @hidden */
  3695. _w: number;
  3696. /** @hidden */
  3697. _isDirty: boolean;
  3698. /** Gets or sets the x coordinate */
  3699. get x(): number;
  3700. set x(value: number);
  3701. /** Gets or sets the y coordinate */
  3702. get y(): number;
  3703. set y(value: number);
  3704. /** Gets or sets the z coordinate */
  3705. get z(): number;
  3706. set z(value: number);
  3707. /** Gets or sets the w coordinate */
  3708. get w(): number;
  3709. set w(value: number);
  3710. /**
  3711. * Creates a new Quaternion from the given floats
  3712. * @param x defines the first component (0 by default)
  3713. * @param y defines the second component (0 by default)
  3714. * @param z defines the third component (0 by default)
  3715. * @param w defines the fourth component (1.0 by default)
  3716. */
  3717. constructor(x?: number, y?: number, z?: number, w?: number);
  3718. /**
  3719. * Gets a string representation for the current quaternion
  3720. * @returns a string with the Quaternion coordinates
  3721. */
  3722. toString(): string;
  3723. /**
  3724. * Gets the class name of the quaternion
  3725. * @returns the string "Quaternion"
  3726. */
  3727. getClassName(): string;
  3728. /**
  3729. * Gets a hash code for this quaternion
  3730. * @returns the quaternion hash code
  3731. */
  3732. getHashCode(): number;
  3733. /**
  3734. * Copy the quaternion to an array
  3735. * @returns a new array populated with 4 elements from the quaternion coordinates
  3736. */
  3737. asArray(): number[];
  3738. /**
  3739. * Check if two quaternions are equals
  3740. * @param otherQuaternion defines the second operand
  3741. * @return true if the current quaternion and the given one coordinates are strictly equals
  3742. */
  3743. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3744. /**
  3745. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3746. * @param otherQuaternion defines the other quaternion
  3747. * @param epsilon defines the minimal distance to consider equality
  3748. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3749. */
  3750. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3751. /**
  3752. * Clone the current quaternion
  3753. * @returns a new quaternion copied from the current one
  3754. */
  3755. clone(): Quaternion;
  3756. /**
  3757. * Copy a quaternion to the current one
  3758. * @param other defines the other quaternion
  3759. * @returns the updated current quaternion
  3760. */
  3761. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3762. /**
  3763. * Updates the current quaternion with the given float coordinates
  3764. * @param x defines the x coordinate
  3765. * @param y defines the y coordinate
  3766. * @param z defines the z coordinate
  3767. * @param w defines the w coordinate
  3768. * @returns the updated current quaternion
  3769. */
  3770. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3771. /**
  3772. * Updates the current quaternion from the given float coordinates
  3773. * @param x defines the x coordinate
  3774. * @param y defines the y coordinate
  3775. * @param z defines the z coordinate
  3776. * @param w defines the w coordinate
  3777. * @returns the updated current quaternion
  3778. */
  3779. set(x: number, y: number, z: number, w: number): Quaternion;
  3780. /**
  3781. * Adds two quaternions
  3782. * @param other defines the second operand
  3783. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3784. */
  3785. add(other: DeepImmutable<Quaternion>): Quaternion;
  3786. /**
  3787. * Add a quaternion to the current one
  3788. * @param other defines the quaternion to add
  3789. * @returns the current quaternion
  3790. */
  3791. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3792. /**
  3793. * Subtract two quaternions
  3794. * @param other defines the second operand
  3795. * @returns a new quaternion as the subtraction result of the given one from the current one
  3796. */
  3797. subtract(other: Quaternion): Quaternion;
  3798. /**
  3799. * Multiplies the current quaternion by a scale factor
  3800. * @param value defines the scale factor
  3801. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3802. */
  3803. scale(value: number): Quaternion;
  3804. /**
  3805. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3806. * @param scale defines the scale factor
  3807. * @param result defines the Quaternion object where to store the result
  3808. * @returns the unmodified current quaternion
  3809. */
  3810. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3811. /**
  3812. * Multiplies in place the current quaternion by a scale factor
  3813. * @param value defines the scale factor
  3814. * @returns the current modified quaternion
  3815. */
  3816. scaleInPlace(value: number): Quaternion;
  3817. /**
  3818. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3819. * @param scale defines the scale factor
  3820. * @param result defines the Quaternion object where to store the result
  3821. * @returns the unmodified current quaternion
  3822. */
  3823. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3824. /**
  3825. * Multiplies two quaternions
  3826. * @param q1 defines the second operand
  3827. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3828. */
  3829. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3830. /**
  3831. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3832. * @param q1 defines the second operand
  3833. * @param result defines the target quaternion
  3834. * @returns the current quaternion
  3835. */
  3836. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3837. /**
  3838. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3839. * @param q1 defines the second operand
  3840. * @returns the currentupdated quaternion
  3841. */
  3842. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3843. /**
  3844. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3845. * @param ref defines the target quaternion
  3846. * @returns the current quaternion
  3847. */
  3848. conjugateToRef(ref: Quaternion): Quaternion;
  3849. /**
  3850. * Conjugates in place (1-q) the current quaternion
  3851. * @returns the current updated quaternion
  3852. */
  3853. conjugateInPlace(): Quaternion;
  3854. /**
  3855. * Conjugates in place (1-q) the current quaternion
  3856. * @returns a new quaternion
  3857. */
  3858. conjugate(): Quaternion;
  3859. /**
  3860. * Gets length of current quaternion
  3861. * @returns the quaternion length (float)
  3862. */
  3863. length(): number;
  3864. /**
  3865. * Normalize in place the current quaternion
  3866. * @returns the current updated quaternion
  3867. */
  3868. normalize(): Quaternion;
  3869. /**
  3870. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3871. * @param order is a reserved parameter and is ignored for now
  3872. * @returns a new Vector3 containing the Euler angles
  3873. */
  3874. toEulerAngles(order?: string): Vector3;
  3875. /**
  3876. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3877. * @param result defines the vector which will be filled with the Euler angles
  3878. * @returns the current unchanged quaternion
  3879. */
  3880. toEulerAnglesToRef(result: Vector3): Quaternion;
  3881. /**
  3882. * Updates the given rotation matrix with the current quaternion values
  3883. * @param result defines the target matrix
  3884. * @returns the current unchanged quaternion
  3885. */
  3886. toRotationMatrix(result: Matrix): Quaternion;
  3887. /**
  3888. * Updates the current quaternion from the given rotation matrix values
  3889. * @param matrix defines the source matrix
  3890. * @returns the current updated quaternion
  3891. */
  3892. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3893. /**
  3894. * Creates a new quaternion from a rotation matrix
  3895. * @param matrix defines the source matrix
  3896. * @returns a new quaternion created from the given rotation matrix values
  3897. */
  3898. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3899. /**
  3900. * Updates the given quaternion with the given rotation matrix values
  3901. * @param matrix defines the source matrix
  3902. * @param result defines the target quaternion
  3903. */
  3904. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3905. /**
  3906. * Returns the dot product (float) between the quaternions "left" and "right"
  3907. * @param left defines the left operand
  3908. * @param right defines the right operand
  3909. * @returns the dot product
  3910. */
  3911. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3912. /**
  3913. * Checks if the two quaternions are close to each other
  3914. * @param quat0 defines the first quaternion to check
  3915. * @param quat1 defines the second quaternion to check
  3916. * @returns true if the two quaternions are close to each other
  3917. */
  3918. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3919. /**
  3920. * Creates an empty quaternion
  3921. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3922. */
  3923. static Zero(): Quaternion;
  3924. /**
  3925. * Inverse a given quaternion
  3926. * @param q defines the source quaternion
  3927. * @returns a new quaternion as the inverted current quaternion
  3928. */
  3929. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3930. /**
  3931. * Inverse a given quaternion
  3932. * @param q defines the source quaternion
  3933. * @param result the quaternion the result will be stored in
  3934. * @returns the result quaternion
  3935. */
  3936. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3937. /**
  3938. * Creates an identity quaternion
  3939. * @returns the identity quaternion
  3940. */
  3941. static Identity(): Quaternion;
  3942. /**
  3943. * Gets a boolean indicating if the given quaternion is identity
  3944. * @param quaternion defines the quaternion to check
  3945. * @returns true if the quaternion is identity
  3946. */
  3947. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3948. /**
  3949. * Creates a quaternion from a rotation around an axis
  3950. * @param axis defines the axis to use
  3951. * @param angle defines the angle to use
  3952. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3953. */
  3954. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3955. /**
  3956. * Creates a rotation around an axis and stores it into the given quaternion
  3957. * @param axis defines the axis to use
  3958. * @param angle defines the angle to use
  3959. * @param result defines the target quaternion
  3960. * @returns the target quaternion
  3961. */
  3962. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3963. /**
  3964. * Creates a new quaternion from data stored into an array
  3965. * @param array defines the data source
  3966. * @param offset defines the offset in the source array where the data starts
  3967. * @returns a new quaternion
  3968. */
  3969. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3970. /**
  3971. * Updates the given quaternion "result" from the starting index of the given array.
  3972. * @param array the array to pull values from
  3973. * @param offset the offset into the array to start at
  3974. * @param result the quaternion to store the result in
  3975. */
  3976. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3977. /**
  3978. * Create a quaternion from Euler rotation angles
  3979. * @param x Pitch
  3980. * @param y Yaw
  3981. * @param z Roll
  3982. * @returns the new Quaternion
  3983. */
  3984. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3985. /**
  3986. * Updates a quaternion from Euler rotation angles
  3987. * @param x Pitch
  3988. * @param y Yaw
  3989. * @param z Roll
  3990. * @param result the quaternion to store the result
  3991. * @returns the updated quaternion
  3992. */
  3993. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3994. /**
  3995. * Create a quaternion from Euler rotation vector
  3996. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3997. * @returns the new Quaternion
  3998. */
  3999. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4000. /**
  4001. * Updates a quaternion from Euler rotation vector
  4002. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4003. * @param result the quaternion to store the result
  4004. * @returns the updated quaternion
  4005. */
  4006. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4007. /**
  4008. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4009. * @param yaw defines the rotation around Y axis
  4010. * @param pitch defines the rotation around X axis
  4011. * @param roll defines the rotation around Z axis
  4012. * @returns the new quaternion
  4013. */
  4014. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4015. /**
  4016. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4017. * @param yaw defines the rotation around Y axis
  4018. * @param pitch defines the rotation around X axis
  4019. * @param roll defines the rotation around Z axis
  4020. * @param result defines the target quaternion
  4021. */
  4022. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4023. /**
  4024. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4025. * @param alpha defines the rotation around first axis
  4026. * @param beta defines the rotation around second axis
  4027. * @param gamma defines the rotation around third axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4031. /**
  4032. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4033. * @param alpha defines the rotation around first axis
  4034. * @param beta defines the rotation around second axis
  4035. * @param gamma defines the rotation around third axis
  4036. * @param result defines the target quaternion
  4037. */
  4038. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4039. /**
  4040. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4041. * @param axis1 defines the first axis
  4042. * @param axis2 defines the second axis
  4043. * @param axis3 defines the third axis
  4044. * @returns the new quaternion
  4045. */
  4046. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4047. /**
  4048. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4049. * @param axis1 defines the first axis
  4050. * @param axis2 defines the second axis
  4051. * @param axis3 defines the third axis
  4052. * @param ref defines the target quaternion
  4053. */
  4054. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4055. /**
  4056. * Interpolates between two quaternions
  4057. * @param left defines first quaternion
  4058. * @param right defines second quaternion
  4059. * @param amount defines the gradient to use
  4060. * @returns the new interpolated quaternion
  4061. */
  4062. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4063. /**
  4064. * Interpolates between two quaternions and stores it into a target quaternion
  4065. * @param left defines first quaternion
  4066. * @param right defines second quaternion
  4067. * @param amount defines the gradient to use
  4068. * @param result defines the target quaternion
  4069. */
  4070. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4071. /**
  4072. * Interpolate between two quaternions using Hermite interpolation
  4073. * @param value1 defines first quaternion
  4074. * @param tangent1 defines the incoming tangent
  4075. * @param value2 defines second quaternion
  4076. * @param tangent2 defines the outgoing tangent
  4077. * @param amount defines the target quaternion
  4078. * @returns the new interpolated quaternion
  4079. */
  4080. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4081. }
  4082. /**
  4083. * Class used to store matrix data (4x4)
  4084. */
  4085. export class Matrix {
  4086. /**
  4087. * Gets the precision of matrix computations
  4088. */
  4089. static get Use64Bits(): boolean;
  4090. private static _updateFlagSeed;
  4091. private static _identityReadOnly;
  4092. private _isIdentity;
  4093. private _isIdentityDirty;
  4094. private _isIdentity3x2;
  4095. private _isIdentity3x2Dirty;
  4096. /**
  4097. * Gets the update flag of the matrix which is an unique number for the matrix.
  4098. * It will be incremented every time the matrix data change.
  4099. * You can use it to speed the comparison between two versions of the same matrix.
  4100. */
  4101. updateFlag: number;
  4102. private readonly _m;
  4103. /**
  4104. * Gets the internal data of the matrix
  4105. */
  4106. get m(): DeepImmutable<Float32Array | Array<number>>;
  4107. /** @hidden */
  4108. _markAsUpdated(): void;
  4109. /** @hidden */
  4110. private _updateIdentityStatus;
  4111. /**
  4112. * Creates an empty matrix (filled with zeros)
  4113. */
  4114. constructor();
  4115. /**
  4116. * Check if the current matrix is identity
  4117. * @returns true is the matrix is the identity matrix
  4118. */
  4119. isIdentity(): boolean;
  4120. /**
  4121. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4122. * @returns true is the matrix is the identity matrix
  4123. */
  4124. isIdentityAs3x2(): boolean;
  4125. /**
  4126. * Gets the determinant of the matrix
  4127. * @returns the matrix determinant
  4128. */
  4129. determinant(): number;
  4130. /**
  4131. * Returns the matrix as a Float32Array or Array<number>
  4132. * @returns the matrix underlying array
  4133. */
  4134. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4135. /**
  4136. * Returns the matrix as a Float32Array or Array<number>
  4137. * @returns the matrix underlying array.
  4138. */
  4139. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4140. /**
  4141. * Inverts the current matrix in place
  4142. * @returns the current inverted matrix
  4143. */
  4144. invert(): Matrix;
  4145. /**
  4146. * Sets all the matrix elements to zero
  4147. * @returns the current matrix
  4148. */
  4149. reset(): Matrix;
  4150. /**
  4151. * Adds the current matrix with a second one
  4152. * @param other defines the matrix to add
  4153. * @returns a new matrix as the addition of the current matrix and the given one
  4154. */
  4155. add(other: DeepImmutable<Matrix>): Matrix;
  4156. /**
  4157. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4158. * @param other defines the matrix to add
  4159. * @param result defines the target matrix
  4160. * @returns the current matrix
  4161. */
  4162. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4163. /**
  4164. * Adds in place the given matrix to the current matrix
  4165. * @param other defines the second operand
  4166. * @returns the current updated matrix
  4167. */
  4168. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4169. /**
  4170. * Sets the given matrix to the current inverted Matrix
  4171. * @param other defines the target matrix
  4172. * @returns the unmodified current matrix
  4173. */
  4174. invertToRef(other: Matrix): Matrix;
  4175. /**
  4176. * add a value at the specified position in the current Matrix
  4177. * @param index the index of the value within the matrix. between 0 and 15.
  4178. * @param value the value to be added
  4179. * @returns the current updated matrix
  4180. */
  4181. addAtIndex(index: number, value: number): Matrix;
  4182. /**
  4183. * mutiply the specified position in the current Matrix by a value
  4184. * @param index the index of the value within the matrix. between 0 and 15.
  4185. * @param value the value to be added
  4186. * @returns the current updated matrix
  4187. */
  4188. multiplyAtIndex(index: number, value: number): Matrix;
  4189. /**
  4190. * Inserts the translation vector (using 3 floats) in the current matrix
  4191. * @param x defines the 1st component of the translation
  4192. * @param y defines the 2nd component of the translation
  4193. * @param z defines the 3rd component of the translation
  4194. * @returns the current updated matrix
  4195. */
  4196. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4197. /**
  4198. * Adds the translation vector (using 3 floats) in the current matrix
  4199. * @param x defines the 1st component of the translation
  4200. * @param y defines the 2nd component of the translation
  4201. * @param z defines the 3rd component of the translation
  4202. * @returns the current updated matrix
  4203. */
  4204. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4205. /**
  4206. * Inserts the translation vector in the current matrix
  4207. * @param vector3 defines the translation to insert
  4208. * @returns the current updated matrix
  4209. */
  4210. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4211. /**
  4212. * Gets the translation value of the current matrix
  4213. * @returns a new Vector3 as the extracted translation from the matrix
  4214. */
  4215. getTranslation(): Vector3;
  4216. /**
  4217. * Fill a Vector3 with the extracted translation from the matrix
  4218. * @param result defines the Vector3 where to store the translation
  4219. * @returns the current matrix
  4220. */
  4221. getTranslationToRef(result: Vector3): Matrix;
  4222. /**
  4223. * Remove rotation and scaling part from the matrix
  4224. * @returns the updated matrix
  4225. */
  4226. removeRotationAndScaling(): Matrix;
  4227. /**
  4228. * Multiply two matrices
  4229. * @param other defines the second operand
  4230. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4231. */
  4232. multiply(other: DeepImmutable<Matrix>): Matrix;
  4233. /**
  4234. * Copy the current matrix from the given one
  4235. * @param other defines the source matrix
  4236. * @returns the current updated matrix
  4237. */
  4238. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4239. /**
  4240. * Populates the given array from the starting index with the current matrix values
  4241. * @param array defines the target array
  4242. * @param offset defines the offset in the target array where to start storing values
  4243. * @returns the current matrix
  4244. */
  4245. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4246. /**
  4247. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4248. * @param other defines the second operand
  4249. * @param result defines the matrix where to store the multiplication
  4250. * @returns the current matrix
  4251. */
  4252. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4253. /**
  4254. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4255. * @param other defines the second operand
  4256. * @param result defines the array where to store the multiplication
  4257. * @param offset defines the offset in the target array where to start storing values
  4258. * @returns the current matrix
  4259. */
  4260. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4261. /**
  4262. * Check equality between this matrix and a second one
  4263. * @param value defines the second matrix to compare
  4264. * @returns true is the current matrix and the given one values are strictly equal
  4265. */
  4266. equals(value: DeepImmutable<Matrix>): boolean;
  4267. /**
  4268. * Clone the current matrix
  4269. * @returns a new matrix from the current matrix
  4270. */
  4271. clone(): Matrix;
  4272. /**
  4273. * Returns the name of the current matrix class
  4274. * @returns the string "Matrix"
  4275. */
  4276. getClassName(): string;
  4277. /**
  4278. * Gets the hash code of the current matrix
  4279. * @returns the hash code
  4280. */
  4281. getHashCode(): number;
  4282. /**
  4283. * Decomposes the current Matrix into a translation, rotation and scaling components
  4284. * @param scale defines the scale vector3 given as a reference to update
  4285. * @param rotation defines the rotation quaternion given as a reference to update
  4286. * @param translation defines the translation vector3 given as a reference to update
  4287. * @returns true if operation was successful
  4288. */
  4289. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4290. /**
  4291. * Gets specific row of the matrix
  4292. * @param index defines the number of the row to get
  4293. * @returns the index-th row of the current matrix as a new Vector4
  4294. */
  4295. getRow(index: number): Nullable<Vector4>;
  4296. /**
  4297. * Sets the index-th row of the current matrix to the vector4 values
  4298. * @param index defines the number of the row to set
  4299. * @param row defines the target vector4
  4300. * @returns the updated current matrix
  4301. */
  4302. setRow(index: number, row: Vector4): Matrix;
  4303. /**
  4304. * Compute the transpose of the matrix
  4305. * @returns the new transposed matrix
  4306. */
  4307. transpose(): Matrix;
  4308. /**
  4309. * Compute the transpose of the matrix and store it in a given matrix
  4310. * @param result defines the target matrix
  4311. * @returns the current matrix
  4312. */
  4313. transposeToRef(result: Matrix): Matrix;
  4314. /**
  4315. * Sets the index-th row of the current matrix with the given 4 x float values
  4316. * @param index defines the row index
  4317. * @param x defines the x component to set
  4318. * @param y defines the y component to set
  4319. * @param z defines the z component to set
  4320. * @param w defines the w component to set
  4321. * @returns the updated current matrix
  4322. */
  4323. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4324. /**
  4325. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4326. * @param scale defines the scale factor
  4327. * @returns a new matrix
  4328. */
  4329. scale(scale: number): Matrix;
  4330. /**
  4331. * Scale the current matrix values by a factor to a given result matrix
  4332. * @param scale defines the scale factor
  4333. * @param result defines the matrix to store the result
  4334. * @returns the current matrix
  4335. */
  4336. scaleToRef(scale: number, result: Matrix): Matrix;
  4337. /**
  4338. * Scale the current matrix values by a factor and add the result to a given matrix
  4339. * @param scale defines the scale factor
  4340. * @param result defines the Matrix to store the result
  4341. * @returns the current matrix
  4342. */
  4343. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4344. /**
  4345. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4346. * @param ref matrix to store the result
  4347. */
  4348. toNormalMatrix(ref: Matrix): void;
  4349. /**
  4350. * Gets only rotation part of the current matrix
  4351. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4352. */
  4353. getRotationMatrix(): Matrix;
  4354. /**
  4355. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4356. * @param result defines the target matrix to store data to
  4357. * @returns the current matrix
  4358. */
  4359. getRotationMatrixToRef(result: Matrix): Matrix;
  4360. /**
  4361. * Toggles model matrix from being right handed to left handed in place and vice versa
  4362. */
  4363. toggleModelMatrixHandInPlace(): void;
  4364. /**
  4365. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4366. */
  4367. toggleProjectionMatrixHandInPlace(): void;
  4368. /**
  4369. * Creates a matrix from an array
  4370. * @param array defines the source array
  4371. * @param offset defines an offset in the source array
  4372. * @returns a new Matrix set from the starting index of the given array
  4373. */
  4374. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4375. /**
  4376. * Copy the content of an array into a given matrix
  4377. * @param array defines the source array
  4378. * @param offset defines an offset in the source array
  4379. * @param result defines the target matrix
  4380. */
  4381. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4382. /**
  4383. * Stores an array into a matrix after having multiplied each component by a given factor
  4384. * @param array defines the source array
  4385. * @param offset defines the offset in the source array
  4386. * @param scale defines the scaling factor
  4387. * @param result defines the target matrix
  4388. */
  4389. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4390. /**
  4391. * Gets an identity matrix that must not be updated
  4392. */
  4393. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4394. /**
  4395. * Stores a list of values (16) inside a given matrix
  4396. * @param initialM11 defines 1st value of 1st row
  4397. * @param initialM12 defines 2nd value of 1st row
  4398. * @param initialM13 defines 3rd value of 1st row
  4399. * @param initialM14 defines 4th value of 1st row
  4400. * @param initialM21 defines 1st value of 2nd row
  4401. * @param initialM22 defines 2nd value of 2nd row
  4402. * @param initialM23 defines 3rd value of 2nd row
  4403. * @param initialM24 defines 4th value of 2nd row
  4404. * @param initialM31 defines 1st value of 3rd row
  4405. * @param initialM32 defines 2nd value of 3rd row
  4406. * @param initialM33 defines 3rd value of 3rd row
  4407. * @param initialM34 defines 4th value of 3rd row
  4408. * @param initialM41 defines 1st value of 4th row
  4409. * @param initialM42 defines 2nd value of 4th row
  4410. * @param initialM43 defines 3rd value of 4th row
  4411. * @param initialM44 defines 4th value of 4th row
  4412. * @param result defines the target matrix
  4413. */
  4414. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4415. /**
  4416. * Creates new matrix from a list of values (16)
  4417. * @param initialM11 defines 1st value of 1st row
  4418. * @param initialM12 defines 2nd value of 1st row
  4419. * @param initialM13 defines 3rd value of 1st row
  4420. * @param initialM14 defines 4th value of 1st row
  4421. * @param initialM21 defines 1st value of 2nd row
  4422. * @param initialM22 defines 2nd value of 2nd row
  4423. * @param initialM23 defines 3rd value of 2nd row
  4424. * @param initialM24 defines 4th value of 2nd row
  4425. * @param initialM31 defines 1st value of 3rd row
  4426. * @param initialM32 defines 2nd value of 3rd row
  4427. * @param initialM33 defines 3rd value of 3rd row
  4428. * @param initialM34 defines 4th value of 3rd row
  4429. * @param initialM41 defines 1st value of 4th row
  4430. * @param initialM42 defines 2nd value of 4th row
  4431. * @param initialM43 defines 3rd value of 4th row
  4432. * @param initialM44 defines 4th value of 4th row
  4433. * @returns the new matrix
  4434. */
  4435. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4436. /**
  4437. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4438. * @param scale defines the scale vector3
  4439. * @param rotation defines the rotation quaternion
  4440. * @param translation defines the translation vector3
  4441. * @returns a new matrix
  4442. */
  4443. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4444. /**
  4445. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4446. * @param scale defines the scale vector3
  4447. * @param rotation defines the rotation quaternion
  4448. * @param translation defines the translation vector3
  4449. * @param result defines the target matrix
  4450. */
  4451. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4452. /**
  4453. * Creates a new identity matrix
  4454. * @returns a new identity matrix
  4455. */
  4456. static Identity(): Matrix;
  4457. /**
  4458. * Creates a new identity matrix and stores the result in a given matrix
  4459. * @param result defines the target matrix
  4460. */
  4461. static IdentityToRef(result: Matrix): void;
  4462. /**
  4463. * Creates a new zero matrix
  4464. * @returns a new zero matrix
  4465. */
  4466. static Zero(): Matrix;
  4467. /**
  4468. * Creates a new rotation matrix for "angle" radians around the X axis
  4469. * @param angle defines the angle (in radians) to use
  4470. * @return the new matrix
  4471. */
  4472. static RotationX(angle: number): Matrix;
  4473. /**
  4474. * Creates a new matrix as the invert of a given matrix
  4475. * @param source defines the source matrix
  4476. * @returns the new matrix
  4477. */
  4478. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4479. /**
  4480. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationXToRef(angle: number, result: Matrix): void;
  4485. /**
  4486. * Creates a new rotation matrix for "angle" radians around the Y axis
  4487. * @param angle defines the angle (in radians) to use
  4488. * @return the new matrix
  4489. */
  4490. static RotationY(angle: number): Matrix;
  4491. /**
  4492. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4493. * @param angle defines the angle (in radians) to use
  4494. * @param result defines the target matrix
  4495. */
  4496. static RotationYToRef(angle: number, result: Matrix): void;
  4497. /**
  4498. * Creates a new rotation matrix for "angle" radians around the Z axis
  4499. * @param angle defines the angle (in radians) to use
  4500. * @return the new matrix
  4501. */
  4502. static RotationZ(angle: number): Matrix;
  4503. /**
  4504. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4505. * @param angle defines the angle (in radians) to use
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationZToRef(angle: number, result: Matrix): void;
  4509. /**
  4510. * Creates a new rotation matrix for "angle" radians around the given axis
  4511. * @param axis defines the axis to use
  4512. * @param angle defines the angle (in radians) to use
  4513. * @return the new matrix
  4514. */
  4515. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4516. /**
  4517. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4518. * @param axis defines the axis to use
  4519. * @param angle defines the angle (in radians) to use
  4520. * @param result defines the target matrix
  4521. */
  4522. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4523. /**
  4524. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4525. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4526. * @param from defines the vector to align
  4527. * @param to defines the vector to align to
  4528. * @param result defines the target matrix
  4529. */
  4530. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4531. /**
  4532. * Creates a rotation matrix
  4533. * @param yaw defines the yaw angle in radians (Y axis)
  4534. * @param pitch defines the pitch angle in radians (X axis)
  4535. * @param roll defines the roll angle in radians (Z axis)
  4536. * @returns the new rotation matrix
  4537. */
  4538. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4539. /**
  4540. * Creates a rotation matrix and stores it in a given matrix
  4541. * @param yaw defines the yaw angle in radians (Y axis)
  4542. * @param pitch defines the pitch angle in radians (X axis)
  4543. * @param roll defines the roll angle in radians (Z axis)
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4547. /**
  4548. * Creates a scaling matrix
  4549. * @param x defines the scale factor on X axis
  4550. * @param y defines the scale factor on Y axis
  4551. * @param z defines the scale factor on Z axis
  4552. * @returns the new matrix
  4553. */
  4554. static Scaling(x: number, y: number, z: number): Matrix;
  4555. /**
  4556. * Creates a scaling matrix and stores it in a given matrix
  4557. * @param x defines the scale factor on X axis
  4558. * @param y defines the scale factor on Y axis
  4559. * @param z defines the scale factor on Z axis
  4560. * @param result defines the target matrix
  4561. */
  4562. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4563. /**
  4564. * Creates a translation matrix
  4565. * @param x defines the translation on X axis
  4566. * @param y defines the translation on Y axis
  4567. * @param z defines the translationon Z axis
  4568. * @returns the new matrix
  4569. */
  4570. static Translation(x: number, y: number, z: number): Matrix;
  4571. /**
  4572. * Creates a translation matrix and stores it in a given matrix
  4573. * @param x defines the translation on X axis
  4574. * @param y defines the translation on Y axis
  4575. * @param z defines the translationon Z axis
  4576. * @param result defines the target matrix
  4577. */
  4578. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4579. /**
  4580. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4581. * @param startValue defines the start value
  4582. * @param endValue defines the end value
  4583. * @param gradient defines the gradient factor
  4584. * @returns the new matrix
  4585. */
  4586. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4587. /**
  4588. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4589. * @param startValue defines the start value
  4590. * @param endValue defines the end value
  4591. * @param gradient defines the gradient factor
  4592. * @param result defines the Matrix object where to store data
  4593. */
  4594. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4595. /**
  4596. * Builds a new matrix whose values are computed by:
  4597. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4598. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4599. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4600. * @param startValue defines the first matrix
  4601. * @param endValue defines the second matrix
  4602. * @param gradient defines the gradient between the two matrices
  4603. * @returns the new matrix
  4604. */
  4605. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4606. /**
  4607. * Update a matrix to values which are computed by:
  4608. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4609. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4610. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4611. * @param startValue defines the first matrix
  4612. * @param endValue defines the second matrix
  4613. * @param gradient defines the gradient between the two matrices
  4614. * @param result defines the target matrix
  4615. */
  4616. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4617. /**
  4618. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4619. * This function works in left handed mode
  4620. * @param eye defines the final position of the entity
  4621. * @param target defines where the entity should look at
  4622. * @param up defines the up vector for the entity
  4623. * @returns the new matrix
  4624. */
  4625. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4626. /**
  4627. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4628. * This function works in left handed mode
  4629. * @param eye defines the final position of the entity
  4630. * @param target defines where the entity should look at
  4631. * @param up defines the up vector for the entity
  4632. * @param result defines the target matrix
  4633. */
  4634. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4635. /**
  4636. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4637. * This function works in right handed mode
  4638. * @param eye defines the final position of the entity
  4639. * @param target defines where the entity should look at
  4640. * @param up defines the up vector for the entity
  4641. * @returns the new matrix
  4642. */
  4643. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4644. /**
  4645. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4646. * This function works in right handed mode
  4647. * @param eye defines the final position of the entity
  4648. * @param target defines where the entity should look at
  4649. * @param up defines the up vector for the entity
  4650. * @param result defines the target matrix
  4651. */
  4652. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4653. /**
  4654. * Create a left-handed orthographic projection matrix
  4655. * @param width defines the viewport width
  4656. * @param height defines the viewport height
  4657. * @param znear defines the near clip plane
  4658. * @param zfar defines the far clip plane
  4659. * @returns a new matrix as a left-handed orthographic projection matrix
  4660. */
  4661. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4662. /**
  4663. * Store a left-handed orthographic projection to a given matrix
  4664. * @param width defines the viewport width
  4665. * @param height defines the viewport height
  4666. * @param znear defines the near clip plane
  4667. * @param zfar defines the far clip plane
  4668. * @param result defines the target matrix
  4669. */
  4670. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4671. /**
  4672. * Create a left-handed orthographic projection matrix
  4673. * @param left defines the viewport left coordinate
  4674. * @param right defines the viewport right coordinate
  4675. * @param bottom defines the viewport bottom coordinate
  4676. * @param top defines the viewport top coordinate
  4677. * @param znear defines the near clip plane
  4678. * @param zfar defines the far clip plane
  4679. * @returns a new matrix as a left-handed orthographic projection matrix
  4680. */
  4681. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4682. /**
  4683. * Stores a left-handed orthographic projection into a given matrix
  4684. * @param left defines the viewport left coordinate
  4685. * @param right defines the viewport right coordinate
  4686. * @param bottom defines the viewport bottom coordinate
  4687. * @param top defines the viewport top coordinate
  4688. * @param znear defines the near clip plane
  4689. * @param zfar defines the far clip plane
  4690. * @param result defines the target matrix
  4691. */
  4692. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4693. /**
  4694. * Creates a right-handed orthographic projection matrix
  4695. * @param left defines the viewport left coordinate
  4696. * @param right defines the viewport right coordinate
  4697. * @param bottom defines the viewport bottom coordinate
  4698. * @param top defines the viewport top coordinate
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed orthographic projection matrix
  4702. */
  4703. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed orthographic projection into a given matrix
  4706. * @param left defines the viewport left coordinate
  4707. * @param right defines the viewport right coordinate
  4708. * @param bottom defines the viewport bottom coordinate
  4709. * @param top defines the viewport top coordinate
  4710. * @param znear defines the near clip plane
  4711. * @param zfar defines the far clip plane
  4712. * @param result defines the target matrix
  4713. */
  4714. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4715. /**
  4716. * Creates a left-handed perspective projection matrix
  4717. * @param width defines the viewport width
  4718. * @param height defines the viewport height
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a left-handed perspective projection matrix
  4722. */
  4723. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Creates a left-handed perspective projection matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @returns a new matrix as a left-handed perspective projection matrix
  4731. */
  4732. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4733. /**
  4734. * Stores a left-handed perspective projection into a given matrix
  4735. * @param fov defines the horizontal field of view
  4736. * @param aspect defines the aspect ratio
  4737. * @param znear defines the near clip plane
  4738. * @param zfar defines the far clip plane
  4739. * @param result defines the target matrix
  4740. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4741. */
  4742. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4743. /**
  4744. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4745. * @param fov defines the horizontal field of view
  4746. * @param aspect defines the aspect ratio
  4747. * @param znear defines the near clip plane
  4748. * @param zfar not used as infinity is used as far clip
  4749. * @param result defines the target matrix
  4750. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4751. */
  4752. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4753. /**
  4754. * Creates a right-handed perspective projection matrix
  4755. * @param fov defines the horizontal field of view
  4756. * @param aspect defines the aspect ratio
  4757. * @param znear defines the near clip plane
  4758. * @param zfar defines the far clip plane
  4759. * @returns a new matrix as a right-handed perspective projection matrix
  4760. */
  4761. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4762. /**
  4763. * Stores a right-handed perspective projection into a given matrix
  4764. * @param fov defines the horizontal field of view
  4765. * @param aspect defines the aspect ratio
  4766. * @param znear defines the near clip plane
  4767. * @param zfar defines the far clip plane
  4768. * @param result defines the target matrix
  4769. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4770. */
  4771. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4772. /**
  4773. * Stores a right-handed perspective projection into a given matrix
  4774. * @param fov defines the horizontal field of view
  4775. * @param aspect defines the aspect ratio
  4776. * @param znear defines the near clip plane
  4777. * @param zfar not used as infinity is used as far clip
  4778. * @param result defines the target matrix
  4779. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4780. */
  4781. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4782. /**
  4783. * Stores a perspective projection for WebVR info a given matrix
  4784. * @param fov defines the field of view
  4785. * @param znear defines the near clip plane
  4786. * @param zfar defines the far clip plane
  4787. * @param result defines the target matrix
  4788. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4789. */
  4790. static PerspectiveFovWebVRToRef(fov: {
  4791. upDegrees: number;
  4792. downDegrees: number;
  4793. leftDegrees: number;
  4794. rightDegrees: number;
  4795. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4796. /**
  4797. * Computes a complete transformation matrix
  4798. * @param viewport defines the viewport to use
  4799. * @param world defines the world matrix
  4800. * @param view defines the view matrix
  4801. * @param projection defines the projection matrix
  4802. * @param zmin defines the near clip plane
  4803. * @param zmax defines the far clip plane
  4804. * @returns the transformation matrix
  4805. */
  4806. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4807. /**
  4808. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4809. * @param matrix defines the matrix to use
  4810. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4811. */
  4812. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4813. /**
  4814. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4815. * @param matrix defines the matrix to use
  4816. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4817. */
  4818. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4819. /**
  4820. * Compute the transpose of a given matrix
  4821. * @param matrix defines the matrix to transpose
  4822. * @returns the new matrix
  4823. */
  4824. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4825. /**
  4826. * Compute the transpose of a matrix and store it in a target matrix
  4827. * @param matrix defines the matrix to transpose
  4828. * @param result defines the target matrix
  4829. */
  4830. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4831. /**
  4832. * Computes a reflection matrix from a plane
  4833. * @param plane defines the reflection plane
  4834. * @returns a new matrix
  4835. */
  4836. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4837. /**
  4838. * Computes a reflection matrix from a plane
  4839. * @param plane defines the reflection plane
  4840. * @param result defines the target matrix
  4841. */
  4842. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4843. /**
  4844. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4845. * @param xaxis defines the value of the 1st axis
  4846. * @param yaxis defines the value of the 2nd axis
  4847. * @param zaxis defines the value of the 3rd axis
  4848. * @param result defines the target matrix
  4849. */
  4850. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4851. /**
  4852. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4853. * @param quat defines the quaternion to use
  4854. * @param result defines the target matrix
  4855. */
  4856. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4857. }
  4858. /**
  4859. * @hidden
  4860. */
  4861. export class TmpVectors {
  4862. static Vector2: Vector2[];
  4863. static Vector3: Vector3[];
  4864. static Vector4: Vector4[];
  4865. static Quaternion: Quaternion[];
  4866. static Matrix: Matrix[];
  4867. }
  4868. }
  4869. declare module BABYLON {
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module BABYLON {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module BABYLON {
  5516. /**
  5517. * Class used to hold a RBG color
  5518. */
  5519. export class Color3 {
  5520. /**
  5521. * Defines the red component (between 0 and 1, default is 0)
  5522. */
  5523. r: number;
  5524. /**
  5525. * Defines the green component (between 0 and 1, default is 0)
  5526. */
  5527. g: number;
  5528. /**
  5529. * Defines the blue component (between 0 and 1, default is 0)
  5530. */
  5531. b: number;
  5532. /**
  5533. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5534. * @param r defines the red component (between 0 and 1, default is 0)
  5535. * @param g defines the green component (between 0 and 1, default is 0)
  5536. * @param b defines the blue component (between 0 and 1, default is 0)
  5537. */
  5538. constructor(
  5539. /**
  5540. * Defines the red component (between 0 and 1, default is 0)
  5541. */
  5542. r?: number,
  5543. /**
  5544. * Defines the green component (between 0 and 1, default is 0)
  5545. */
  5546. g?: number,
  5547. /**
  5548. * Defines the blue component (between 0 and 1, default is 0)
  5549. */
  5550. b?: number);
  5551. /**
  5552. * Creates a string with the Color3 current values
  5553. * @returns the string representation of the Color3 object
  5554. */
  5555. toString(): string;
  5556. /**
  5557. * Returns the string "Color3"
  5558. * @returns "Color3"
  5559. */
  5560. getClassName(): string;
  5561. /**
  5562. * Compute the Color3 hash code
  5563. * @returns an unique number that can be used to hash Color3 objects
  5564. */
  5565. getHashCode(): number;
  5566. /**
  5567. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5568. * @param array defines the array where to store the r,g,b components
  5569. * @param index defines an optional index in the target array to define where to start storing values
  5570. * @returns the current Color3 object
  5571. */
  5572. toArray(array: FloatArray, index?: number): Color3;
  5573. /**
  5574. * Update the current color with values stored in an array from the starting index of the given array
  5575. * @param array defines the source array
  5576. * @param offset defines an offset in the source array
  5577. * @returns the current Color3 object
  5578. */
  5579. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5580. /**
  5581. * Returns a new Color4 object from the current Color3 and the given alpha
  5582. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5583. * @returns a new Color4 object
  5584. */
  5585. toColor4(alpha?: number): Color4;
  5586. /**
  5587. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5588. * @returns the new array
  5589. */
  5590. asArray(): number[];
  5591. /**
  5592. * Returns the luminance value
  5593. * @returns a float value
  5594. */
  5595. toLuminance(): number;
  5596. /**
  5597. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5598. * @param otherColor defines the second operand
  5599. * @returns the new Color3 object
  5600. */
  5601. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5602. /**
  5603. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5604. * @param otherColor defines the second operand
  5605. * @param result defines the Color3 object where to store the result
  5606. * @returns the current Color3
  5607. */
  5608. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5609. /**
  5610. * Determines equality between Color3 objects
  5611. * @param otherColor defines the second operand
  5612. * @returns true if the rgb values are equal to the given ones
  5613. */
  5614. equals(otherColor: DeepImmutable<Color3>): boolean;
  5615. /**
  5616. * Determines equality between the current Color3 object and a set of r,b,g values
  5617. * @param r defines the red component to check
  5618. * @param g defines the green component to check
  5619. * @param b defines the blue component to check
  5620. * @returns true if the rgb values are equal to the given ones
  5621. */
  5622. equalsFloats(r: number, g: number, b: number): boolean;
  5623. /**
  5624. * Multiplies in place each rgb value by scale
  5625. * @param scale defines the scaling factor
  5626. * @returns the updated Color3
  5627. */
  5628. scale(scale: number): Color3;
  5629. /**
  5630. * Multiplies the rgb values by scale and stores the result into "result"
  5631. * @param scale defines the scaling factor
  5632. * @param result defines the Color3 object where to store the result
  5633. * @returns the unmodified current Color3
  5634. */
  5635. scaleToRef(scale: number, result: Color3): Color3;
  5636. /**
  5637. * Scale the current Color3 values by a factor and add the result to a given Color3
  5638. * @param scale defines the scale factor
  5639. * @param result defines color to store the result into
  5640. * @returns the unmodified current Color3
  5641. */
  5642. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5643. /**
  5644. * Clamps the rgb values by the min and max values and stores the result into "result"
  5645. * @param min defines minimum clamping value (default is 0)
  5646. * @param max defines maximum clamping value (default is 1)
  5647. * @param result defines color to store the result into
  5648. * @returns the original Color3
  5649. */
  5650. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5651. /**
  5652. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5653. * @param otherColor defines the second operand
  5654. * @returns the new Color3
  5655. */
  5656. add(otherColor: DeepImmutable<Color3>): Color3;
  5657. /**
  5658. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5659. * @param otherColor defines the second operand
  5660. * @param result defines Color3 object to store the result into
  5661. * @returns the unmodified current Color3
  5662. */
  5663. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5664. /**
  5665. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5666. * @param otherColor defines the second operand
  5667. * @returns the new Color3
  5668. */
  5669. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5670. /**
  5671. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5672. * @param otherColor defines the second operand
  5673. * @param result defines Color3 object to store the result into
  5674. * @returns the unmodified current Color3
  5675. */
  5676. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5677. /**
  5678. * Copy the current object
  5679. * @returns a new Color3 copied the current one
  5680. */
  5681. clone(): Color3;
  5682. /**
  5683. * Copies the rgb values from the source in the current Color3
  5684. * @param source defines the source Color3 object
  5685. * @returns the updated Color3 object
  5686. */
  5687. copyFrom(source: DeepImmutable<Color3>): Color3;
  5688. /**
  5689. * Updates the Color3 rgb values from the given floats
  5690. * @param r defines the red component to read from
  5691. * @param g defines the green component to read from
  5692. * @param b defines the blue component to read from
  5693. * @returns the current Color3 object
  5694. */
  5695. copyFromFloats(r: number, g: number, b: number): Color3;
  5696. /**
  5697. * Updates the Color3 rgb values from the given floats
  5698. * @param r defines the red component to read from
  5699. * @param g defines the green component to read from
  5700. * @param b defines the blue component to read from
  5701. * @returns the current Color3 object
  5702. */
  5703. set(r: number, g: number, b: number): Color3;
  5704. /**
  5705. * Compute the Color3 hexadecimal code as a string
  5706. * @returns a string containing the hexadecimal representation of the Color3 object
  5707. */
  5708. toHexString(): string;
  5709. /**
  5710. * Computes a new Color3 converted from the current one to linear space
  5711. * @returns a new Color3 object
  5712. */
  5713. toLinearSpace(): Color3;
  5714. /**
  5715. * Converts current color in rgb space to HSV values
  5716. * @returns a new color3 representing the HSV values
  5717. */
  5718. toHSV(): Color3;
  5719. /**
  5720. * Converts current color in rgb space to HSV values
  5721. * @param result defines the Color3 where to store the HSV values
  5722. */
  5723. toHSVToRef(result: Color3): void;
  5724. /**
  5725. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5726. * @param convertedColor defines the Color3 object where to store the linear space version
  5727. * @returns the unmodified Color3
  5728. */
  5729. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5730. /**
  5731. * Computes a new Color3 converted from the current one to gamma space
  5732. * @returns a new Color3 object
  5733. */
  5734. toGammaSpace(): Color3;
  5735. /**
  5736. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5737. * @param convertedColor defines the Color3 object where to store the gamma space version
  5738. * @returns the unmodified Color3
  5739. */
  5740. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5741. private static _BlackReadOnly;
  5742. /**
  5743. * Convert Hue, saturation and value to a Color3 (RGB)
  5744. * @param hue defines the hue
  5745. * @param saturation defines the saturation
  5746. * @param value defines the value
  5747. * @param result defines the Color3 where to store the RGB values
  5748. */
  5749. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5750. /**
  5751. * Creates a new Color3 from the string containing valid hexadecimal values
  5752. * @param hex defines a string containing valid hexadecimal values
  5753. * @returns a new Color3 object
  5754. */
  5755. static FromHexString(hex: string): Color3;
  5756. /**
  5757. * Creates a new Color3 from the starting index of the given array
  5758. * @param array defines the source array
  5759. * @param offset defines an offset in the source array
  5760. * @returns a new Color3 object
  5761. */
  5762. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5763. /**
  5764. * Creates a new Color3 from the starting index element of the given array
  5765. * @param array defines the source array to read from
  5766. * @param offset defines the offset in the source array
  5767. * @param result defines the target Color3 object
  5768. */
  5769. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5770. /**
  5771. * Creates a new Color3 from integer values (< 256)
  5772. * @param r defines the red component to read from (value between 0 and 255)
  5773. * @param g defines the green component to read from (value between 0 and 255)
  5774. * @param b defines the blue component to read from (value between 0 and 255)
  5775. * @returns a new Color3 object
  5776. */
  5777. static FromInts(r: number, g: number, b: number): Color3;
  5778. /**
  5779. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5780. * @param start defines the start Color3 value
  5781. * @param end defines the end Color3 value
  5782. * @param amount defines the gradient value between start and end
  5783. * @returns a new Color3 object
  5784. */
  5785. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5786. /**
  5787. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5788. * @param left defines the start value
  5789. * @param right defines the end value
  5790. * @param amount defines the gradient factor
  5791. * @param result defines the Color3 object where to store the result
  5792. */
  5793. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5794. /**
  5795. * Returns a Color3 value containing a red color
  5796. * @returns a new Color3 object
  5797. */
  5798. static Red(): Color3;
  5799. /**
  5800. * Returns a Color3 value containing a green color
  5801. * @returns a new Color3 object
  5802. */
  5803. static Green(): Color3;
  5804. /**
  5805. * Returns a Color3 value containing a blue color
  5806. * @returns a new Color3 object
  5807. */
  5808. static Blue(): Color3;
  5809. /**
  5810. * Returns a Color3 value containing a black color
  5811. * @returns a new Color3 object
  5812. */
  5813. static Black(): Color3;
  5814. /**
  5815. * Gets a Color3 value containing a black color that must not be updated
  5816. */
  5817. static get BlackReadOnly(): DeepImmutable<Color3>;
  5818. /**
  5819. * Returns a Color3 value containing a white color
  5820. * @returns a new Color3 object
  5821. */
  5822. static White(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a purple color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Purple(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a magenta color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Magenta(): Color3;
  5833. /**
  5834. * Returns a Color3 value containing a yellow color
  5835. * @returns a new Color3 object
  5836. */
  5837. static Yellow(): Color3;
  5838. /**
  5839. * Returns a Color3 value containing a gray color
  5840. * @returns a new Color3 object
  5841. */
  5842. static Gray(): Color3;
  5843. /**
  5844. * Returns a Color3 value containing a teal color
  5845. * @returns a new Color3 object
  5846. */
  5847. static Teal(): Color3;
  5848. /**
  5849. * Returns a Color3 value containing a random color
  5850. * @returns a new Color3 object
  5851. */
  5852. static Random(): Color3;
  5853. }
  5854. /**
  5855. * Class used to hold a RBGA color
  5856. */
  5857. export class Color4 {
  5858. /**
  5859. * Defines the red component (between 0 and 1, default is 0)
  5860. */
  5861. r: number;
  5862. /**
  5863. * Defines the green component (between 0 and 1, default is 0)
  5864. */
  5865. g: number;
  5866. /**
  5867. * Defines the blue component (between 0 and 1, default is 0)
  5868. */
  5869. b: number;
  5870. /**
  5871. * Defines the alpha component (between 0 and 1, default is 1)
  5872. */
  5873. a: number;
  5874. /**
  5875. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5876. * @param r defines the red component (between 0 and 1, default is 0)
  5877. * @param g defines the green component (between 0 and 1, default is 0)
  5878. * @param b defines the blue component (between 0 and 1, default is 0)
  5879. * @param a defines the alpha component (between 0 and 1, default is 1)
  5880. */
  5881. constructor(
  5882. /**
  5883. * Defines the red component (between 0 and 1, default is 0)
  5884. */
  5885. r?: number,
  5886. /**
  5887. * Defines the green component (between 0 and 1, default is 0)
  5888. */
  5889. g?: number,
  5890. /**
  5891. * Defines the blue component (between 0 and 1, default is 0)
  5892. */
  5893. b?: number,
  5894. /**
  5895. * Defines the alpha component (between 0 and 1, default is 1)
  5896. */
  5897. a?: number);
  5898. /**
  5899. * Adds in place the given Color4 values to the current Color4 object
  5900. * @param right defines the second operand
  5901. * @returns the current updated Color4 object
  5902. */
  5903. addInPlace(right: DeepImmutable<Color4>): Color4;
  5904. /**
  5905. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5906. * @returns the new array
  5907. */
  5908. asArray(): number[];
  5909. /**
  5910. * Stores from the starting index in the given array the Color4 successive values
  5911. * @param array defines the array where to store the r,g,b components
  5912. * @param index defines an optional index in the target array to define where to start storing values
  5913. * @returns the current Color4 object
  5914. */
  5915. toArray(array: number[], index?: number): Color4;
  5916. /**
  5917. * Update the current color with values stored in an array from the starting index of the given array
  5918. * @param array defines the source array
  5919. * @param offset defines an offset in the source array
  5920. * @returns the current Color4 object
  5921. */
  5922. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5923. /**
  5924. * Determines equality between Color4 objects
  5925. * @param otherColor defines the second operand
  5926. * @returns true if the rgba values are equal to the given ones
  5927. */
  5928. equals(otherColor: DeepImmutable<Color4>): boolean;
  5929. /**
  5930. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5931. * @param right defines the second operand
  5932. * @returns a new Color4 object
  5933. */
  5934. add(right: DeepImmutable<Color4>): Color4;
  5935. /**
  5936. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5937. * @param right defines the second operand
  5938. * @returns a new Color4 object
  5939. */
  5940. subtract(right: DeepImmutable<Color4>): Color4;
  5941. /**
  5942. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5943. * @param right defines the second operand
  5944. * @param result defines the Color4 object where to store the result
  5945. * @returns the current Color4 object
  5946. */
  5947. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5948. /**
  5949. * Creates a new Color4 with the current Color4 values multiplied by scale
  5950. * @param scale defines the scaling factor to apply
  5951. * @returns a new Color4 object
  5952. */
  5953. scale(scale: number): Color4;
  5954. /**
  5955. * Multiplies the current Color4 values by scale and stores the result in "result"
  5956. * @param scale defines the scaling factor to apply
  5957. * @param result defines the Color4 object where to store the result
  5958. * @returns the current unmodified Color4
  5959. */
  5960. scaleToRef(scale: number, result: Color4): Color4;
  5961. /**
  5962. * Scale the current Color4 values by a factor and add the result to a given Color4
  5963. * @param scale defines the scale factor
  5964. * @param result defines the Color4 object where to store the result
  5965. * @returns the unmodified current Color4
  5966. */
  5967. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5968. /**
  5969. * Clamps the rgb values by the min and max values and stores the result into "result"
  5970. * @param min defines minimum clamping value (default is 0)
  5971. * @param max defines maximum clamping value (default is 1)
  5972. * @param result defines color to store the result into.
  5973. * @returns the cuurent Color4
  5974. */
  5975. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5976. /**
  5977. * Multipy an Color4 value by another and return a new Color4 object
  5978. * @param color defines the Color4 value to multiply by
  5979. * @returns a new Color4 object
  5980. */
  5981. multiply(color: Color4): Color4;
  5982. /**
  5983. * Multipy a Color4 value by another and push the result in a reference value
  5984. * @param color defines the Color4 value to multiply by
  5985. * @param result defines the Color4 to fill the result in
  5986. * @returns the result Color4
  5987. */
  5988. multiplyToRef(color: Color4, result: Color4): Color4;
  5989. /**
  5990. * Creates a string with the Color4 current values
  5991. * @returns the string representation of the Color4 object
  5992. */
  5993. toString(): string;
  5994. /**
  5995. * Returns the string "Color4"
  5996. * @returns "Color4"
  5997. */
  5998. getClassName(): string;
  5999. /**
  6000. * Compute the Color4 hash code
  6001. * @returns an unique number that can be used to hash Color4 objects
  6002. */
  6003. getHashCode(): number;
  6004. /**
  6005. * Creates a new Color4 copied from the current one
  6006. * @returns a new Color4 object
  6007. */
  6008. clone(): Color4;
  6009. /**
  6010. * Copies the given Color4 values into the current one
  6011. * @param source defines the source Color4 object
  6012. * @returns the current updated Color4 object
  6013. */
  6014. copyFrom(source: Color4): Color4;
  6015. /**
  6016. * Copies the given float values into the current one
  6017. * @param r defines the red component to read from
  6018. * @param g defines the green component to read from
  6019. * @param b defines the blue component to read from
  6020. * @param a defines the alpha component to read from
  6021. * @returns the current updated Color4 object
  6022. */
  6023. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6024. /**
  6025. * Copies the given float values into the current one
  6026. * @param r defines the red component to read from
  6027. * @param g defines the green component to read from
  6028. * @param b defines the blue component to read from
  6029. * @param a defines the alpha component to read from
  6030. * @returns the current updated Color4 object
  6031. */
  6032. set(r: number, g: number, b: number, a: number): Color4;
  6033. /**
  6034. * Compute the Color4 hexadecimal code as a string
  6035. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6036. * @returns a string containing the hexadecimal representation of the Color4 object
  6037. */
  6038. toHexString(returnAsColor3?: boolean): string;
  6039. /**
  6040. * Computes a new Color4 converted from the current one to linear space
  6041. * @returns a new Color4 object
  6042. */
  6043. toLinearSpace(): Color4;
  6044. /**
  6045. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6046. * @param convertedColor defines the Color4 object where to store the linear space version
  6047. * @returns the unmodified Color4
  6048. */
  6049. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6050. /**
  6051. * Computes a new Color4 converted from the current one to gamma space
  6052. * @returns a new Color4 object
  6053. */
  6054. toGammaSpace(): Color4;
  6055. /**
  6056. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6057. * @param convertedColor defines the Color4 object where to store the gamma space version
  6058. * @returns the unmodified Color4
  6059. */
  6060. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6061. /**
  6062. * Creates a new Color4 from the string containing valid hexadecimal values
  6063. * @param hex defines a string containing valid hexadecimal values
  6064. * @returns a new Color4 object
  6065. */
  6066. static FromHexString(hex: string): Color4;
  6067. /**
  6068. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6069. * @param left defines the start value
  6070. * @param right defines the end value
  6071. * @param amount defines the gradient factor
  6072. * @returns a new Color4 object
  6073. */
  6074. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6075. /**
  6076. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6077. * @param left defines the start value
  6078. * @param right defines the end value
  6079. * @param amount defines the gradient factor
  6080. * @param result defines the Color4 object where to store data
  6081. */
  6082. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6083. /**
  6084. * Creates a new Color4 from a Color3 and an alpha value
  6085. * @param color3 defines the source Color3 to read from
  6086. * @param alpha defines the alpha component (1.0 by default)
  6087. * @returns a new Color4 object
  6088. */
  6089. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6090. /**
  6091. * Creates a new Color4 from the starting index element of the given array
  6092. * @param array defines the source array to read from
  6093. * @param offset defines the offset in the source array
  6094. * @returns a new Color4 object
  6095. */
  6096. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6097. /**
  6098. * Creates a new Color4 from the starting index element of the given array
  6099. * @param array defines the source array to read from
  6100. * @param offset defines the offset in the source array
  6101. * @param result defines the target Color4 object
  6102. */
  6103. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6104. /**
  6105. * Creates a new Color3 from integer values (< 256)
  6106. * @param r defines the red component to read from (value between 0 and 255)
  6107. * @param g defines the green component to read from (value between 0 and 255)
  6108. * @param b defines the blue component to read from (value between 0 and 255)
  6109. * @param a defines the alpha component to read from (value between 0 and 255)
  6110. * @returns a new Color3 object
  6111. */
  6112. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6113. /**
  6114. * Check the content of a given array and convert it to an array containing RGBA data
  6115. * If the original array was already containing count * 4 values then it is returned directly
  6116. * @param colors defines the array to check
  6117. * @param count defines the number of RGBA data to expect
  6118. * @returns an array containing count * 4 values (RGBA)
  6119. */
  6120. static CheckColors4(colors: number[], count: number): number[];
  6121. }
  6122. /**
  6123. * @hidden
  6124. */
  6125. export class TmpColors {
  6126. static Color3: Color3[];
  6127. static Color4: Color4[];
  6128. }
  6129. }
  6130. declare module BABYLON {
  6131. /**
  6132. * Defines an interface which represents an animation key frame
  6133. */
  6134. export interface IAnimationKey {
  6135. /**
  6136. * Frame of the key frame
  6137. */
  6138. frame: number;
  6139. /**
  6140. * Value at the specifies key frame
  6141. */
  6142. value: any;
  6143. /**
  6144. * The input tangent for the cubic hermite spline
  6145. */
  6146. inTangent?: any;
  6147. /**
  6148. * The output tangent for the cubic hermite spline
  6149. */
  6150. outTangent?: any;
  6151. /**
  6152. * The animation interpolation type
  6153. */
  6154. interpolation?: AnimationKeyInterpolation;
  6155. }
  6156. /**
  6157. * Enum for the animation key frame interpolation type
  6158. */
  6159. export enum AnimationKeyInterpolation {
  6160. /**
  6161. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6162. */
  6163. STEP = 1
  6164. }
  6165. }
  6166. declare module BABYLON {
  6167. /**
  6168. * Represents the range of an animation
  6169. */
  6170. export class AnimationRange {
  6171. /**The name of the animation range**/
  6172. name: string;
  6173. /**The starting frame of the animation */
  6174. from: number;
  6175. /**The ending frame of the animation*/
  6176. to: number;
  6177. /**
  6178. * Initializes the range of an animation
  6179. * @param name The name of the animation range
  6180. * @param from The starting frame of the animation
  6181. * @param to The ending frame of the animation
  6182. */
  6183. constructor(
  6184. /**The name of the animation range**/
  6185. name: string,
  6186. /**The starting frame of the animation */
  6187. from: number,
  6188. /**The ending frame of the animation*/
  6189. to: number);
  6190. /**
  6191. * Makes a copy of the animation range
  6192. * @returns A copy of the animation range
  6193. */
  6194. clone(): AnimationRange;
  6195. }
  6196. }
  6197. declare module BABYLON {
  6198. /**
  6199. * Composed of a frame, and an action function
  6200. */
  6201. export class AnimationEvent {
  6202. /** The frame for which the event is triggered **/
  6203. frame: number;
  6204. /** The event to perform when triggered **/
  6205. action: (currentFrame: number) => void;
  6206. /** Specifies if the event should be triggered only once**/
  6207. onlyOnce?: boolean | undefined;
  6208. /**
  6209. * Specifies if the animation event is done
  6210. */
  6211. isDone: boolean;
  6212. /**
  6213. * Initializes the animation event
  6214. * @param frame The frame for which the event is triggered
  6215. * @param action The event to perform when triggered
  6216. * @param onlyOnce Specifies if the event should be triggered only once
  6217. */
  6218. constructor(
  6219. /** The frame for which the event is triggered **/
  6220. frame: number,
  6221. /** The event to perform when triggered **/
  6222. action: (currentFrame: number) => void,
  6223. /** Specifies if the event should be triggered only once**/
  6224. onlyOnce?: boolean | undefined);
  6225. /** @hidden */
  6226. _clone(): AnimationEvent;
  6227. }
  6228. }
  6229. declare module BABYLON {
  6230. /**
  6231. * Interface used to define a behavior
  6232. */
  6233. export interface Behavior<T> {
  6234. /** gets or sets behavior's name */
  6235. name: string;
  6236. /**
  6237. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6238. */
  6239. init(): void;
  6240. /**
  6241. * Called when the behavior is attached to a target
  6242. * @param target defines the target where the behavior is attached to
  6243. */
  6244. attach(target: T): void;
  6245. /**
  6246. * Called when the behavior is detached from its target
  6247. */
  6248. detach(): void;
  6249. }
  6250. /**
  6251. * Interface implemented by classes supporting behaviors
  6252. */
  6253. export interface IBehaviorAware<T> {
  6254. /**
  6255. * Attach a behavior
  6256. * @param behavior defines the behavior to attach
  6257. * @returns the current host
  6258. */
  6259. addBehavior(behavior: Behavior<T>): T;
  6260. /**
  6261. * Remove a behavior from the current object
  6262. * @param behavior defines the behavior to detach
  6263. * @returns the current host
  6264. */
  6265. removeBehavior(behavior: Behavior<T>): T;
  6266. /**
  6267. * Gets a behavior using its name to search
  6268. * @param name defines the name to search
  6269. * @returns the behavior or null if not found
  6270. */
  6271. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6272. }
  6273. }
  6274. declare module BABYLON {
  6275. /**
  6276. * Defines an array and its length.
  6277. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6278. */
  6279. export interface ISmartArrayLike<T> {
  6280. /**
  6281. * The data of the array.
  6282. */
  6283. data: Array<T>;
  6284. /**
  6285. * The active length of the array.
  6286. */
  6287. length: number;
  6288. }
  6289. /**
  6290. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6291. */
  6292. export class SmartArray<T> implements ISmartArrayLike<T> {
  6293. /**
  6294. * The full set of data from the array.
  6295. */
  6296. data: Array<T>;
  6297. /**
  6298. * The active length of the array.
  6299. */
  6300. length: number;
  6301. protected _id: number;
  6302. /**
  6303. * Instantiates a Smart Array.
  6304. * @param capacity defines the default capacity of the array.
  6305. */
  6306. constructor(capacity: number);
  6307. /**
  6308. * Pushes a value at the end of the active data.
  6309. * @param value defines the object to push in the array.
  6310. */
  6311. push(value: T): void;
  6312. /**
  6313. * Iterates over the active data and apply the lambda to them.
  6314. * @param func defines the action to apply on each value.
  6315. */
  6316. forEach(func: (content: T) => void): void;
  6317. /**
  6318. * Sorts the full sets of data.
  6319. * @param compareFn defines the comparison function to apply.
  6320. */
  6321. sort(compareFn: (a: T, b: T) => number): void;
  6322. /**
  6323. * Resets the active data to an empty array.
  6324. */
  6325. reset(): void;
  6326. /**
  6327. * Releases all the data from the array as well as the array.
  6328. */
  6329. dispose(): void;
  6330. /**
  6331. * Concats the active data with a given array.
  6332. * @param array defines the data to concatenate with.
  6333. */
  6334. concat(array: any): void;
  6335. /**
  6336. * Returns the position of a value in the active data.
  6337. * @param value defines the value to find the index for
  6338. * @returns the index if found in the active data otherwise -1
  6339. */
  6340. indexOf(value: T): number;
  6341. /**
  6342. * Returns whether an element is part of the active data.
  6343. * @param value defines the value to look for
  6344. * @returns true if found in the active data otherwise false
  6345. */
  6346. contains(value: T): boolean;
  6347. private static _GlobalId;
  6348. }
  6349. /**
  6350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6351. * The data in this array can only be present once
  6352. */
  6353. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6354. private _duplicateId;
  6355. /**
  6356. * Pushes a value at the end of the active data.
  6357. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6358. * @param value defines the object to push in the array.
  6359. */
  6360. push(value: T): void;
  6361. /**
  6362. * Pushes a value at the end of the active data.
  6363. * If the data is already present, it won t be added again
  6364. * @param value defines the object to push in the array.
  6365. * @returns true if added false if it was already present
  6366. */
  6367. pushNoDuplicate(value: T): boolean;
  6368. /**
  6369. * Resets the active data to an empty array.
  6370. */
  6371. reset(): void;
  6372. /**
  6373. * Concats the active data with a given array.
  6374. * This ensures no dupplicate will be present in the result.
  6375. * @param array defines the data to concatenate with.
  6376. */
  6377. concatWithNoDuplicate(array: any): void;
  6378. }
  6379. }
  6380. declare module BABYLON {
  6381. /**
  6382. * @ignore
  6383. * This is a list of all the different input types that are available in the application.
  6384. * Fo instance: ArcRotateCameraGamepadInput...
  6385. */
  6386. export var CameraInputTypes: {};
  6387. /**
  6388. * This is the contract to implement in order to create a new input class.
  6389. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6390. */
  6391. export interface ICameraInput<TCamera extends Camera> {
  6392. /**
  6393. * Defines the camera the input is attached to.
  6394. */
  6395. camera: Nullable<TCamera>;
  6396. /**
  6397. * Gets the class name of the current intput.
  6398. * @returns the class name
  6399. */
  6400. getClassName(): string;
  6401. /**
  6402. * Get the friendly name associated with the input class.
  6403. * @returns the input friendly name
  6404. */
  6405. getSimpleName(): string;
  6406. /**
  6407. * Attach the input controls to a specific dom element to get the input from.
  6408. * @param element Defines the element the controls should be listened from
  6409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6410. */
  6411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6412. /**
  6413. * Detach the current controls from the specified dom element.
  6414. * @param element Defines the element to stop listening the inputs from
  6415. */
  6416. detachControl(element: Nullable<HTMLElement>): void;
  6417. /**
  6418. * Update the current camera state depending on the inputs that have been used this frame.
  6419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6420. */
  6421. checkInputs?: () => void;
  6422. }
  6423. /**
  6424. * Represents a map of input types to input instance or input index to input instance.
  6425. */
  6426. export interface CameraInputsMap<TCamera extends Camera> {
  6427. /**
  6428. * Accessor to the input by input type.
  6429. */
  6430. [name: string]: ICameraInput<TCamera>;
  6431. /**
  6432. * Accessor to the input by input index.
  6433. */
  6434. [idx: number]: ICameraInput<TCamera>;
  6435. }
  6436. /**
  6437. * This represents the input manager used within a camera.
  6438. * It helps dealing with all the different kind of input attached to a camera.
  6439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6440. */
  6441. export class CameraInputsManager<TCamera extends Camera> {
  6442. /**
  6443. * Defines the list of inputs attahed to the camera.
  6444. */
  6445. attached: CameraInputsMap<TCamera>;
  6446. /**
  6447. * Defines the dom element the camera is collecting inputs from.
  6448. * This is null if the controls have not been attached.
  6449. */
  6450. attachedElement: Nullable<HTMLElement>;
  6451. /**
  6452. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6453. */
  6454. noPreventDefault: boolean;
  6455. /**
  6456. * Defined the camera the input manager belongs to.
  6457. */
  6458. camera: TCamera;
  6459. /**
  6460. * Update the current camera state depending on the inputs that have been used this frame.
  6461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6462. */
  6463. checkInputs: () => void;
  6464. /**
  6465. * Instantiate a new Camera Input Manager.
  6466. * @param camera Defines the camera the input manager blongs to
  6467. */
  6468. constructor(camera: TCamera);
  6469. /**
  6470. * Add an input method to a camera
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. * @param input camera input method
  6473. */
  6474. add(input: ICameraInput<TCamera>): void;
  6475. /**
  6476. * Remove a specific input method from a camera
  6477. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6478. * @param inputToRemove camera input method
  6479. */
  6480. remove(inputToRemove: ICameraInput<TCamera>): void;
  6481. /**
  6482. * Remove a specific input type from a camera
  6483. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6484. * @param inputType the type of the input to remove
  6485. */
  6486. removeByType(inputType: string): void;
  6487. private _addCheckInputs;
  6488. /**
  6489. * Attach the input controls to the currently attached dom element to listen the events from.
  6490. * @param input Defines the input to attach
  6491. */
  6492. attachInput(input: ICameraInput<TCamera>): void;
  6493. /**
  6494. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6495. * @param element Defines the dom element to collect the events from
  6496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6499. /**
  6500. * Detach the current manager inputs controls from a specific dom element.
  6501. * @param element Defines the dom element to collect the events from
  6502. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6503. */
  6504. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6505. /**
  6506. * Rebuild the dynamic inputCheck function from the current list of
  6507. * defined inputs in the manager.
  6508. */
  6509. rebuildInputCheck(): void;
  6510. /**
  6511. * Remove all attached input methods from a camera
  6512. */
  6513. clear(): void;
  6514. /**
  6515. * Serialize the current input manager attached to a camera.
  6516. * This ensures than once parsed,
  6517. * the input associated to the camera will be identical to the current ones
  6518. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6519. */
  6520. serialize(serializedCamera: any): void;
  6521. /**
  6522. * Parses an input manager serialized JSON to restore the previous list of inputs
  6523. * and states associated to a camera.
  6524. * @param parsedCamera Defines the JSON to parse
  6525. */
  6526. parse(parsedCamera: any): void;
  6527. }
  6528. }
  6529. declare module BABYLON {
  6530. /**
  6531. * Class used to store data that will be store in GPU memory
  6532. */
  6533. export class Buffer {
  6534. private _engine;
  6535. private _buffer;
  6536. /** @hidden */
  6537. _data: Nullable<DataArray>;
  6538. private _updatable;
  6539. private _instanced;
  6540. private _divisor;
  6541. /**
  6542. * Gets the byte stride.
  6543. */
  6544. readonly byteStride: number;
  6545. /**
  6546. * Constructor
  6547. * @param engine the engine
  6548. * @param data the data to use for this buffer
  6549. * @param updatable whether the data is updatable
  6550. * @param stride the stride (optional)
  6551. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6552. * @param instanced whether the buffer is instanced (optional)
  6553. * @param useBytes set to true if the stride in in bytes (optional)
  6554. * @param divisor sets an optional divisor for instances (1 by default)
  6555. */
  6556. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6557. /**
  6558. * Create a new VertexBuffer based on the current buffer
  6559. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6560. * @param offset defines offset in the buffer (0 by default)
  6561. * @param size defines the size in floats of attributes (position is 3 for instance)
  6562. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6563. * @param instanced defines if the vertex buffer contains indexed data
  6564. * @param useBytes defines if the offset and stride are in bytes *
  6565. * @param divisor sets an optional divisor for instances (1 by default)
  6566. * @returns the new vertex buffer
  6567. */
  6568. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6569. /**
  6570. * Gets a boolean indicating if the Buffer is updatable?
  6571. * @returns true if the buffer is updatable
  6572. */
  6573. isUpdatable(): boolean;
  6574. /**
  6575. * Gets current buffer's data
  6576. * @returns a DataArray or null
  6577. */
  6578. getData(): Nullable<DataArray>;
  6579. /**
  6580. * Gets underlying native buffer
  6581. * @returns underlying native buffer
  6582. */
  6583. getBuffer(): Nullable<DataBuffer>;
  6584. /**
  6585. * Gets the stride in float32 units (i.e. byte stride / 4).
  6586. * May not be an integer if the byte stride is not divisible by 4.
  6587. * @returns the stride in float32 units
  6588. * @deprecated Please use byteStride instead.
  6589. */
  6590. getStrideSize(): number;
  6591. /**
  6592. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6593. * @param data defines the data to store
  6594. */
  6595. create(data?: Nullable<DataArray>): void;
  6596. /** @hidden */
  6597. _rebuild(): void;
  6598. /**
  6599. * Update current buffer data
  6600. * @param data defines the data to store
  6601. */
  6602. update(data: DataArray): void;
  6603. /**
  6604. * Updates the data directly.
  6605. * @param data the new data
  6606. * @param offset the new offset
  6607. * @param vertexCount the vertex count (optional)
  6608. * @param useBytes set to true if the offset is in bytes
  6609. */
  6610. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6611. /**
  6612. * Release all resources
  6613. */
  6614. dispose(): void;
  6615. }
  6616. /**
  6617. * Specialized buffer used to store vertex data
  6618. */
  6619. export class VertexBuffer {
  6620. /** @hidden */
  6621. _buffer: Buffer;
  6622. private _kind;
  6623. private _size;
  6624. private _ownsBuffer;
  6625. private _instanced;
  6626. private _instanceDivisor;
  6627. /**
  6628. * The byte type.
  6629. */
  6630. static readonly BYTE: number;
  6631. /**
  6632. * The unsigned byte type.
  6633. */
  6634. static readonly UNSIGNED_BYTE: number;
  6635. /**
  6636. * The short type.
  6637. */
  6638. static readonly SHORT: number;
  6639. /**
  6640. * The unsigned short type.
  6641. */
  6642. static readonly UNSIGNED_SHORT: number;
  6643. /**
  6644. * The integer type.
  6645. */
  6646. static readonly INT: number;
  6647. /**
  6648. * The unsigned integer type.
  6649. */
  6650. static readonly UNSIGNED_INT: number;
  6651. /**
  6652. * The float type.
  6653. */
  6654. static readonly FLOAT: number;
  6655. /**
  6656. * Gets or sets the instance divisor when in instanced mode
  6657. */
  6658. get instanceDivisor(): number;
  6659. set instanceDivisor(value: number);
  6660. /**
  6661. * Gets the byte stride.
  6662. */
  6663. readonly byteStride: number;
  6664. /**
  6665. * Gets the byte offset.
  6666. */
  6667. readonly byteOffset: number;
  6668. /**
  6669. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6670. */
  6671. readonly normalized: boolean;
  6672. /**
  6673. * Gets the data type of each component in the array.
  6674. */
  6675. readonly type: number;
  6676. /**
  6677. * Constructor
  6678. * @param engine the engine
  6679. * @param data the data to use for this vertex buffer
  6680. * @param kind the vertex buffer kind
  6681. * @param updatable whether the data is updatable
  6682. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6683. * @param stride the stride (optional)
  6684. * @param instanced whether the buffer is instanced (optional)
  6685. * @param offset the offset of the data (optional)
  6686. * @param size the number of components (optional)
  6687. * @param type the type of the component (optional)
  6688. * @param normalized whether the data contains normalized data (optional)
  6689. * @param useBytes set to true if stride and offset are in bytes (optional)
  6690. * @param divisor defines the instance divisor to use (1 by default)
  6691. */
  6692. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6693. /** @hidden */
  6694. _rebuild(): void;
  6695. /**
  6696. * Returns the kind of the VertexBuffer (string)
  6697. * @returns a string
  6698. */
  6699. getKind(): string;
  6700. /**
  6701. * Gets a boolean indicating if the VertexBuffer is updatable?
  6702. * @returns true if the buffer is updatable
  6703. */
  6704. isUpdatable(): boolean;
  6705. /**
  6706. * Gets current buffer's data
  6707. * @returns a DataArray or null
  6708. */
  6709. getData(): Nullable<DataArray>;
  6710. /**
  6711. * Gets underlying native buffer
  6712. * @returns underlying native buffer
  6713. */
  6714. getBuffer(): Nullable<DataBuffer>;
  6715. /**
  6716. * Gets the stride in float32 units (i.e. byte stride / 4).
  6717. * May not be an integer if the byte stride is not divisible by 4.
  6718. * @returns the stride in float32 units
  6719. * @deprecated Please use byteStride instead.
  6720. */
  6721. getStrideSize(): number;
  6722. /**
  6723. * Returns the offset as a multiple of the type byte length.
  6724. * @returns the offset in bytes
  6725. * @deprecated Please use byteOffset instead.
  6726. */
  6727. getOffset(): number;
  6728. /**
  6729. * Returns the number of components per vertex attribute (integer)
  6730. * @returns the size in float
  6731. */
  6732. getSize(): number;
  6733. /**
  6734. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6735. * @returns true if this buffer is instanced
  6736. */
  6737. getIsInstanced(): boolean;
  6738. /**
  6739. * Returns the instancing divisor, zero for non-instanced (integer).
  6740. * @returns a number
  6741. */
  6742. getInstanceDivisor(): number;
  6743. /**
  6744. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6745. * @param data defines the data to store
  6746. */
  6747. create(data?: DataArray): void;
  6748. /**
  6749. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6750. * This function will create a new buffer if the current one is not updatable
  6751. * @param data defines the data to store
  6752. */
  6753. update(data: DataArray): void;
  6754. /**
  6755. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6756. * Returns the directly updated WebGLBuffer.
  6757. * @param data the new data
  6758. * @param offset the new offset
  6759. * @param useBytes set to true if the offset is in bytes
  6760. */
  6761. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6762. /**
  6763. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6764. */
  6765. dispose(): void;
  6766. /**
  6767. * Enumerates each value of this vertex buffer as numbers.
  6768. * @param count the number of values to enumerate
  6769. * @param callback the callback function called for each value
  6770. */
  6771. forEach(count: number, callback: (value: number, index: number) => void): void;
  6772. /**
  6773. * Positions
  6774. */
  6775. static readonly PositionKind: string;
  6776. /**
  6777. * Normals
  6778. */
  6779. static readonly NormalKind: string;
  6780. /**
  6781. * Tangents
  6782. */
  6783. static readonly TangentKind: string;
  6784. /**
  6785. * Texture coordinates
  6786. */
  6787. static readonly UVKind: string;
  6788. /**
  6789. * Texture coordinates 2
  6790. */
  6791. static readonly UV2Kind: string;
  6792. /**
  6793. * Texture coordinates 3
  6794. */
  6795. static readonly UV3Kind: string;
  6796. /**
  6797. * Texture coordinates 4
  6798. */
  6799. static readonly UV4Kind: string;
  6800. /**
  6801. * Texture coordinates 5
  6802. */
  6803. static readonly UV5Kind: string;
  6804. /**
  6805. * Texture coordinates 6
  6806. */
  6807. static readonly UV6Kind: string;
  6808. /**
  6809. * Colors
  6810. */
  6811. static readonly ColorKind: string;
  6812. /**
  6813. * Matrix indices (for bones)
  6814. */
  6815. static readonly MatricesIndicesKind: string;
  6816. /**
  6817. * Matrix weights (for bones)
  6818. */
  6819. static readonly MatricesWeightsKind: string;
  6820. /**
  6821. * Additional matrix indices (for bones)
  6822. */
  6823. static readonly MatricesIndicesExtraKind: string;
  6824. /**
  6825. * Additional matrix weights (for bones)
  6826. */
  6827. static readonly MatricesWeightsExtraKind: string;
  6828. /**
  6829. * Deduces the stride given a kind.
  6830. * @param kind The kind string to deduce
  6831. * @returns The deduced stride
  6832. */
  6833. static DeduceStride(kind: string): number;
  6834. /**
  6835. * Gets the byte length of the given type.
  6836. * @param type the type
  6837. * @returns the number of bytes
  6838. */
  6839. static GetTypeByteLength(type: number): number;
  6840. /**
  6841. * Enumerates each value of the given parameters as numbers.
  6842. * @param data the data to enumerate
  6843. * @param byteOffset the byte offset of the data
  6844. * @param byteStride the byte stride of the data
  6845. * @param componentCount the number of components per element
  6846. * @param componentType the type of the component
  6847. * @param count the number of values to enumerate
  6848. * @param normalized whether the data is normalized
  6849. * @param callback the callback function called for each value
  6850. */
  6851. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6852. private static _GetFloatValue;
  6853. }
  6854. }
  6855. declare module BABYLON {
  6856. /**
  6857. * The options Interface for creating a Capsule Mesh
  6858. */
  6859. export interface ICreateCapsuleOptions {
  6860. /** The Orientation of the capsule. Default : Vector3.Up() */
  6861. orientation?: Vector3;
  6862. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6863. subdivisions: number;
  6864. /** Number of cylindrical segments on the capsule. */
  6865. tessellation: number;
  6866. /** Height or Length of the capsule. */
  6867. height: number;
  6868. /** Radius of the capsule. */
  6869. radius: number;
  6870. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6871. capSubdivisions: number;
  6872. /** Overwrite for the top radius. */
  6873. radiusTop?: number;
  6874. /** Overwrite for the bottom radius. */
  6875. radiusBottom?: number;
  6876. /** Overwrite for the top capSubdivisions. */
  6877. topCapSubdivisions?: number;
  6878. /** Overwrite for the bottom capSubdivisions. */
  6879. bottomCapSubdivisions?: number;
  6880. }
  6881. /**
  6882. * Class containing static functions to help procedurally build meshes
  6883. */
  6884. export class CapsuleBuilder {
  6885. /**
  6886. * Creates a capsule or a pill mesh
  6887. * @param name defines the name of the mesh
  6888. * @param options The constructors options.
  6889. * @param scene The scene the mesh is scoped to.
  6890. * @returns Capsule Mesh
  6891. */
  6892. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6893. }
  6894. }
  6895. declare module BABYLON {
  6896. /**
  6897. * @hidden
  6898. */
  6899. export class IntersectionInfo {
  6900. bu: Nullable<number>;
  6901. bv: Nullable<number>;
  6902. distance: number;
  6903. faceId: number;
  6904. subMeshId: number;
  6905. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding sphere information
  6911. */
  6912. export class BoundingSphere {
  6913. /**
  6914. * Gets the center of the bounding sphere in local space
  6915. */
  6916. readonly center: Vector3;
  6917. /**
  6918. * Radius of the bounding sphere in local space
  6919. */
  6920. radius: number;
  6921. /**
  6922. * Gets the center of the bounding sphere in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in world space
  6927. */
  6928. radiusWorld: number;
  6929. /**
  6930. * Gets the minimum vector in local space
  6931. */
  6932. readonly minimum: Vector3;
  6933. /**
  6934. * Gets the maximum vector in local space
  6935. */
  6936. readonly maximum: Vector3;
  6937. private _worldMatrix;
  6938. private static readonly TmpVector3;
  6939. /**
  6940. * Creates a new bounding sphere
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding sphere by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingSphere;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding sphere is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding sphere center is in between the frustum planes.
  6974. * Used for optimistic fast inclusion.
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if the sphere center is in between the frustum planes
  6977. */
  6978. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding sphere
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding sphere
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Checks if two sphere intersct
  6987. * @param sphere0 sphere 0
  6988. * @param sphere1 sphere 1
  6989. * @returns true if the speres intersect
  6990. */
  6991. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6992. }
  6993. }
  6994. declare module BABYLON {
  6995. /**
  6996. * Class used to store bounding box information
  6997. */
  6998. export class BoundingBox implements ICullable {
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in local space
  7001. */
  7002. readonly vectors: Vector3[];
  7003. /**
  7004. * Gets the center of the bounding box in local space
  7005. */
  7006. readonly center: Vector3;
  7007. /**
  7008. * Gets the center of the bounding box in world space
  7009. */
  7010. readonly centerWorld: Vector3;
  7011. /**
  7012. * Gets the extend size in local space
  7013. */
  7014. readonly extendSize: Vector3;
  7015. /**
  7016. * Gets the extend size in world space
  7017. */
  7018. readonly extendSizeWorld: Vector3;
  7019. /**
  7020. * Gets the OBB (object bounding box) directions
  7021. */
  7022. readonly directions: Vector3[];
  7023. /**
  7024. * Gets the 8 vectors representing the bounding box in world space
  7025. */
  7026. readonly vectorsWorld: Vector3[];
  7027. /**
  7028. * Gets the minimum vector in world space
  7029. */
  7030. readonly minimumWorld: Vector3;
  7031. /**
  7032. * Gets the maximum vector in world space
  7033. */
  7034. readonly maximumWorld: Vector3;
  7035. /**
  7036. * Gets the minimum vector in local space
  7037. */
  7038. readonly minimum: Vector3;
  7039. /**
  7040. * Gets the maximum vector in local space
  7041. */
  7042. readonly maximum: Vector3;
  7043. private _worldMatrix;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * @hidden
  7047. */
  7048. _tag: number;
  7049. /**
  7050. * Creates a new bounding box
  7051. * @param min defines the minimum vector (in local space)
  7052. * @param max defines the maximum vector (in local space)
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * Scale the current bounding box by applying a scale factor
  7065. * @param factor defines the scale factor to apply
  7066. * @returns the current bounding box
  7067. */
  7068. scale(factor: number): BoundingBox;
  7069. /**
  7070. * Gets the world matrix of the bounding box
  7071. * @returns a matrix
  7072. */
  7073. getWorldMatrix(): DeepImmutable<Matrix>;
  7074. /** @hidden */
  7075. _update(world: DeepImmutable<Matrix>): void;
  7076. /**
  7077. * Tests if the bounding box is intersecting the frustum planes
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @returns true if there is an intersection
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. /**
  7083. * Tests if the bounding box is entirely inside the frustum planes
  7084. * @param frustumPlanes defines the frustum planes to test
  7085. * @returns true if there is an inclusion
  7086. */
  7087. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7088. /**
  7089. * Tests if a point is inside the bounding box
  7090. * @param point defines the point to test
  7091. * @returns true if the point is inside the bounding box
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Tests if the bounding box intersects with a bounding sphere
  7096. * @param sphere defines the sphere to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7100. /**
  7101. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7102. * @param min defines the min vector to use
  7103. * @param max defines the max vector to use
  7104. * @returns true if there is an intersection
  7105. */
  7106. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7107. /**
  7108. * Tests if two bounding boxes are intersections
  7109. * @param box0 defines the first box to test
  7110. * @param box1 defines the second box to test
  7111. * @returns true if there is an intersection
  7112. */
  7113. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7114. /**
  7115. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7116. * @param minPoint defines the minimum vector of the bounding box
  7117. * @param maxPoint defines the maximum vector of the bounding box
  7118. * @param sphereCenter defines the sphere center
  7119. * @param sphereRadius defines the sphere radius
  7120. * @returns true if there is an intersection
  7121. */
  7122. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7123. /**
  7124. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7125. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @return true if there is an inclusion
  7128. */
  7129. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7132. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7133. * @param frustumPlanes defines the frustum planes to test
  7134. * @return true if there is an intersection
  7135. */
  7136. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. }
  7138. }
  7139. declare module BABYLON {
  7140. /** @hidden */
  7141. export class Collider {
  7142. /** Define if a collision was found */
  7143. collisionFound: boolean;
  7144. /**
  7145. * Define last intersection point in local space
  7146. */
  7147. intersectionPoint: Vector3;
  7148. /**
  7149. * Define last collided mesh
  7150. */
  7151. collidedMesh: Nullable<AbstractMesh>;
  7152. private _collisionPoint;
  7153. private _planeIntersectionPoint;
  7154. private _tempVector;
  7155. private _tempVector2;
  7156. private _tempVector3;
  7157. private _tempVector4;
  7158. private _edge;
  7159. private _baseToVertex;
  7160. private _destinationPoint;
  7161. private _slidePlaneNormal;
  7162. private _displacementVector;
  7163. /** @hidden */
  7164. _radius: Vector3;
  7165. /** @hidden */
  7166. _retry: number;
  7167. private _velocity;
  7168. private _basePoint;
  7169. private _epsilon;
  7170. /** @hidden */
  7171. _velocityWorldLength: number;
  7172. /** @hidden */
  7173. _basePointWorld: Vector3;
  7174. private _velocityWorld;
  7175. private _normalizedVelocity;
  7176. /** @hidden */
  7177. _initialVelocity: Vector3;
  7178. /** @hidden */
  7179. _initialPosition: Vector3;
  7180. private _nearestDistance;
  7181. private _collisionMask;
  7182. get collisionMask(): number;
  7183. set collisionMask(mask: number);
  7184. /**
  7185. * Gets the plane normal used to compute the sliding response (in local space)
  7186. */
  7187. get slidePlaneNormal(): Vector3;
  7188. /** @hidden */
  7189. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7190. /** @hidden */
  7191. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7192. /** @hidden */
  7193. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7194. /** @hidden */
  7195. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7196. /** @hidden */
  7197. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _getResponse(pos: Vector3, vel: Vector3): void;
  7200. }
  7201. }
  7202. declare module BABYLON {
  7203. /**
  7204. * Interface for cullable objects
  7205. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7206. */
  7207. export interface ICullable {
  7208. /**
  7209. * Checks if the object or part of the object is in the frustum
  7210. * @param frustumPlanes Camera near/planes
  7211. * @returns true if the object is in frustum otherwise false
  7212. */
  7213. isInFrustum(frustumPlanes: Plane[]): boolean;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7221. }
  7222. /**
  7223. * Info for a bounding data of a mesh
  7224. */
  7225. export class BoundingInfo implements ICullable {
  7226. /**
  7227. * Bounding box for the mesh
  7228. */
  7229. readonly boundingBox: BoundingBox;
  7230. /**
  7231. * Bounding sphere for the mesh
  7232. */
  7233. readonly boundingSphere: BoundingSphere;
  7234. private _isLocked;
  7235. private static readonly TmpVector3;
  7236. /**
  7237. * Constructs bounding info
  7238. * @param minimum min vector of the bounding box/sphere
  7239. * @param maximum max vector of the bounding box/sphere
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * min vector of the bounding box/sphere
  7252. */
  7253. get minimum(): Vector3;
  7254. /**
  7255. * max vector of the bounding box/sphere
  7256. */
  7257. get maximum(): Vector3;
  7258. /**
  7259. * If the info is locked and won't be updated to avoid perf overhead
  7260. */
  7261. get isLocked(): boolean;
  7262. set isLocked(value: boolean);
  7263. /**
  7264. * Updates the bounding sphere and box
  7265. * @param world world matrix to be used to update
  7266. */
  7267. update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7270. * @param center New center of the bounding info
  7271. * @param extend New extend of the bounding info
  7272. * @returns the current bounding info
  7273. */
  7274. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7275. /**
  7276. * Scale the current bounding info by applying a scale factor
  7277. * @param factor defines the scale factor to apply
  7278. * @returns the current bounding info
  7279. */
  7280. scale(factor: number): BoundingInfo;
  7281. /**
  7282. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7283. * @param frustumPlanes defines the frustum to test
  7284. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7285. * @returns true if the bounding info is in the frustum planes
  7286. */
  7287. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7288. /**
  7289. * Gets the world distance between the min and max points of the bounding box
  7290. */
  7291. get diagonalLength(): number;
  7292. /**
  7293. * Checks if a cullable object (mesh...) is in the camera frustum
  7294. * Unlike isInFrustum this cheks the full bounding box
  7295. * @param frustumPlanes Camera near/planes
  7296. * @returns true if the object is in frustum otherwise false
  7297. */
  7298. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7299. /** @hidden */
  7300. _checkCollision(collider: Collider): boolean;
  7301. /**
  7302. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7303. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7304. * @param point the point to check intersection with
  7305. * @returns if the point intersects
  7306. */
  7307. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7308. /**
  7309. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7311. * @param boundingInfo the bounding info to check intersection with
  7312. * @param precise if the intersection should be done using OBB
  7313. * @returns if the bounding info intersects
  7314. */
  7315. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7316. }
  7317. }
  7318. declare module BABYLON {
  7319. /**
  7320. * Extracts minimum and maximum values from a list of indexed positions
  7321. * @param positions defines the positions to use
  7322. * @param indices defines the indices to the positions
  7323. * @param indexStart defines the start index
  7324. * @param indexCount defines the end index
  7325. * @param bias defines bias value to add to the result
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. /**
  7333. * Extracts minimum and maximum values from a list of positions
  7334. * @param positions defines the positions to use
  7335. * @param start defines the start index in the positions array
  7336. * @param count defines the number of positions to handle
  7337. * @param bias defines bias value to add to the result
  7338. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7339. * @return minimum and maximum values
  7340. */
  7341. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7342. minimum: Vector3;
  7343. maximum: Vector3;
  7344. };
  7345. }
  7346. declare module BABYLON {
  7347. /** @hidden */
  7348. export class WebGLDataBuffer extends DataBuffer {
  7349. private _buffer;
  7350. constructor(resource: WebGLBuffer);
  7351. get underlyingResource(): any;
  7352. }
  7353. }
  7354. declare module BABYLON {
  7355. /** @hidden */
  7356. export class WebGLPipelineContext implements IPipelineContext {
  7357. engine: ThinEngine;
  7358. program: Nullable<WebGLProgram>;
  7359. context?: WebGLRenderingContext;
  7360. vertexShader?: WebGLShader;
  7361. fragmentShader?: WebGLShader;
  7362. isParallelCompiled: boolean;
  7363. onCompiled?: () => void;
  7364. transformFeedback?: WebGLTransformFeedback | null;
  7365. vertexCompilationError: Nullable<string>;
  7366. fragmentCompilationError: Nullable<string>;
  7367. programLinkError: Nullable<string>;
  7368. programValidationError: Nullable<string>;
  7369. get isAsync(): boolean;
  7370. get isReady(): boolean;
  7371. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7372. _getVertexShaderCode(): string | null;
  7373. _getFragmentShaderCode(): string | null;
  7374. }
  7375. }
  7376. declare module BABYLON {
  7377. interface ThinEngine {
  7378. /**
  7379. * Create an uniform buffer
  7380. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7381. * @param elements defines the content of the uniform buffer
  7382. * @returns the webGL uniform buffer
  7383. */
  7384. createUniformBuffer(elements: FloatArray): DataBuffer;
  7385. /**
  7386. * Create a dynamic uniform buffer
  7387. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7388. * @param elements defines the content of the uniform buffer
  7389. * @returns the webGL uniform buffer
  7390. */
  7391. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7392. /**
  7393. * Update an existing uniform buffer
  7394. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7395. * @param uniformBuffer defines the target uniform buffer
  7396. * @param elements defines the content to update
  7397. * @param offset defines the offset in the uniform buffer where update should start
  7398. * @param count defines the size of the data to update
  7399. */
  7400. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7401. /**
  7402. * Bind an uniform buffer to the current webGL context
  7403. * @param buffer defines the buffer to bind
  7404. */
  7405. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7406. /**
  7407. * Bind a buffer to the current webGL context at a given location
  7408. * @param buffer defines the buffer to bind
  7409. * @param location defines the index where to bind the buffer
  7410. */
  7411. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7412. /**
  7413. * Bind a specific block at a given index in a specific shader program
  7414. * @param pipelineContext defines the pipeline context to use
  7415. * @param blockName defines the block name
  7416. * @param index defines the index where to bind the block
  7417. */
  7418. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Uniform buffer objects.
  7424. *
  7425. * Handles blocks of uniform on the GPU.
  7426. *
  7427. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7428. *
  7429. * For more information, please refer to :
  7430. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7431. */
  7432. export class UniformBuffer {
  7433. private _engine;
  7434. private _buffer;
  7435. private _data;
  7436. private _bufferData;
  7437. private _dynamic?;
  7438. private _uniformLocations;
  7439. private _uniformSizes;
  7440. private _uniformLocationPointer;
  7441. private _needSync;
  7442. private _noUBO;
  7443. private _currentEffect;
  7444. /** @hidden */
  7445. _alreadyBound: boolean;
  7446. private static _MAX_UNIFORM_SIZE;
  7447. private static _tempBuffer;
  7448. /**
  7449. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7450. * This is dynamic to allow compat with webgl 1 and 2.
  7451. * You will need to pass the name of the uniform as well as the value.
  7452. */
  7453. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7454. /**
  7455. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7456. * This is dynamic to allow compat with webgl 1 and 2.
  7457. * You will need to pass the name of the uniform as well as the value.
  7458. */
  7459. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7460. /**
  7461. * Lambda to Update a single float in a uniform buffer.
  7462. * This is dynamic to allow compat with webgl 1 and 2.
  7463. * You will need to pass the name of the uniform as well as the value.
  7464. */
  7465. updateFloat: (name: string, x: number) => void;
  7466. /**
  7467. * Lambda to Update a vec2 of float in a uniform buffer.
  7468. * This is dynamic to allow compat with webgl 1 and 2.
  7469. * You will need to pass the name of the uniform as well as the value.
  7470. */
  7471. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7472. /**
  7473. * Lambda to Update a vec3 of float in a uniform buffer.
  7474. * This is dynamic to allow compat with webgl 1 and 2.
  7475. * You will need to pass the name of the uniform as well as the value.
  7476. */
  7477. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7478. /**
  7479. * Lambda to Update a vec4 of float in a uniform buffer.
  7480. * This is dynamic to allow compat with webgl 1 and 2.
  7481. * You will need to pass the name of the uniform as well as the value.
  7482. */
  7483. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7484. /**
  7485. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7486. * This is dynamic to allow compat with webgl 1 and 2.
  7487. * You will need to pass the name of the uniform as well as the value.
  7488. */
  7489. updateMatrix: (name: string, mat: Matrix) => void;
  7490. /**
  7491. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7492. * This is dynamic to allow compat with webgl 1 and 2.
  7493. * You will need to pass the name of the uniform as well as the value.
  7494. */
  7495. updateVector3: (name: string, vector: Vector3) => void;
  7496. /**
  7497. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7498. * This is dynamic to allow compat with webgl 1 and 2.
  7499. * You will need to pass the name of the uniform as well as the value.
  7500. */
  7501. updateVector4: (name: string, vector: Vector4) => void;
  7502. /**
  7503. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7504. * This is dynamic to allow compat with webgl 1 and 2.
  7505. * You will need to pass the name of the uniform as well as the value.
  7506. */
  7507. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7508. /**
  7509. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7510. * This is dynamic to allow compat with webgl 1 and 2.
  7511. * You will need to pass the name of the uniform as well as the value.
  7512. */
  7513. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7514. /**
  7515. * Instantiates a new Uniform buffer objects.
  7516. *
  7517. * Handles blocks of uniform on the GPU.
  7518. *
  7519. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7520. *
  7521. * For more information, please refer to :
  7522. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7523. * @param engine Define the engine the buffer is associated with
  7524. * @param data Define the data contained in the buffer
  7525. * @param dynamic Define if the buffer is updatable
  7526. */
  7527. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7528. /**
  7529. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7530. * or just falling back on setUniformXXX calls.
  7531. */
  7532. get useUbo(): boolean;
  7533. /**
  7534. * Indicates if the WebGL underlying uniform buffer is in sync
  7535. * with the javascript cache data.
  7536. */
  7537. get isSync(): boolean;
  7538. /**
  7539. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7540. * Also, a dynamic UniformBuffer will disable cache verification and always
  7541. * update the underlying WebGL uniform buffer to the GPU.
  7542. * @returns if Dynamic, otherwise false
  7543. */
  7544. isDynamic(): boolean;
  7545. /**
  7546. * The data cache on JS side.
  7547. * @returns the underlying data as a float array
  7548. */
  7549. getData(): Float32Array;
  7550. /**
  7551. * The underlying WebGL Uniform buffer.
  7552. * @returns the webgl buffer
  7553. */
  7554. getBuffer(): Nullable<DataBuffer>;
  7555. /**
  7556. * std140 layout specifies how to align data within an UBO structure.
  7557. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7558. * for specs.
  7559. */
  7560. private _fillAlignment;
  7561. /**
  7562. * Adds an uniform in the buffer.
  7563. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7564. * for the layout to be correct !
  7565. * @param name Name of the uniform, as used in the uniform block in the shader.
  7566. * @param size Data size, or data directly.
  7567. */
  7568. addUniform(name: string, size: number | number[]): void;
  7569. /**
  7570. * Adds a Matrix 4x4 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. * @param mat A 4x4 matrix.
  7573. */
  7574. addMatrix(name: string, mat: Matrix): void;
  7575. /**
  7576. * Adds a vec2 to the uniform buffer.
  7577. * @param name Name of the uniform, as used in the uniform block in the shader.
  7578. * @param x Define the x component value of the vec2
  7579. * @param y Define the y component value of the vec2
  7580. */
  7581. addFloat2(name: string, x: number, y: number): void;
  7582. /**
  7583. * Adds a vec3 to the uniform buffer.
  7584. * @param name Name of the uniform, as used in the uniform block in the shader.
  7585. * @param x Define the x component value of the vec3
  7586. * @param y Define the y component value of the vec3
  7587. * @param z Define the z component value of the vec3
  7588. */
  7589. addFloat3(name: string, x: number, y: number, z: number): void;
  7590. /**
  7591. * Adds a vec3 to the uniform buffer.
  7592. * @param name Name of the uniform, as used in the uniform block in the shader.
  7593. * @param color Define the vec3 from a Color
  7594. */
  7595. addColor3(name: string, color: Color3): void;
  7596. /**
  7597. * Adds a vec4 to the uniform buffer.
  7598. * @param name Name of the uniform, as used in the uniform block in the shader.
  7599. * @param color Define the rgb components from a Color
  7600. * @param alpha Define the a component of the vec4
  7601. */
  7602. addColor4(name: string, color: Color3, alpha: number): void;
  7603. /**
  7604. * Adds a vec3 to the uniform buffer.
  7605. * @param name Name of the uniform, as used in the uniform block in the shader.
  7606. * @param vector Define the vec3 components from a Vector
  7607. */
  7608. addVector3(name: string, vector: Vector3): void;
  7609. /**
  7610. * Adds a Matrix 3x3 to the uniform buffer.
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. */
  7613. addMatrix3x3(name: string): void;
  7614. /**
  7615. * Adds a Matrix 2x2 to the uniform buffer.
  7616. * @param name Name of the uniform, as used in the uniform block in the shader.
  7617. */
  7618. addMatrix2x2(name: string): void;
  7619. /**
  7620. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7621. */
  7622. create(): void;
  7623. /** @hidden */
  7624. _rebuild(): void;
  7625. /**
  7626. * Updates the WebGL Uniform Buffer on the GPU.
  7627. * If the `dynamic` flag is set to true, no cache comparison is done.
  7628. * Otherwise, the buffer will be updated only if the cache differs.
  7629. */
  7630. update(): void;
  7631. /**
  7632. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7633. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7634. * @param data Define the flattened data
  7635. * @param size Define the size of the data.
  7636. */
  7637. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7638. private _valueCache;
  7639. private _cacheMatrix;
  7640. private _updateMatrix3x3ForUniform;
  7641. private _updateMatrix3x3ForEffect;
  7642. private _updateMatrix2x2ForEffect;
  7643. private _updateMatrix2x2ForUniform;
  7644. private _updateFloatForEffect;
  7645. private _updateFloatForUniform;
  7646. private _updateFloat2ForEffect;
  7647. private _updateFloat2ForUniform;
  7648. private _updateFloat3ForEffect;
  7649. private _updateFloat3ForUniform;
  7650. private _updateFloat4ForEffect;
  7651. private _updateFloat4ForUniform;
  7652. private _updateMatrixForEffect;
  7653. private _updateMatrixForUniform;
  7654. private _updateVector3ForEffect;
  7655. private _updateVector3ForUniform;
  7656. private _updateVector4ForEffect;
  7657. private _updateVector4ForUniform;
  7658. private _updateColor3ForEffect;
  7659. private _updateColor3ForUniform;
  7660. private _updateColor4ForEffect;
  7661. private _updateColor4ForUniform;
  7662. /**
  7663. * Sets a sampler uniform on the effect.
  7664. * @param name Define the name of the sampler.
  7665. * @param texture Define the texture to set in the sampler
  7666. */
  7667. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7668. /**
  7669. * Directly updates the value of the uniform in the cache AND on the GPU.
  7670. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7671. * @param data Define the flattened data
  7672. */
  7673. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7674. /**
  7675. * Binds this uniform buffer to an effect.
  7676. * @param effect Define the effect to bind the buffer to
  7677. * @param name Name of the uniform block in the shader.
  7678. */
  7679. bindToEffect(effect: Effect, name: string): void;
  7680. /**
  7681. * Disposes the uniform buffer.
  7682. */
  7683. dispose(): void;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. /**
  7688. * Enum that determines the text-wrapping mode to use.
  7689. */
  7690. export enum InspectableType {
  7691. /**
  7692. * Checkbox for booleans
  7693. */
  7694. Checkbox = 0,
  7695. /**
  7696. * Sliders for numbers
  7697. */
  7698. Slider = 1,
  7699. /**
  7700. * Vector3
  7701. */
  7702. Vector3 = 2,
  7703. /**
  7704. * Quaternions
  7705. */
  7706. Quaternion = 3,
  7707. /**
  7708. * Color3
  7709. */
  7710. Color3 = 4,
  7711. /**
  7712. * String
  7713. */
  7714. String = 5
  7715. }
  7716. /**
  7717. * Interface used to define custom inspectable properties.
  7718. * This interface is used by the inspector to display custom property grids
  7719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7720. */
  7721. export interface IInspectable {
  7722. /**
  7723. * Gets the label to display
  7724. */
  7725. label: string;
  7726. /**
  7727. * Gets the name of the property to edit
  7728. */
  7729. propertyName: string;
  7730. /**
  7731. * Gets the type of the editor to use
  7732. */
  7733. type: InspectableType;
  7734. /**
  7735. * Gets the minimum value of the property when using in "slider" mode
  7736. */
  7737. min?: number;
  7738. /**
  7739. * Gets the maximum value of the property when using in "slider" mode
  7740. */
  7741. max?: number;
  7742. /**
  7743. * Gets the setp to use when using in "slider" mode
  7744. */
  7745. step?: number;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Class used to provide helper for timing
  7751. */
  7752. export class TimingTools {
  7753. /**
  7754. * Polyfill for setImmediate
  7755. * @param action defines the action to execute after the current execution block
  7756. */
  7757. static SetImmediate(action: () => void): void;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Class used to enable instatition of objects by class name
  7763. */
  7764. export class InstantiationTools {
  7765. /**
  7766. * Use this object to register external classes like custom textures or material
  7767. * to allow the laoders to instantiate them
  7768. */
  7769. static RegisteredExternalClasses: {
  7770. [key: string]: Object;
  7771. };
  7772. /**
  7773. * Tries to instantiate a new object from a given class name
  7774. * @param className defines the class name to instantiate
  7775. * @returns the new object or null if the system was not able to do the instantiation
  7776. */
  7777. static Instantiate(className: string): any;
  7778. }
  7779. }
  7780. declare module BABYLON {
  7781. /**
  7782. * Define options used to create a depth texture
  7783. */
  7784. export class DepthTextureCreationOptions {
  7785. /** Specifies whether or not a stencil should be allocated in the texture */
  7786. generateStencil?: boolean;
  7787. /** Specifies whether or not bilinear filtering is enable on the texture */
  7788. bilinearFiltering?: boolean;
  7789. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7790. comparisonFunction?: number;
  7791. /** Specifies if the created texture is a cube texture */
  7792. isCube?: boolean;
  7793. }
  7794. }
  7795. declare module BABYLON {
  7796. interface ThinEngine {
  7797. /**
  7798. * Creates a depth stencil cube texture.
  7799. * This is only available in WebGL 2.
  7800. * @param size The size of face edge in the cube texture.
  7801. * @param options The options defining the cube texture.
  7802. * @returns The cube texture
  7803. */
  7804. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7805. /**
  7806. * Creates a cube texture
  7807. * @param rootUrl defines the url where the files to load is located
  7808. * @param scene defines the current scene
  7809. * @param files defines the list of files to load (1 per face)
  7810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7811. * @param onLoad defines an optional callback raised when the texture is loaded
  7812. * @param onError defines an optional callback raised if there is an issue to load the texture
  7813. * @param format defines the format of the data
  7814. * @param forcedExtension defines the extension to use to pick the right loader
  7815. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7816. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7817. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7818. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7819. * @returns the cube texture as an InternalTexture
  7820. */
  7821. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7822. /**
  7823. * Creates a cube texture
  7824. * @param rootUrl defines the url where the files to load is located
  7825. * @param scene defines the current scene
  7826. * @param files defines the list of files to load (1 per face)
  7827. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7828. * @param onLoad defines an optional callback raised when the texture is loaded
  7829. * @param onError defines an optional callback raised if there is an issue to load the texture
  7830. * @param format defines the format of the data
  7831. * @param forcedExtension defines the extension to use to pick the right loader
  7832. * @returns the cube texture as an InternalTexture
  7833. */
  7834. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7835. /**
  7836. * Creates a cube texture
  7837. * @param rootUrl defines the url where the files to load is located
  7838. * @param scene defines the current scene
  7839. * @param files defines the list of files to load (1 per face)
  7840. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7841. * @param onLoad defines an optional callback raised when the texture is loaded
  7842. * @param onError defines an optional callback raised if there is an issue to load the texture
  7843. * @param format defines the format of the data
  7844. * @param forcedExtension defines the extension to use to pick the right loader
  7845. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7846. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7847. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7848. * @returns the cube texture as an InternalTexture
  7849. */
  7850. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7851. /** @hidden */
  7852. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7853. /** @hidden */
  7854. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7855. /** @hidden */
  7856. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7857. /** @hidden */
  7858. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7859. /**
  7860. * @hidden
  7861. */
  7862. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7863. }
  7864. }
  7865. declare module BABYLON {
  7866. /**
  7867. * Class for creating a cube texture
  7868. */
  7869. export class CubeTexture extends BaseTexture {
  7870. private _delayedOnLoad;
  7871. /**
  7872. * Observable triggered once the texture has been loaded.
  7873. */
  7874. onLoadObservable: Observable<CubeTexture>;
  7875. /**
  7876. * The url of the texture
  7877. */
  7878. url: string;
  7879. /**
  7880. * Gets or sets the center of the bounding box associated with the cube texture.
  7881. * It must define where the camera used to render the texture was set
  7882. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7883. */
  7884. boundingBoxPosition: Vector3;
  7885. private _boundingBoxSize;
  7886. /**
  7887. * Gets or sets the size of the bounding box associated with the cube texture
  7888. * When defined, the cubemap will switch to local mode
  7889. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7890. * @example https://www.babylonjs-playground.com/#RNASML
  7891. */
  7892. set boundingBoxSize(value: Vector3);
  7893. /**
  7894. * Returns the bounding box size
  7895. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7896. */
  7897. get boundingBoxSize(): Vector3;
  7898. protected _rotationY: number;
  7899. /**
  7900. * Sets texture matrix rotation angle around Y axis in radians.
  7901. */
  7902. set rotationY(value: number);
  7903. /**
  7904. * Gets texture matrix rotation angle around Y axis radians.
  7905. */
  7906. get rotationY(): number;
  7907. /**
  7908. * Are mip maps generated for this texture or not.
  7909. */
  7910. get noMipmap(): boolean;
  7911. private _noMipmap;
  7912. private _files;
  7913. protected _forcedExtension: Nullable<string>;
  7914. private _extensions;
  7915. private _textureMatrix;
  7916. private _format;
  7917. private _createPolynomials;
  7918. /**
  7919. * Creates a cube texture from an array of image urls
  7920. * @param files defines an array of image urls
  7921. * @param scene defines the hosting scene
  7922. * @param noMipmap specifies if mip maps are not used
  7923. * @returns a cube texture
  7924. */
  7925. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7926. /**
  7927. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7928. * @param url defines the url of the prefiltered texture
  7929. * @param scene defines the scene the texture is attached to
  7930. * @param forcedExtension defines the extension of the file if different from the url
  7931. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7932. * @return the prefiltered texture
  7933. */
  7934. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7935. /**
  7936. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7937. * as prefiltered data.
  7938. * @param rootUrl defines the url of the texture or the root name of the six images
  7939. * @param null defines the scene or engine the texture is attached to
  7940. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7941. * @param noMipmap defines if mipmaps should be created or not
  7942. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7943. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7944. * @param onError defines a callback triggered in case of error during load
  7945. * @param format defines the internal format to use for the texture once loaded
  7946. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7947. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7950. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7951. * @return the cube texture
  7952. */
  7953. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7954. /**
  7955. * Get the current class name of the texture useful for serialization or dynamic coding.
  7956. * @returns "CubeTexture"
  7957. */
  7958. getClassName(): string;
  7959. /**
  7960. * Update the url (and optional buffer) of this texture if url was null during construction.
  7961. * @param url the url of the texture
  7962. * @param forcedExtension defines the extension to use
  7963. * @param onLoad callback called when the texture is loaded (defaults to null)
  7964. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7965. */
  7966. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7967. /**
  7968. * Delays loading of the cube texture
  7969. * @param forcedExtension defines the extension to use
  7970. */
  7971. delayLoad(forcedExtension?: string): void;
  7972. /**
  7973. * Returns the reflection texture matrix
  7974. * @returns the reflection texture matrix
  7975. */
  7976. getReflectionTextureMatrix(): Matrix;
  7977. /**
  7978. * Sets the reflection texture matrix
  7979. * @param value Reflection texture matrix
  7980. */
  7981. setReflectionTextureMatrix(value: Matrix): void;
  7982. /**
  7983. * Parses text to create a cube texture
  7984. * @param parsedTexture define the serialized text to read from
  7985. * @param scene defines the hosting scene
  7986. * @param rootUrl defines the root url of the cube texture
  7987. * @returns a cube texture
  7988. */
  7989. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7990. /**
  7991. * Makes a clone, or deep copy, of the cube texture
  7992. * @returns a new cube texture
  7993. */
  7994. clone(): CubeTexture;
  7995. }
  7996. }
  7997. declare module BABYLON {
  7998. /**
  7999. * Manages the defines for the Material
  8000. */
  8001. export class MaterialDefines {
  8002. /** @hidden */
  8003. protected _keys: string[];
  8004. private _isDirty;
  8005. /** @hidden */
  8006. _renderId: number;
  8007. /** @hidden */
  8008. _areLightsDirty: boolean;
  8009. /** @hidden */
  8010. _areLightsDisposed: boolean;
  8011. /** @hidden */
  8012. _areAttributesDirty: boolean;
  8013. /** @hidden */
  8014. _areTexturesDirty: boolean;
  8015. /** @hidden */
  8016. _areFresnelDirty: boolean;
  8017. /** @hidden */
  8018. _areMiscDirty: boolean;
  8019. /** @hidden */
  8020. _arePrePassDirty: boolean;
  8021. /** @hidden */
  8022. _areImageProcessingDirty: boolean;
  8023. /** @hidden */
  8024. _normals: boolean;
  8025. /** @hidden */
  8026. _uvs: boolean;
  8027. /** @hidden */
  8028. _needNormals: boolean;
  8029. /** @hidden */
  8030. _needUVs: boolean;
  8031. [id: string]: any;
  8032. /**
  8033. * Specifies if the material needs to be re-calculated
  8034. */
  8035. get isDirty(): boolean;
  8036. /**
  8037. * Marks the material to indicate that it has been re-calculated
  8038. */
  8039. markAsProcessed(): void;
  8040. /**
  8041. * Marks the material to indicate that it needs to be re-calculated
  8042. */
  8043. markAsUnprocessed(): void;
  8044. /**
  8045. * Marks the material to indicate all of its defines need to be re-calculated
  8046. */
  8047. markAllAsDirty(): void;
  8048. /**
  8049. * Marks the material to indicate that image processing needs to be re-calculated
  8050. */
  8051. markAsImageProcessingDirty(): void;
  8052. /**
  8053. * Marks the material to indicate the lights need to be re-calculated
  8054. * @param disposed Defines whether the light is dirty due to dispose or not
  8055. */
  8056. markAsLightDirty(disposed?: boolean): void;
  8057. /**
  8058. * Marks the attribute state as changed
  8059. */
  8060. markAsAttributesDirty(): void;
  8061. /**
  8062. * Marks the texture state as changed
  8063. */
  8064. markAsTexturesDirty(): void;
  8065. /**
  8066. * Marks the fresnel state as changed
  8067. */
  8068. markAsFresnelDirty(): void;
  8069. /**
  8070. * Marks the misc state as changed
  8071. */
  8072. markAsMiscDirty(): void;
  8073. /**
  8074. * Marks the prepass state as changed
  8075. */
  8076. markAsPrePassDirty(): void;
  8077. /**
  8078. * Rebuilds the material defines
  8079. */
  8080. rebuild(): void;
  8081. /**
  8082. * Specifies if two material defines are equal
  8083. * @param other - A material define instance to compare to
  8084. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8085. */
  8086. isEqual(other: MaterialDefines): boolean;
  8087. /**
  8088. * Clones this instance's defines to another instance
  8089. * @param other - material defines to clone values to
  8090. */
  8091. cloneTo(other: MaterialDefines): void;
  8092. /**
  8093. * Resets the material define values
  8094. */
  8095. reset(): void;
  8096. /**
  8097. * Converts the material define values to a string
  8098. * @returns - String of material define information
  8099. */
  8100. toString(): string;
  8101. }
  8102. }
  8103. declare module BABYLON {
  8104. /**
  8105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8107. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8109. */
  8110. export class ColorCurves {
  8111. private _dirty;
  8112. private _tempColor;
  8113. private _globalCurve;
  8114. private _highlightsCurve;
  8115. private _midtonesCurve;
  8116. private _shadowsCurve;
  8117. private _positiveCurve;
  8118. private _negativeCurve;
  8119. private _globalHue;
  8120. private _globalDensity;
  8121. private _globalSaturation;
  8122. private _globalExposure;
  8123. /**
  8124. * Gets the global Hue value.
  8125. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8126. */
  8127. get globalHue(): number;
  8128. /**
  8129. * Sets the global Hue value.
  8130. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8131. */
  8132. set globalHue(value: number);
  8133. /**
  8134. * Gets the global Density value.
  8135. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8136. * Values less than zero provide a filter of opposite hue.
  8137. */
  8138. get globalDensity(): number;
  8139. /**
  8140. * Sets the global Density value.
  8141. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8142. * Values less than zero provide a filter of opposite hue.
  8143. */
  8144. set globalDensity(value: number);
  8145. /**
  8146. * Gets the global Saturation value.
  8147. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8148. */
  8149. get globalSaturation(): number;
  8150. /**
  8151. * Sets the global Saturation value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8153. */
  8154. set globalSaturation(value: number);
  8155. /**
  8156. * Gets the global Exposure value.
  8157. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8158. */
  8159. get globalExposure(): number;
  8160. /**
  8161. * Sets the global Exposure value.
  8162. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8163. */
  8164. set globalExposure(value: number);
  8165. private _highlightsHue;
  8166. private _highlightsDensity;
  8167. private _highlightsSaturation;
  8168. private _highlightsExposure;
  8169. /**
  8170. * Gets the highlights Hue value.
  8171. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8172. */
  8173. get highlightsHue(): number;
  8174. /**
  8175. * Sets the highlights Hue value.
  8176. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8177. */
  8178. set highlightsHue(value: number);
  8179. /**
  8180. * Gets the highlights Density value.
  8181. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8182. * Values less than zero provide a filter of opposite hue.
  8183. */
  8184. get highlightsDensity(): number;
  8185. /**
  8186. * Sets the highlights Density value.
  8187. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8188. * Values less than zero provide a filter of opposite hue.
  8189. */
  8190. set highlightsDensity(value: number);
  8191. /**
  8192. * Gets the highlights Saturation value.
  8193. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8194. */
  8195. get highlightsSaturation(): number;
  8196. /**
  8197. * Sets the highlights Saturation value.
  8198. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8199. */
  8200. set highlightsSaturation(value: number);
  8201. /**
  8202. * Gets the highlights Exposure value.
  8203. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8204. */
  8205. get highlightsExposure(): number;
  8206. /**
  8207. * Sets the highlights Exposure value.
  8208. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8209. */
  8210. set highlightsExposure(value: number);
  8211. private _midtonesHue;
  8212. private _midtonesDensity;
  8213. private _midtonesSaturation;
  8214. private _midtonesExposure;
  8215. /**
  8216. * Gets the midtones Hue value.
  8217. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8218. */
  8219. get midtonesHue(): number;
  8220. /**
  8221. * Sets the midtones Hue value.
  8222. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8223. */
  8224. set midtonesHue(value: number);
  8225. /**
  8226. * Gets the midtones Density value.
  8227. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8228. * Values less than zero provide a filter of opposite hue.
  8229. */
  8230. get midtonesDensity(): number;
  8231. /**
  8232. * Sets the midtones Density value.
  8233. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8234. * Values less than zero provide a filter of opposite hue.
  8235. */
  8236. set midtonesDensity(value: number);
  8237. /**
  8238. * Gets the midtones Saturation value.
  8239. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8240. */
  8241. get midtonesSaturation(): number;
  8242. /**
  8243. * Sets the midtones Saturation value.
  8244. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8245. */
  8246. set midtonesSaturation(value: number);
  8247. /**
  8248. * Gets the midtones Exposure value.
  8249. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8250. */
  8251. get midtonesExposure(): number;
  8252. /**
  8253. * Sets the midtones Exposure value.
  8254. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8255. */
  8256. set midtonesExposure(value: number);
  8257. private _shadowsHue;
  8258. private _shadowsDensity;
  8259. private _shadowsSaturation;
  8260. private _shadowsExposure;
  8261. /**
  8262. * Gets the shadows Hue value.
  8263. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8264. */
  8265. get shadowsHue(): number;
  8266. /**
  8267. * Sets the shadows Hue value.
  8268. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8269. */
  8270. set shadowsHue(value: number);
  8271. /**
  8272. * Gets the shadows Density value.
  8273. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8274. * Values less than zero provide a filter of opposite hue.
  8275. */
  8276. get shadowsDensity(): number;
  8277. /**
  8278. * Sets the shadows Density value.
  8279. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8280. * Values less than zero provide a filter of opposite hue.
  8281. */
  8282. set shadowsDensity(value: number);
  8283. /**
  8284. * Gets the shadows Saturation value.
  8285. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8286. */
  8287. get shadowsSaturation(): number;
  8288. /**
  8289. * Sets the shadows Saturation value.
  8290. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8291. */
  8292. set shadowsSaturation(value: number);
  8293. /**
  8294. * Gets the shadows Exposure value.
  8295. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8296. */
  8297. get shadowsExposure(): number;
  8298. /**
  8299. * Sets the shadows Exposure value.
  8300. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8301. */
  8302. set shadowsExposure(value: number);
  8303. /**
  8304. * Returns the class name
  8305. * @returns The class name
  8306. */
  8307. getClassName(): string;
  8308. /**
  8309. * Binds the color curves to the shader.
  8310. * @param colorCurves The color curve to bind
  8311. * @param effect The effect to bind to
  8312. * @param positiveUniform The positive uniform shader parameter
  8313. * @param neutralUniform The neutral uniform shader parameter
  8314. * @param negativeUniform The negative uniform shader parameter
  8315. */
  8316. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8317. /**
  8318. * Prepare the list of uniforms associated with the ColorCurves effects.
  8319. * @param uniformsList The list of uniforms used in the effect
  8320. */
  8321. static PrepareUniforms(uniformsList: string[]): void;
  8322. /**
  8323. * Returns color grading data based on a hue, density, saturation and exposure value.
  8324. * @param filterHue The hue of the color filter.
  8325. * @param filterDensity The density of the color filter.
  8326. * @param saturation The saturation.
  8327. * @param exposure The exposure.
  8328. * @param result The result data container.
  8329. */
  8330. private getColorGradingDataToRef;
  8331. /**
  8332. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8333. * @param value The input slider value in range [-100,100].
  8334. * @returns Adjusted value.
  8335. */
  8336. private static applyColorGradingSliderNonlinear;
  8337. /**
  8338. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8339. * @param hue The hue (H) input.
  8340. * @param saturation The saturation (S) input.
  8341. * @param brightness The brightness (B) input.
  8342. * @result An RGBA color represented as Vector4.
  8343. */
  8344. private static fromHSBToRef;
  8345. /**
  8346. * Returns a value clamped between min and max
  8347. * @param value The value to clamp
  8348. * @param min The minimum of value
  8349. * @param max The maximum of value
  8350. * @returns The clamped value.
  8351. */
  8352. private static clamp;
  8353. /**
  8354. * Clones the current color curve instance.
  8355. * @return The cloned curves
  8356. */
  8357. clone(): ColorCurves;
  8358. /**
  8359. * Serializes the current color curve instance to a json representation.
  8360. * @return a JSON representation
  8361. */
  8362. serialize(): any;
  8363. /**
  8364. * Parses the color curve from a json representation.
  8365. * @param source the JSON source to parse
  8366. * @return The parsed curves
  8367. */
  8368. static Parse(source: any): ColorCurves;
  8369. }
  8370. }
  8371. declare module BABYLON {
  8372. /**
  8373. * Interface to follow in your material defines to integrate easily the
  8374. * Image proccessing functions.
  8375. * @hidden
  8376. */
  8377. export interface IImageProcessingConfigurationDefines {
  8378. IMAGEPROCESSING: boolean;
  8379. VIGNETTE: boolean;
  8380. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8381. VIGNETTEBLENDMODEOPAQUE: boolean;
  8382. TONEMAPPING: boolean;
  8383. TONEMAPPING_ACES: boolean;
  8384. CONTRAST: boolean;
  8385. EXPOSURE: boolean;
  8386. COLORCURVES: boolean;
  8387. COLORGRADING: boolean;
  8388. COLORGRADING3D: boolean;
  8389. SAMPLER3DGREENDEPTH: boolean;
  8390. SAMPLER3DBGRMAP: boolean;
  8391. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8392. }
  8393. /**
  8394. * @hidden
  8395. */
  8396. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. COLORCURVES: boolean;
  8405. COLORGRADING: boolean;
  8406. COLORGRADING3D: boolean;
  8407. SAMPLER3DGREENDEPTH: boolean;
  8408. SAMPLER3DBGRMAP: boolean;
  8409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8410. EXPOSURE: boolean;
  8411. constructor();
  8412. }
  8413. /**
  8414. * This groups together the common properties used for image processing either in direct forward pass
  8415. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8416. * or not.
  8417. */
  8418. export class ImageProcessingConfiguration {
  8419. /**
  8420. * Default tone mapping applied in BabylonJS.
  8421. */
  8422. static readonly TONEMAPPING_STANDARD: number;
  8423. /**
  8424. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8425. * to other engines rendering to increase portability.
  8426. */
  8427. static readonly TONEMAPPING_ACES: number;
  8428. /**
  8429. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8430. */
  8431. colorCurves: Nullable<ColorCurves>;
  8432. private _colorCurvesEnabled;
  8433. /**
  8434. * Gets wether the color curves effect is enabled.
  8435. */
  8436. get colorCurvesEnabled(): boolean;
  8437. /**
  8438. * Sets wether the color curves effect is enabled.
  8439. */
  8440. set colorCurvesEnabled(value: boolean);
  8441. private _colorGradingTexture;
  8442. /**
  8443. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8444. */
  8445. get colorGradingTexture(): Nullable<BaseTexture>;
  8446. /**
  8447. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8448. */
  8449. set colorGradingTexture(value: Nullable<BaseTexture>);
  8450. private _colorGradingEnabled;
  8451. /**
  8452. * Gets wether the color grading effect is enabled.
  8453. */
  8454. get colorGradingEnabled(): boolean;
  8455. /**
  8456. * Sets wether the color grading effect is enabled.
  8457. */
  8458. set colorGradingEnabled(value: boolean);
  8459. private _colorGradingWithGreenDepth;
  8460. /**
  8461. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8462. */
  8463. get colorGradingWithGreenDepth(): boolean;
  8464. /**
  8465. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8466. */
  8467. set colorGradingWithGreenDepth(value: boolean);
  8468. private _colorGradingBGR;
  8469. /**
  8470. * Gets wether the color grading texture contains BGR values.
  8471. */
  8472. get colorGradingBGR(): boolean;
  8473. /**
  8474. * Sets wether the color grading texture contains BGR values.
  8475. */
  8476. set colorGradingBGR(value: boolean);
  8477. /** @hidden */
  8478. _exposure: number;
  8479. /**
  8480. * Gets the Exposure used in the effect.
  8481. */
  8482. get exposure(): number;
  8483. /**
  8484. * Sets the Exposure used in the effect.
  8485. */
  8486. set exposure(value: number);
  8487. private _toneMappingEnabled;
  8488. /**
  8489. * Gets wether the tone mapping effect is enabled.
  8490. */
  8491. get toneMappingEnabled(): boolean;
  8492. /**
  8493. * Sets wether the tone mapping effect is enabled.
  8494. */
  8495. set toneMappingEnabled(value: boolean);
  8496. private _toneMappingType;
  8497. /**
  8498. * Gets the type of tone mapping effect.
  8499. */
  8500. get toneMappingType(): number;
  8501. /**
  8502. * Sets the type of tone mapping effect used in BabylonJS.
  8503. */
  8504. set toneMappingType(value: number);
  8505. protected _contrast: number;
  8506. /**
  8507. * Gets the contrast used in the effect.
  8508. */
  8509. get contrast(): number;
  8510. /**
  8511. * Sets the contrast used in the effect.
  8512. */
  8513. set contrast(value: number);
  8514. /**
  8515. * Vignette stretch size.
  8516. */
  8517. vignetteStretch: number;
  8518. /**
  8519. * Vignette centre X Offset.
  8520. */
  8521. vignetteCentreX: number;
  8522. /**
  8523. * Vignette centre Y Offset.
  8524. */
  8525. vignetteCentreY: number;
  8526. /**
  8527. * Vignette weight or intensity of the vignette effect.
  8528. */
  8529. vignetteWeight: number;
  8530. /**
  8531. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8532. * if vignetteEnabled is set to true.
  8533. */
  8534. vignetteColor: Color4;
  8535. /**
  8536. * Camera field of view used by the Vignette effect.
  8537. */
  8538. vignetteCameraFov: number;
  8539. private _vignetteBlendMode;
  8540. /**
  8541. * Gets the vignette blend mode allowing different kind of effect.
  8542. */
  8543. get vignetteBlendMode(): number;
  8544. /**
  8545. * Sets the vignette blend mode allowing different kind of effect.
  8546. */
  8547. set vignetteBlendMode(value: number);
  8548. private _vignetteEnabled;
  8549. /**
  8550. * Gets wether the vignette effect is enabled.
  8551. */
  8552. get vignetteEnabled(): boolean;
  8553. /**
  8554. * Sets wether the vignette effect is enabled.
  8555. */
  8556. set vignetteEnabled(value: boolean);
  8557. private _applyByPostProcess;
  8558. /**
  8559. * Gets wether the image processing is applied through a post process or not.
  8560. */
  8561. get applyByPostProcess(): boolean;
  8562. /**
  8563. * Sets wether the image processing is applied through a post process or not.
  8564. */
  8565. set applyByPostProcess(value: boolean);
  8566. private _isEnabled;
  8567. /**
  8568. * Gets wether the image processing is enabled or not.
  8569. */
  8570. get isEnabled(): boolean;
  8571. /**
  8572. * Sets wether the image processing is enabled or not.
  8573. */
  8574. set isEnabled(value: boolean);
  8575. /**
  8576. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8577. */
  8578. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8579. /**
  8580. * Method called each time the image processing information changes requires to recompile the effect.
  8581. */
  8582. protected _updateParameters(): void;
  8583. /**
  8584. * Gets the current class name.
  8585. * @return "ImageProcessingConfiguration"
  8586. */
  8587. getClassName(): string;
  8588. /**
  8589. * Prepare the list of uniforms associated with the Image Processing effects.
  8590. * @param uniforms The list of uniforms used in the effect
  8591. * @param defines the list of defines currently in use
  8592. */
  8593. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8594. /**
  8595. * Prepare the list of samplers associated with the Image Processing effects.
  8596. * @param samplersList The list of uniforms used in the effect
  8597. * @param defines the list of defines currently in use
  8598. */
  8599. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8600. /**
  8601. * Prepare the list of defines associated to the shader.
  8602. * @param defines the list of defines to complete
  8603. * @param forPostProcess Define if we are currently in post process mode or not
  8604. */
  8605. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8606. /**
  8607. * Returns true if all the image processing information are ready.
  8608. * @returns True if ready, otherwise, false
  8609. */
  8610. isReady(): boolean;
  8611. /**
  8612. * Binds the image processing to the shader.
  8613. * @param effect The effect to bind to
  8614. * @param overrideAspectRatio Override the aspect ratio of the effect
  8615. */
  8616. bind(effect: Effect, overrideAspectRatio?: number): void;
  8617. /**
  8618. * Clones the current image processing instance.
  8619. * @return The cloned image processing
  8620. */
  8621. clone(): ImageProcessingConfiguration;
  8622. /**
  8623. * Serializes the current image processing instance to a json representation.
  8624. * @return a JSON representation
  8625. */
  8626. serialize(): any;
  8627. /**
  8628. * Parses the image processing from a json representation.
  8629. * @param source the JSON source to parse
  8630. * @return The parsed image processing
  8631. */
  8632. static Parse(source: any): ImageProcessingConfiguration;
  8633. private static _VIGNETTEMODE_MULTIPLY;
  8634. private static _VIGNETTEMODE_OPAQUE;
  8635. /**
  8636. * Used to apply the vignette as a mix with the pixel color.
  8637. */
  8638. static get VIGNETTEMODE_MULTIPLY(): number;
  8639. /**
  8640. * Used to apply the vignette as a replacement of the pixel color.
  8641. */
  8642. static get VIGNETTEMODE_OPAQUE(): number;
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /** @hidden */
  8647. export var postprocessVertexShader: {
  8648. name: string;
  8649. shader: string;
  8650. };
  8651. }
  8652. declare module BABYLON {
  8653. /**
  8654. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8655. */
  8656. export type RenderTargetTextureSize = number | {
  8657. width: number;
  8658. height: number;
  8659. layers?: number;
  8660. };
  8661. interface ThinEngine {
  8662. /**
  8663. * Creates a new render target texture
  8664. * @param size defines the size of the texture
  8665. * @param options defines the options used to create the texture
  8666. * @returns a new render target texture stored in an InternalTexture
  8667. */
  8668. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8669. /**
  8670. * Creates a depth stencil texture.
  8671. * This is only available in WebGL 2 or with the depth texture extension available.
  8672. * @param size The size of face edge in the texture.
  8673. * @param options The options defining the texture.
  8674. * @returns The texture
  8675. */
  8676. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8677. /** @hidden */
  8678. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8679. }
  8680. }
  8681. declare module BABYLON {
  8682. /**
  8683. * Defines the kind of connection point for node based material
  8684. */
  8685. export enum NodeMaterialBlockConnectionPointTypes {
  8686. /** Float */
  8687. Float = 1,
  8688. /** Int */
  8689. Int = 2,
  8690. /** Vector2 */
  8691. Vector2 = 4,
  8692. /** Vector3 */
  8693. Vector3 = 8,
  8694. /** Vector4 */
  8695. Vector4 = 16,
  8696. /** Color3 */
  8697. Color3 = 32,
  8698. /** Color4 */
  8699. Color4 = 64,
  8700. /** Matrix */
  8701. Matrix = 128,
  8702. /** Custom object */
  8703. Object = 256,
  8704. /** Detect type based on connection */
  8705. AutoDetect = 1024,
  8706. /** Output type that will be defined by input type */
  8707. BasedOnInput = 2048
  8708. }
  8709. }
  8710. declare module BABYLON {
  8711. /**
  8712. * Enum used to define the target of a block
  8713. */
  8714. export enum NodeMaterialBlockTargets {
  8715. /** Vertex shader */
  8716. Vertex = 1,
  8717. /** Fragment shader */
  8718. Fragment = 2,
  8719. /** Neutral */
  8720. Neutral = 4,
  8721. /** Vertex and Fragment */
  8722. VertexAndFragment = 3
  8723. }
  8724. }
  8725. declare module BABYLON {
  8726. /**
  8727. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8728. */
  8729. export enum NodeMaterialBlockConnectionPointMode {
  8730. /** Value is an uniform */
  8731. Uniform = 0,
  8732. /** Value is a mesh attribute */
  8733. Attribute = 1,
  8734. /** Value is a varying between vertex and fragment shaders */
  8735. Varying = 2,
  8736. /** Mode is undefined */
  8737. Undefined = 3
  8738. }
  8739. }
  8740. declare module BABYLON {
  8741. /**
  8742. * Enum used to define system values e.g. values automatically provided by the system
  8743. */
  8744. export enum NodeMaterialSystemValues {
  8745. /** World */
  8746. World = 1,
  8747. /** View */
  8748. View = 2,
  8749. /** Projection */
  8750. Projection = 3,
  8751. /** ViewProjection */
  8752. ViewProjection = 4,
  8753. /** WorldView */
  8754. WorldView = 5,
  8755. /** WorldViewProjection */
  8756. WorldViewProjection = 6,
  8757. /** CameraPosition */
  8758. CameraPosition = 7,
  8759. /** Fog Color */
  8760. FogColor = 8,
  8761. /** Delta time */
  8762. DeltaTime = 9
  8763. }
  8764. }
  8765. declare module BABYLON {
  8766. /** Defines supported spaces */
  8767. export enum Space {
  8768. /** Local (object) space */
  8769. LOCAL = 0,
  8770. /** World space */
  8771. WORLD = 1,
  8772. /** Bone space */
  8773. BONE = 2
  8774. }
  8775. /** Defines the 3 main axes */
  8776. export class Axis {
  8777. /** X axis */
  8778. static X: Vector3;
  8779. /** Y axis */
  8780. static Y: Vector3;
  8781. /** Z axis */
  8782. static Z: Vector3;
  8783. }
  8784. }
  8785. declare module BABYLON {
  8786. /**
  8787. * Represents a camera frustum
  8788. */
  8789. export class Frustum {
  8790. /**
  8791. * Gets the planes representing the frustum
  8792. * @param transform matrix to be applied to the returned planes
  8793. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8794. */
  8795. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8796. /**
  8797. * Gets the near frustum plane transformed by the transform matrix
  8798. * @param transform transformation matrix to be applied to the resulting frustum plane
  8799. * @param frustumPlane the resuling frustum plane
  8800. */
  8801. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8802. /**
  8803. * Gets the far frustum plane transformed by the transform matrix
  8804. * @param transform transformation matrix to be applied to the resulting frustum plane
  8805. * @param frustumPlane the resuling frustum plane
  8806. */
  8807. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8808. /**
  8809. * Gets the left frustum plane transformed by the transform matrix
  8810. * @param transform transformation matrix to be applied to the resulting frustum plane
  8811. * @param frustumPlane the resuling frustum plane
  8812. */
  8813. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8814. /**
  8815. * Gets the right frustum plane transformed by the transform matrix
  8816. * @param transform transformation matrix to be applied to the resulting frustum plane
  8817. * @param frustumPlane the resuling frustum plane
  8818. */
  8819. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8820. /**
  8821. * Gets the top frustum plane transformed by the transform matrix
  8822. * @param transform transformation matrix to be applied to the resulting frustum plane
  8823. * @param frustumPlane the resuling frustum plane
  8824. */
  8825. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8826. /**
  8827. * Gets the bottom frustum plane transformed by the transform matrix
  8828. * @param transform transformation matrix to be applied to the resulting frustum plane
  8829. * @param frustumPlane the resuling frustum plane
  8830. */
  8831. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8832. /**
  8833. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8834. * @param transform transformation matrix to be applied to the resulting frustum planes
  8835. * @param frustumPlanes the resuling frustum planes
  8836. */
  8837. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8838. }
  8839. }
  8840. declare module BABYLON {
  8841. /**
  8842. * Interface for the size containing width and height
  8843. */
  8844. export interface ISize {
  8845. /**
  8846. * Width
  8847. */
  8848. width: number;
  8849. /**
  8850. * Heighht
  8851. */
  8852. height: number;
  8853. }
  8854. /**
  8855. * Size containing widht and height
  8856. */
  8857. export class Size implements ISize {
  8858. /**
  8859. * Width
  8860. */
  8861. width: number;
  8862. /**
  8863. * Height
  8864. */
  8865. height: number;
  8866. /**
  8867. * Creates a Size object from the given width and height (floats).
  8868. * @param width width of the new size
  8869. * @param height height of the new size
  8870. */
  8871. constructor(width: number, height: number);
  8872. /**
  8873. * Returns a string with the Size width and height
  8874. * @returns a string with the Size width and height
  8875. */
  8876. toString(): string;
  8877. /**
  8878. * "Size"
  8879. * @returns the string "Size"
  8880. */
  8881. getClassName(): string;
  8882. /**
  8883. * Returns the Size hash code.
  8884. * @returns a hash code for a unique width and height
  8885. */
  8886. getHashCode(): number;
  8887. /**
  8888. * Updates the current size from the given one.
  8889. * @param src the given size
  8890. */
  8891. copyFrom(src: Size): void;
  8892. /**
  8893. * Updates in place the current Size from the given floats.
  8894. * @param width width of the new size
  8895. * @param height height of the new size
  8896. * @returns the updated Size.
  8897. */
  8898. copyFromFloats(width: number, height: number): Size;
  8899. /**
  8900. * Updates in place the current Size from the given floats.
  8901. * @param width width to set
  8902. * @param height height to set
  8903. * @returns the updated Size.
  8904. */
  8905. set(width: number, height: number): Size;
  8906. /**
  8907. * Multiplies the width and height by numbers
  8908. * @param w factor to multiple the width by
  8909. * @param h factor to multiple the height by
  8910. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8911. */
  8912. multiplyByFloats(w: number, h: number): Size;
  8913. /**
  8914. * Clones the size
  8915. * @returns a new Size copied from the given one.
  8916. */
  8917. clone(): Size;
  8918. /**
  8919. * True if the current Size and the given one width and height are strictly equal.
  8920. * @param other the other size to compare against
  8921. * @returns True if the current Size and the given one width and height are strictly equal.
  8922. */
  8923. equals(other: Size): boolean;
  8924. /**
  8925. * The surface of the Size : width * height (float).
  8926. */
  8927. get surface(): number;
  8928. /**
  8929. * Create a new size of zero
  8930. * @returns a new Size set to (0.0, 0.0)
  8931. */
  8932. static Zero(): Size;
  8933. /**
  8934. * Sums the width and height of two sizes
  8935. * @param otherSize size to add to this size
  8936. * @returns a new Size set as the addition result of the current Size and the given one.
  8937. */
  8938. add(otherSize: Size): Size;
  8939. /**
  8940. * Subtracts the width and height of two
  8941. * @param otherSize size to subtract to this size
  8942. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8943. */
  8944. subtract(otherSize: Size): Size;
  8945. /**
  8946. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8947. * @param start starting size to lerp between
  8948. * @param end end size to lerp between
  8949. * @param amount amount to lerp between the start and end values
  8950. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8951. */
  8952. static Lerp(start: Size, end: Size, amount: number): Size;
  8953. }
  8954. }
  8955. declare module BABYLON {
  8956. /**
  8957. * Contains position and normal vectors for a vertex
  8958. */
  8959. export class PositionNormalVertex {
  8960. /** the position of the vertex (defaut: 0,0,0) */
  8961. position: Vector3;
  8962. /** the normal of the vertex (defaut: 0,1,0) */
  8963. normal: Vector3;
  8964. /**
  8965. * Creates a PositionNormalVertex
  8966. * @param position the position of the vertex (defaut: 0,0,0)
  8967. * @param normal the normal of the vertex (defaut: 0,1,0)
  8968. */
  8969. constructor(
  8970. /** the position of the vertex (defaut: 0,0,0) */
  8971. position?: Vector3,
  8972. /** the normal of the vertex (defaut: 0,1,0) */
  8973. normal?: Vector3);
  8974. /**
  8975. * Clones the PositionNormalVertex
  8976. * @returns the cloned PositionNormalVertex
  8977. */
  8978. clone(): PositionNormalVertex;
  8979. }
  8980. /**
  8981. * Contains position, normal and uv vectors for a vertex
  8982. */
  8983. export class PositionNormalTextureVertex {
  8984. /** the position of the vertex (defaut: 0,0,0) */
  8985. position: Vector3;
  8986. /** the normal of the vertex (defaut: 0,1,0) */
  8987. normal: Vector3;
  8988. /** the uv of the vertex (default: 0,0) */
  8989. uv: Vector2;
  8990. /**
  8991. * Creates a PositionNormalTextureVertex
  8992. * @param position the position of the vertex (defaut: 0,0,0)
  8993. * @param normal the normal of the vertex (defaut: 0,1,0)
  8994. * @param uv the uv of the vertex (default: 0,0)
  8995. */
  8996. constructor(
  8997. /** the position of the vertex (defaut: 0,0,0) */
  8998. position?: Vector3,
  8999. /** the normal of the vertex (defaut: 0,1,0) */
  9000. normal?: Vector3,
  9001. /** the uv of the vertex (default: 0,0) */
  9002. uv?: Vector2);
  9003. /**
  9004. * Clones the PositionNormalTextureVertex
  9005. * @returns the cloned PositionNormalTextureVertex
  9006. */
  9007. clone(): PositionNormalTextureVertex;
  9008. }
  9009. }
  9010. declare module BABYLON {
  9011. /**
  9012. * Enum defining the type of animations supported by InputBlock
  9013. */
  9014. export enum AnimatedInputBlockTypes {
  9015. /** No animation */
  9016. None = 0,
  9017. /** Time based animation. Will only work for floats */
  9018. Time = 1
  9019. }
  9020. }
  9021. declare module BABYLON {
  9022. /**
  9023. * Interface describing all the common properties and methods a shadow light needs to implement.
  9024. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9025. * as well as binding the different shadow properties to the effects.
  9026. */
  9027. export interface IShadowLight extends Light {
  9028. /**
  9029. * The light id in the scene (used in scene.findLighById for instance)
  9030. */
  9031. id: string;
  9032. /**
  9033. * The position the shdow will be casted from.
  9034. */
  9035. position: Vector3;
  9036. /**
  9037. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9038. */
  9039. direction: Vector3;
  9040. /**
  9041. * The transformed position. Position of the light in world space taking parenting in account.
  9042. */
  9043. transformedPosition: Vector3;
  9044. /**
  9045. * The transformed direction. Direction of the light in world space taking parenting in account.
  9046. */
  9047. transformedDirection: Vector3;
  9048. /**
  9049. * The friendly name of the light in the scene.
  9050. */
  9051. name: string;
  9052. /**
  9053. * Defines the shadow projection clipping minimum z value.
  9054. */
  9055. shadowMinZ: number;
  9056. /**
  9057. * Defines the shadow projection clipping maximum z value.
  9058. */
  9059. shadowMaxZ: number;
  9060. /**
  9061. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9062. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9063. */
  9064. computeTransformedInformation(): boolean;
  9065. /**
  9066. * Gets the scene the light belongs to.
  9067. * @returns The scene
  9068. */
  9069. getScene(): Scene;
  9070. /**
  9071. * Callback defining a custom Projection Matrix Builder.
  9072. * This can be used to override the default projection matrix computation.
  9073. */
  9074. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9075. /**
  9076. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9077. * @param matrix The materix to updated with the projection information
  9078. * @param viewMatrix The transform matrix of the light
  9079. * @param renderList The list of mesh to render in the map
  9080. * @returns The current light
  9081. */
  9082. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9083. /**
  9084. * Gets the current depth scale used in ESM.
  9085. * @returns The scale
  9086. */
  9087. getDepthScale(): number;
  9088. /**
  9089. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9090. * @returns true if a cube texture needs to be use
  9091. */
  9092. needCube(): boolean;
  9093. /**
  9094. * Detects if the projection matrix requires to be recomputed this frame.
  9095. * @returns true if it requires to be recomputed otherwise, false.
  9096. */
  9097. needProjectionMatrixCompute(): boolean;
  9098. /**
  9099. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9100. */
  9101. forceProjectionMatrixCompute(): void;
  9102. /**
  9103. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9106. */
  9107. getShadowDirection(faceIndex?: number): Vector3;
  9108. /**
  9109. * Gets the minZ used for shadow according to both the scene and the light.
  9110. * @param activeCamera The camera we are returning the min for
  9111. * @returns the depth min z
  9112. */
  9113. getDepthMinZ(activeCamera: Camera): number;
  9114. /**
  9115. * Gets the maxZ used for shadow according to both the scene and the light.
  9116. * @param activeCamera The camera we are returning the max for
  9117. * @returns the depth max z
  9118. */
  9119. getDepthMaxZ(activeCamera: Camera): number;
  9120. }
  9121. /**
  9122. * Base implementation IShadowLight
  9123. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9124. */
  9125. export abstract class ShadowLight extends Light implements IShadowLight {
  9126. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9127. protected _position: Vector3;
  9128. protected _setPosition(value: Vector3): void;
  9129. /**
  9130. * Sets the position the shadow will be casted from. Also use as the light position for both
  9131. * point and spot lights.
  9132. */
  9133. get position(): Vector3;
  9134. /**
  9135. * Sets the position the shadow will be casted from. Also use as the light position for both
  9136. * point and spot lights.
  9137. */
  9138. set position(value: Vector3);
  9139. protected _direction: Vector3;
  9140. protected _setDirection(value: Vector3): void;
  9141. /**
  9142. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9143. * Also use as the light direction on spot and directional lights.
  9144. */
  9145. get direction(): Vector3;
  9146. /**
  9147. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9148. * Also use as the light direction on spot and directional lights.
  9149. */
  9150. set direction(value: Vector3);
  9151. protected _shadowMinZ: number;
  9152. /**
  9153. * Gets the shadow projection clipping minimum z value.
  9154. */
  9155. get shadowMinZ(): number;
  9156. /**
  9157. * Sets the shadow projection clipping minimum z value.
  9158. */
  9159. set shadowMinZ(value: number);
  9160. protected _shadowMaxZ: number;
  9161. /**
  9162. * Sets the shadow projection clipping maximum z value.
  9163. */
  9164. get shadowMaxZ(): number;
  9165. /**
  9166. * Gets the shadow projection clipping maximum z value.
  9167. */
  9168. set shadowMaxZ(value: number);
  9169. /**
  9170. * Callback defining a custom Projection Matrix Builder.
  9171. * This can be used to override the default projection matrix computation.
  9172. */
  9173. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9174. /**
  9175. * The transformed position. Position of the light in world space taking parenting in account.
  9176. */
  9177. transformedPosition: Vector3;
  9178. /**
  9179. * The transformed direction. Direction of the light in world space taking parenting in account.
  9180. */
  9181. transformedDirection: Vector3;
  9182. private _needProjectionMatrixCompute;
  9183. /**
  9184. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9185. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9186. */
  9187. computeTransformedInformation(): boolean;
  9188. /**
  9189. * Return the depth scale used for the shadow map.
  9190. * @returns the depth scale.
  9191. */
  9192. getDepthScale(): number;
  9193. /**
  9194. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9195. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9196. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9197. */
  9198. getShadowDirection(faceIndex?: number): Vector3;
  9199. /**
  9200. * Returns the ShadowLight absolute position in the World.
  9201. * @returns the position vector in world space
  9202. */
  9203. getAbsolutePosition(): Vector3;
  9204. /**
  9205. * Sets the ShadowLight direction toward the passed target.
  9206. * @param target The point to target in local space
  9207. * @returns the updated ShadowLight direction
  9208. */
  9209. setDirectionToTarget(target: Vector3): Vector3;
  9210. /**
  9211. * Returns the light rotation in euler definition.
  9212. * @returns the x y z rotation in local space.
  9213. */
  9214. getRotation(): Vector3;
  9215. /**
  9216. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9217. * @returns true if a cube texture needs to be use
  9218. */
  9219. needCube(): boolean;
  9220. /**
  9221. * Detects if the projection matrix requires to be recomputed this frame.
  9222. * @returns true if it requires to be recomputed otherwise, false.
  9223. */
  9224. needProjectionMatrixCompute(): boolean;
  9225. /**
  9226. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9227. */
  9228. forceProjectionMatrixCompute(): void;
  9229. /** @hidden */
  9230. _initCache(): void;
  9231. /** @hidden */
  9232. _isSynchronized(): boolean;
  9233. /**
  9234. * Computes the world matrix of the node
  9235. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9236. * @returns the world matrix
  9237. */
  9238. computeWorldMatrix(force?: boolean): Matrix;
  9239. /**
  9240. * Gets the minZ used for shadow according to both the scene and the light.
  9241. * @param activeCamera The camera we are returning the min for
  9242. * @returns the depth min z
  9243. */
  9244. getDepthMinZ(activeCamera: Camera): number;
  9245. /**
  9246. * Gets the maxZ used for shadow according to both the scene and the light.
  9247. * @param activeCamera The camera we are returning the max for
  9248. * @returns the depth max z
  9249. */
  9250. getDepthMaxZ(activeCamera: Camera): number;
  9251. /**
  9252. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9253. * @param matrix The materix to updated with the projection information
  9254. * @param viewMatrix The transform matrix of the light
  9255. * @param renderList The list of mesh to render in the map
  9256. * @returns The current light
  9257. */
  9258. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9259. }
  9260. }
  9261. declare module BABYLON {
  9262. /** @hidden */
  9263. export var packingFunctions: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module BABYLON {
  9269. /** @hidden */
  9270. export var bayerDitherFunctions: {
  9271. name: string;
  9272. shader: string;
  9273. };
  9274. }
  9275. declare module BABYLON {
  9276. /** @hidden */
  9277. export var shadowMapFragmentDeclaration: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module BABYLON {
  9283. /** @hidden */
  9284. export var clipPlaneFragmentDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var clipPlaneFragment: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var shadowMapFragment: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /** @hidden */
  9305. export var shadowMapPixelShader: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var bonesDeclaration: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var morphTargetsVertexGlobalDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var morphTargetsVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var instancesDeclaration: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var helperFunctions: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var shadowMapVertexDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var morphTargetsVertex: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var instancesVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var bonesVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var shadowMapVertexNormalBias: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var shadowMapVertexMetric: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var clipPlaneVertex: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var shadowMapVertexShader: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var depthBoxBlurPixelShader: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var shadowMapFragmentSoftTransparentShadow: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /**
  9424. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9425. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9426. */
  9427. export class EffectFallbacks implements IEffectFallbacks {
  9428. private _defines;
  9429. private _currentRank;
  9430. private _maxRank;
  9431. private _mesh;
  9432. /**
  9433. * Removes the fallback from the bound mesh.
  9434. */
  9435. unBindMesh(): void;
  9436. /**
  9437. * Adds a fallback on the specified property.
  9438. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9439. * @param define The name of the define in the shader
  9440. */
  9441. addFallback(rank: number, define: string): void;
  9442. /**
  9443. * Sets the mesh to use CPU skinning when needing to fallback.
  9444. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9445. * @param mesh The mesh to use the fallbacks.
  9446. */
  9447. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9448. /**
  9449. * Checks to see if more fallbacks are still availible.
  9450. */
  9451. get hasMoreFallbacks(): boolean;
  9452. /**
  9453. * Removes the defines that should be removed when falling back.
  9454. * @param currentDefines defines the current define statements for the shader.
  9455. * @param effect defines the current effect we try to compile
  9456. * @returns The resulting defines with defines of the current rank removed.
  9457. */
  9458. reduce(currentDefines: string, effect: Effect): string;
  9459. }
  9460. }
  9461. declare module BABYLON {
  9462. /**
  9463. * Interface used to define Action
  9464. */
  9465. export interface IAction {
  9466. /**
  9467. * Trigger for the action
  9468. */
  9469. trigger: number;
  9470. /** Options of the trigger */
  9471. triggerOptions: any;
  9472. /**
  9473. * Gets the trigger parameters
  9474. * @returns the trigger parameters
  9475. */
  9476. getTriggerParameter(): any;
  9477. /**
  9478. * Internal only - executes current action event
  9479. * @hidden
  9480. */
  9481. _executeCurrent(evt?: ActionEvent): void;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @param parent of child
  9485. * @returns the serialized object
  9486. */
  9487. serialize(parent: any): any;
  9488. /**
  9489. * Internal only
  9490. * @hidden
  9491. */
  9492. _prepare(): void;
  9493. /**
  9494. * Internal only - manager for action
  9495. * @hidden
  9496. */
  9497. _actionManager: Nullable<AbstractActionManager>;
  9498. /**
  9499. * Adds action to chain of actions, may be a DoNothingAction
  9500. * @param action defines the next action to execute
  9501. * @returns The action passed in
  9502. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9503. */
  9504. then(action: IAction): IAction;
  9505. }
  9506. /**
  9507. * The action to be carried out following a trigger
  9508. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9509. */
  9510. export class Action implements IAction {
  9511. /** the trigger, with or without parameters, for the action */
  9512. triggerOptions: any;
  9513. /**
  9514. * Trigger for the action
  9515. */
  9516. trigger: number;
  9517. /**
  9518. * Internal only - manager for action
  9519. * @hidden
  9520. */
  9521. _actionManager: ActionManager;
  9522. private _nextActiveAction;
  9523. private _child;
  9524. private _condition?;
  9525. private _triggerParameter;
  9526. /**
  9527. * An event triggered prior to action being executed.
  9528. */
  9529. onBeforeExecuteObservable: Observable<Action>;
  9530. /**
  9531. * Creates a new Action
  9532. * @param triggerOptions the trigger, with or without parameters, for the action
  9533. * @param condition an optional determinant of action
  9534. */
  9535. constructor(
  9536. /** the trigger, with or without parameters, for the action */
  9537. triggerOptions: any, condition?: Condition);
  9538. /**
  9539. * Internal only
  9540. * @hidden
  9541. */
  9542. _prepare(): void;
  9543. /**
  9544. * Gets the trigger parameters
  9545. * @returns the trigger parameters
  9546. */
  9547. getTriggerParameter(): any;
  9548. /**
  9549. * Internal only - executes current action event
  9550. * @hidden
  9551. */
  9552. _executeCurrent(evt?: ActionEvent): void;
  9553. /**
  9554. * Execute placeholder for child classes
  9555. * @param evt optional action event
  9556. */
  9557. execute(evt?: ActionEvent): void;
  9558. /**
  9559. * Skips to next active action
  9560. */
  9561. skipToNextActiveAction(): void;
  9562. /**
  9563. * Adds action to chain of actions, may be a DoNothingAction
  9564. * @param action defines the next action to execute
  9565. * @returns The action passed in
  9566. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9567. */
  9568. then(action: Action): Action;
  9569. /**
  9570. * Internal only
  9571. * @hidden
  9572. */
  9573. _getProperty(propertyPath: string): string;
  9574. /**
  9575. * Internal only
  9576. * @hidden
  9577. */
  9578. _getEffectiveTarget(target: any, propertyPath: string): any;
  9579. /**
  9580. * Serialize placeholder for child classes
  9581. * @param parent of child
  9582. * @returns the serialized object
  9583. */
  9584. serialize(parent: any): any;
  9585. /**
  9586. * Internal only called by serialize
  9587. * @hidden
  9588. */
  9589. protected _serialize(serializedAction: any, parent?: any): any;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. static _SerializeValueAsString: (value: any) => string;
  9595. /**
  9596. * Internal only
  9597. * @hidden
  9598. */
  9599. static _GetTargetProperty: (target: Scene | Node) => {
  9600. name: string;
  9601. targetType: string;
  9602. value: string;
  9603. };
  9604. }
  9605. }
  9606. declare module BABYLON {
  9607. /**
  9608. * A Condition applied to an Action
  9609. */
  9610. export class Condition {
  9611. /**
  9612. * Internal only - manager for action
  9613. * @hidden
  9614. */
  9615. _actionManager: ActionManager;
  9616. /**
  9617. * Internal only
  9618. * @hidden
  9619. */
  9620. _evaluationId: number;
  9621. /**
  9622. * Internal only
  9623. * @hidden
  9624. */
  9625. _currentResult: boolean;
  9626. /**
  9627. * Creates a new Condition
  9628. * @param actionManager the manager of the action the condition is applied to
  9629. */
  9630. constructor(actionManager: ActionManager);
  9631. /**
  9632. * Check if the current condition is valid
  9633. * @returns a boolean
  9634. */
  9635. isValid(): boolean;
  9636. /**
  9637. * Internal only
  9638. * @hidden
  9639. */
  9640. _getProperty(propertyPath: string): string;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. _getEffectiveTarget(target: any, propertyPath: string): any;
  9646. /**
  9647. * Serialize placeholder for child classes
  9648. * @returns the serialized object
  9649. */
  9650. serialize(): any;
  9651. /**
  9652. * Internal only
  9653. * @hidden
  9654. */
  9655. protected _serialize(serializedCondition: any): any;
  9656. }
  9657. /**
  9658. * Defines specific conditional operators as extensions of Condition
  9659. */
  9660. export class ValueCondition extends Condition {
  9661. /** path to specify the property of the target the conditional operator uses */
  9662. propertyPath: string;
  9663. /** the value compared by the conditional operator against the current value of the property */
  9664. value: any;
  9665. /** the conditional operator, default ValueCondition.IsEqual */
  9666. operator: number;
  9667. /**
  9668. * Internal only
  9669. * @hidden
  9670. */
  9671. private static _IsEqual;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. private static _IsDifferent;
  9677. /**
  9678. * Internal only
  9679. * @hidden
  9680. */
  9681. private static _IsGreater;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. private static _IsLesser;
  9687. /**
  9688. * returns the number for IsEqual
  9689. */
  9690. static get IsEqual(): number;
  9691. /**
  9692. * Returns the number for IsDifferent
  9693. */
  9694. static get IsDifferent(): number;
  9695. /**
  9696. * Returns the number for IsGreater
  9697. */
  9698. static get IsGreater(): number;
  9699. /**
  9700. * Returns the number for IsLesser
  9701. */
  9702. static get IsLesser(): number;
  9703. /**
  9704. * Internal only The action manager for the condition
  9705. * @hidden
  9706. */
  9707. _actionManager: ActionManager;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. private _target;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. private _effectiveTarget;
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. private _property;
  9723. /**
  9724. * Creates a new ValueCondition
  9725. * @param actionManager manager for the action the condition applies to
  9726. * @param target for the action
  9727. * @param propertyPath path to specify the property of the target the conditional operator uses
  9728. * @param value the value compared by the conditional operator against the current value of the property
  9729. * @param operator the conditional operator, default ValueCondition.IsEqual
  9730. */
  9731. constructor(actionManager: ActionManager, target: any,
  9732. /** path to specify the property of the target the conditional operator uses */
  9733. propertyPath: string,
  9734. /** the value compared by the conditional operator against the current value of the property */
  9735. value: any,
  9736. /** the conditional operator, default ValueCondition.IsEqual */
  9737. operator?: number);
  9738. /**
  9739. * Compares the given value with the property value for the specified conditional operator
  9740. * @returns the result of the comparison
  9741. */
  9742. isValid(): boolean;
  9743. /**
  9744. * Serialize the ValueCondition into a JSON compatible object
  9745. * @returns serialization object
  9746. */
  9747. serialize(): any;
  9748. /**
  9749. * Gets the name of the conditional operator for the ValueCondition
  9750. * @param operator the conditional operator
  9751. * @returns the name
  9752. */
  9753. static GetOperatorName(operator: number): string;
  9754. }
  9755. /**
  9756. * Defines a predicate condition as an extension of Condition
  9757. */
  9758. export class PredicateCondition extends Condition {
  9759. /** defines the predicate function used to validate the condition */
  9760. predicate: () => boolean;
  9761. /**
  9762. * Internal only - manager for action
  9763. * @hidden
  9764. */
  9765. _actionManager: ActionManager;
  9766. /**
  9767. * Creates a new PredicateCondition
  9768. * @param actionManager manager for the action the condition applies to
  9769. * @param predicate defines the predicate function used to validate the condition
  9770. */
  9771. constructor(actionManager: ActionManager,
  9772. /** defines the predicate function used to validate the condition */
  9773. predicate: () => boolean);
  9774. /**
  9775. * @returns the validity of the predicate condition
  9776. */
  9777. isValid(): boolean;
  9778. }
  9779. /**
  9780. * Defines a state condition as an extension of Condition
  9781. */
  9782. export class StateCondition extends Condition {
  9783. /** Value to compare with target state */
  9784. value: string;
  9785. /**
  9786. * Internal only - manager for action
  9787. * @hidden
  9788. */
  9789. _actionManager: ActionManager;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. private _target;
  9795. /**
  9796. * Creates a new StateCondition
  9797. * @param actionManager manager for the action the condition applies to
  9798. * @param target of the condition
  9799. * @param value to compare with target state
  9800. */
  9801. constructor(actionManager: ActionManager, target: any,
  9802. /** Value to compare with target state */
  9803. value: string);
  9804. /**
  9805. * Gets a boolean indicating if the current condition is met
  9806. * @returns the validity of the state
  9807. */
  9808. isValid(): boolean;
  9809. /**
  9810. * Serialize the StateCondition into a JSON compatible object
  9811. * @returns serialization object
  9812. */
  9813. serialize(): any;
  9814. }
  9815. }
  9816. declare module BABYLON {
  9817. /**
  9818. * This defines an action responsible to toggle a boolean once triggered.
  9819. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9820. */
  9821. export class SwitchBooleanAction extends Action {
  9822. /**
  9823. * The path to the boolean property in the target object
  9824. */
  9825. propertyPath: string;
  9826. private _target;
  9827. private _effectiveTarget;
  9828. private _property;
  9829. /**
  9830. * Instantiate the action
  9831. * @param triggerOptions defines the trigger options
  9832. * @param target defines the object containing the boolean
  9833. * @param propertyPath defines the path to the boolean property in the target object
  9834. * @param condition defines the trigger related conditions
  9835. */
  9836. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9837. /** @hidden */
  9838. _prepare(): void;
  9839. /**
  9840. * Execute the action toggle the boolean value.
  9841. */
  9842. execute(): void;
  9843. /**
  9844. * Serializes the actions and its related information.
  9845. * @param parent defines the object to serialize in
  9846. * @returns the serialized object
  9847. */
  9848. serialize(parent: any): any;
  9849. }
  9850. /**
  9851. * This defines an action responsible to set a the state field of the target
  9852. * to a desired value once triggered.
  9853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9854. */
  9855. export class SetStateAction extends Action {
  9856. /**
  9857. * The value to store in the state field.
  9858. */
  9859. value: string;
  9860. private _target;
  9861. /**
  9862. * Instantiate the action
  9863. * @param triggerOptions defines the trigger options
  9864. * @param target defines the object containing the state property
  9865. * @param value defines the value to store in the state field
  9866. * @param condition defines the trigger related conditions
  9867. */
  9868. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9869. /**
  9870. * Execute the action and store the value on the target state property.
  9871. */
  9872. execute(): void;
  9873. /**
  9874. * Serializes the actions and its related information.
  9875. * @param parent defines the object to serialize in
  9876. * @returns the serialized object
  9877. */
  9878. serialize(parent: any): any;
  9879. }
  9880. /**
  9881. * This defines an action responsible to set a property of the target
  9882. * to a desired value once triggered.
  9883. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9884. */
  9885. export class SetValueAction extends Action {
  9886. /**
  9887. * The path of the property to set in the target.
  9888. */
  9889. propertyPath: string;
  9890. /**
  9891. * The value to set in the property
  9892. */
  9893. value: any;
  9894. private _target;
  9895. private _effectiveTarget;
  9896. private _property;
  9897. /**
  9898. * Instantiate the action
  9899. * @param triggerOptions defines the trigger options
  9900. * @param target defines the object containing the property
  9901. * @param propertyPath defines the path of the property to set in the target
  9902. * @param value defines the value to set in the property
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and set the targetted property to the desired value.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to increment the target value
  9921. * to a desired value once triggered.
  9922. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9923. */
  9924. export class IncrementValueAction extends Action {
  9925. /**
  9926. * The path of the property to increment in the target.
  9927. */
  9928. propertyPath: string;
  9929. /**
  9930. * The value we should increment the property by.
  9931. */
  9932. value: any;
  9933. private _target;
  9934. private _effectiveTarget;
  9935. private _property;
  9936. /**
  9937. * Instantiate the action
  9938. * @param triggerOptions defines the trigger options
  9939. * @param target defines the object containing the property
  9940. * @param propertyPath defines the path of the property to increment in the target
  9941. * @param value defines the value value we should increment the property by
  9942. * @param condition defines the trigger related conditions
  9943. */
  9944. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9945. /** @hidden */
  9946. _prepare(): void;
  9947. /**
  9948. * Execute the action and increment the target of the value amount.
  9949. */
  9950. execute(): void;
  9951. /**
  9952. * Serializes the actions and its related information.
  9953. * @param parent defines the object to serialize in
  9954. * @returns the serialized object
  9955. */
  9956. serialize(parent: any): any;
  9957. }
  9958. /**
  9959. * This defines an action responsible to start an animation once triggered.
  9960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9961. */
  9962. export class PlayAnimationAction extends Action {
  9963. /**
  9964. * Where the animation should start (animation frame)
  9965. */
  9966. from: number;
  9967. /**
  9968. * Where the animation should stop (animation frame)
  9969. */
  9970. to: number;
  9971. /**
  9972. * Define if the animation should loop or stop after the first play.
  9973. */
  9974. loop?: boolean;
  9975. private _target;
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param target defines the target animation or animation name
  9980. * @param from defines from where the animation should start (animation frame)
  9981. * @param end defines where the animation should stop (animation frame)
  9982. * @param loop defines if the animation should loop or stop after the first play
  9983. * @param condition defines the trigger related conditions
  9984. */
  9985. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9986. /** @hidden */
  9987. _prepare(): void;
  9988. /**
  9989. * Execute the action and play the animation.
  9990. */
  9991. execute(): void;
  9992. /**
  9993. * Serializes the actions and its related information.
  9994. * @param parent defines the object to serialize in
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. }
  9999. /**
  10000. * This defines an action responsible to stop an animation once triggered.
  10001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10002. */
  10003. export class StopAnimationAction extends Action {
  10004. private _target;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param target defines the target animation or animation name
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, target: any, condition?: Condition);
  10012. /** @hidden */
  10013. _prepare(): void;
  10014. /**
  10015. * Execute the action and stop the animation.
  10016. */
  10017. execute(): void;
  10018. /**
  10019. * Serializes the actions and its related information.
  10020. * @param parent defines the object to serialize in
  10021. * @returns the serialized object
  10022. */
  10023. serialize(parent: any): any;
  10024. }
  10025. /**
  10026. * This defines an action responsible that does nothing once triggered.
  10027. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10028. */
  10029. export class DoNothingAction extends Action {
  10030. /**
  10031. * Instantiate the action
  10032. * @param triggerOptions defines the trigger options
  10033. * @param condition defines the trigger related conditions
  10034. */
  10035. constructor(triggerOptions?: any, condition?: Condition);
  10036. /**
  10037. * Execute the action and do nothing.
  10038. */
  10039. execute(): void;
  10040. /**
  10041. * Serializes the actions and its related information.
  10042. * @param parent defines the object to serialize in
  10043. * @returns the serialized object
  10044. */
  10045. serialize(parent: any): any;
  10046. }
  10047. /**
  10048. * This defines an action responsible to trigger several actions once triggered.
  10049. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10050. */
  10051. export class CombineAction extends Action {
  10052. /**
  10053. * The list of aggregated animations to run.
  10054. */
  10055. children: Action[];
  10056. /**
  10057. * Instantiate the action
  10058. * @param triggerOptions defines the trigger options
  10059. * @param children defines the list of aggregated animations to run
  10060. * @param condition defines the trigger related conditions
  10061. */
  10062. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10063. /** @hidden */
  10064. _prepare(): void;
  10065. /**
  10066. * Execute the action and executes all the aggregated actions.
  10067. */
  10068. execute(evt: ActionEvent): void;
  10069. /**
  10070. * Serializes the actions and its related information.
  10071. * @param parent defines the object to serialize in
  10072. * @returns the serialized object
  10073. */
  10074. serialize(parent: any): any;
  10075. }
  10076. /**
  10077. * This defines an action responsible to run code (external event) once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class ExecuteCodeAction extends Action {
  10081. /**
  10082. * The callback function to run.
  10083. */
  10084. func: (evt: ActionEvent) => void;
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param func defines the callback function to run
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10092. /**
  10093. * Execute the action and run the attached code.
  10094. */
  10095. execute(evt: ActionEvent): void;
  10096. }
  10097. /**
  10098. * This defines an action responsible to set the parent property of the target once triggered.
  10099. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10100. */
  10101. export class SetParentAction extends Action {
  10102. private _parent;
  10103. private _target;
  10104. /**
  10105. * Instantiate the action
  10106. * @param triggerOptions defines the trigger options
  10107. * @param target defines the target containing the parent property
  10108. * @param parent defines from where the animation should start (animation frame)
  10109. * @param condition defines the trigger related conditions
  10110. */
  10111. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10112. /** @hidden */
  10113. _prepare(): void;
  10114. /**
  10115. * Execute the action and set the parent property.
  10116. */
  10117. execute(): void;
  10118. /**
  10119. * Serializes the actions and its related information.
  10120. * @param parent defines the object to serialize in
  10121. * @returns the serialized object
  10122. */
  10123. serialize(parent: any): any;
  10124. }
  10125. }
  10126. declare module BABYLON {
  10127. /**
  10128. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10129. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10131. */
  10132. export class ActionManager extends AbstractActionManager {
  10133. /**
  10134. * Nothing
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly NothingTrigger: number;
  10138. /**
  10139. * On pick
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnPickTrigger: number;
  10143. /**
  10144. * On left pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnLeftPickTrigger: number;
  10148. /**
  10149. * On right pick
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnRightPickTrigger: number;
  10153. /**
  10154. * On center pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnCenterPickTrigger: number;
  10158. /**
  10159. * On pick down
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnPickDownTrigger: number;
  10163. /**
  10164. * On double pick
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnDoublePickTrigger: number;
  10168. /**
  10169. * On pick up
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnPickUpTrigger: number;
  10173. /**
  10174. * On pick out.
  10175. * This trigger will only be raised if you also declared a OnPickDown
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnPickOutTrigger: number;
  10179. /**
  10180. * On long press
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnLongPressTrigger: number;
  10184. /**
  10185. * On pointer over
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnPointerOverTrigger: number;
  10189. /**
  10190. * On pointer out
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnPointerOutTrigger: number;
  10194. /**
  10195. * On every frame
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnEveryFrameTrigger: number;
  10199. /**
  10200. * On intersection enter
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnIntersectionEnterTrigger: number;
  10204. /**
  10205. * On intersection exit
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnIntersectionExitTrigger: number;
  10209. /**
  10210. * On key down
  10211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10212. */
  10213. static readonly OnKeyDownTrigger: number;
  10214. /**
  10215. * On key up
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnKeyUpTrigger: number;
  10219. private _scene;
  10220. /**
  10221. * Creates a new action manager
  10222. * @param scene defines the hosting scene
  10223. */
  10224. constructor(scene: Scene);
  10225. /**
  10226. * Releases all associated resources
  10227. */
  10228. dispose(): void;
  10229. /**
  10230. * Gets hosting scene
  10231. * @returns the hosting scene
  10232. */
  10233. getScene(): Scene;
  10234. /**
  10235. * Does this action manager handles actions of any of the given triggers
  10236. * @param triggers defines the triggers to be tested
  10237. * @return a boolean indicating whether one (or more) of the triggers is handled
  10238. */
  10239. hasSpecificTriggers(triggers: number[]): boolean;
  10240. /**
  10241. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10242. * speed.
  10243. * @param triggerA defines the trigger to be tested
  10244. * @param triggerB defines the trigger to be tested
  10245. * @return a boolean indicating whether one (or more) of the triggers is handled
  10246. */
  10247. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10248. /**
  10249. * Does this action manager handles actions of a given trigger
  10250. * @param trigger defines the trigger to be tested
  10251. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10252. * @return whether the trigger is handled
  10253. */
  10254. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10255. /**
  10256. * Does this action manager has pointer triggers
  10257. */
  10258. get hasPointerTriggers(): boolean;
  10259. /**
  10260. * Does this action manager has pick triggers
  10261. */
  10262. get hasPickTriggers(): boolean;
  10263. /**
  10264. * Registers an action to this action manager
  10265. * @param action defines the action to be registered
  10266. * @return the action amended (prepared) after registration
  10267. */
  10268. registerAction(action: IAction): Nullable<IAction>;
  10269. /**
  10270. * Unregisters an action to this action manager
  10271. * @param action defines the action to be unregistered
  10272. * @return a boolean indicating whether the action has been unregistered
  10273. */
  10274. unregisterAction(action: IAction): Boolean;
  10275. /**
  10276. * Process a specific trigger
  10277. * @param trigger defines the trigger to process
  10278. * @param evt defines the event details to be processed
  10279. */
  10280. processTrigger(trigger: number, evt?: IActionEvent): void;
  10281. /** @hidden */
  10282. _getEffectiveTarget(target: any, propertyPath: string): any;
  10283. /** @hidden */
  10284. _getProperty(propertyPath: string): string;
  10285. /**
  10286. * Serialize this manager to a JSON object
  10287. * @param name defines the property name to store this manager
  10288. * @returns a JSON representation of this manager
  10289. */
  10290. serialize(name: string): any;
  10291. /**
  10292. * Creates a new ActionManager from a JSON data
  10293. * @param parsedActions defines the JSON data to read from
  10294. * @param object defines the hosting mesh
  10295. * @param scene defines the hosting scene
  10296. */
  10297. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10298. /**
  10299. * Get a trigger name by index
  10300. * @param trigger defines the trigger index
  10301. * @returns a trigger name
  10302. */
  10303. static GetTriggerName(trigger: number): string;
  10304. }
  10305. }
  10306. declare module BABYLON {
  10307. /**
  10308. * Class used to represent a sprite
  10309. * @see https://doc.babylonjs.com/babylon101/sprites
  10310. */
  10311. export class Sprite implements IAnimatable {
  10312. /** defines the name */
  10313. name: string;
  10314. /** Gets or sets the current world position */
  10315. position: Vector3;
  10316. /** Gets or sets the main color */
  10317. color: Color4;
  10318. /** Gets or sets the width */
  10319. width: number;
  10320. /** Gets or sets the height */
  10321. height: number;
  10322. /** Gets or sets rotation angle */
  10323. angle: number;
  10324. /** Gets or sets the cell index in the sprite sheet */
  10325. cellIndex: number;
  10326. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10327. cellRef: string;
  10328. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10329. invertU: boolean;
  10330. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10331. invertV: boolean;
  10332. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10333. disposeWhenFinishedAnimating: boolean;
  10334. /** Gets the list of attached animations */
  10335. animations: Nullable<Array<Animation>>;
  10336. /** Gets or sets a boolean indicating if the sprite can be picked */
  10337. isPickable: boolean;
  10338. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10339. useAlphaForPicking: boolean;
  10340. /** @hidden */
  10341. _xOffset: number;
  10342. /** @hidden */
  10343. _yOffset: number;
  10344. /** @hidden */
  10345. _xSize: number;
  10346. /** @hidden */
  10347. _ySize: number;
  10348. /**
  10349. * Gets or sets the associated action manager
  10350. */
  10351. actionManager: Nullable<ActionManager>;
  10352. /**
  10353. * An event triggered when the control has been disposed
  10354. */
  10355. onDisposeObservable: Observable<Sprite>;
  10356. private _animationStarted;
  10357. private _loopAnimation;
  10358. private _fromIndex;
  10359. private _toIndex;
  10360. private _delay;
  10361. private _direction;
  10362. private _manager;
  10363. private _time;
  10364. private _onAnimationEnd;
  10365. /**
  10366. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10367. */
  10368. isVisible: boolean;
  10369. /**
  10370. * Gets or sets the sprite size
  10371. */
  10372. get size(): number;
  10373. set size(value: number);
  10374. /**
  10375. * Returns a boolean indicating if the animation is started
  10376. */
  10377. get animationStarted(): boolean;
  10378. /**
  10379. * Gets or sets the unique id of the sprite
  10380. */
  10381. uniqueId: number;
  10382. /**
  10383. * Gets the manager of this sprite
  10384. */
  10385. get manager(): ISpriteManager;
  10386. /**
  10387. * Creates a new Sprite
  10388. * @param name defines the name
  10389. * @param manager defines the manager
  10390. */
  10391. constructor(
  10392. /** defines the name */
  10393. name: string, manager: ISpriteManager);
  10394. /**
  10395. * Returns the string "Sprite"
  10396. * @returns "Sprite"
  10397. */
  10398. getClassName(): string;
  10399. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10400. get fromIndex(): number;
  10401. set fromIndex(value: number);
  10402. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10403. get toIndex(): number;
  10404. set toIndex(value: number);
  10405. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10406. get loopAnimation(): boolean;
  10407. set loopAnimation(value: boolean);
  10408. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10409. get delay(): number;
  10410. set delay(value: number);
  10411. /**
  10412. * Starts an animation
  10413. * @param from defines the initial key
  10414. * @param to defines the end key
  10415. * @param loop defines if the animation must loop
  10416. * @param delay defines the start delay (in ms)
  10417. * @param onAnimationEnd defines a callback to call when animation ends
  10418. */
  10419. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10420. /** Stops current animation (if any) */
  10421. stopAnimation(): void;
  10422. /** @hidden */
  10423. _animate(deltaTime: number): void;
  10424. /** Release associated resources */
  10425. dispose(): void;
  10426. /**
  10427. * Serializes the sprite to a JSON object
  10428. * @returns the JSON object
  10429. */
  10430. serialize(): any;
  10431. /**
  10432. * Parses a JSON object to create a new sprite
  10433. * @param parsedSprite The JSON object to parse
  10434. * @param manager defines the hosting manager
  10435. * @returns the new sprite
  10436. */
  10437. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10438. }
  10439. }
  10440. declare module BABYLON {
  10441. /**
  10442. * Information about the result of picking within a scene
  10443. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10444. */
  10445. export class PickingInfo {
  10446. /** @hidden */
  10447. _pickingUnavailable: boolean;
  10448. /**
  10449. * If the pick collided with an object
  10450. */
  10451. hit: boolean;
  10452. /**
  10453. * Distance away where the pick collided
  10454. */
  10455. distance: number;
  10456. /**
  10457. * The location of pick collision
  10458. */
  10459. pickedPoint: Nullable<Vector3>;
  10460. /**
  10461. * The mesh corresponding the the pick collision
  10462. */
  10463. pickedMesh: Nullable<AbstractMesh>;
  10464. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10465. bu: number;
  10466. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10467. bv: number;
  10468. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10469. faceId: number;
  10470. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10471. subMeshFaceId: number;
  10472. /** Id of the the submesh that was picked */
  10473. subMeshId: number;
  10474. /** If a sprite was picked, this will be the sprite the pick collided with */
  10475. pickedSprite: Nullable<Sprite>;
  10476. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10477. thinInstanceIndex: number;
  10478. /**
  10479. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10480. */
  10481. originMesh: Nullable<AbstractMesh>;
  10482. /**
  10483. * The ray that was used to perform the picking.
  10484. */
  10485. ray: Nullable<Ray>;
  10486. /**
  10487. * Gets the normal correspodning to the face the pick collided with
  10488. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10489. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10490. * @returns The normal correspodning to the face the pick collided with
  10491. */
  10492. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10493. /**
  10494. * Gets the texture coordinates of where the pick occured
  10495. * @returns the vector containing the coordnates of the texture
  10496. */
  10497. getTextureCoordinates(): Nullable<Vector2>;
  10498. }
  10499. }
  10500. declare module BABYLON {
  10501. /**
  10502. * Class representing a ray with position and direction
  10503. */
  10504. export class Ray {
  10505. /** origin point */
  10506. origin: Vector3;
  10507. /** direction */
  10508. direction: Vector3;
  10509. /** length of the ray */
  10510. length: number;
  10511. private static readonly _TmpVector3;
  10512. private _tmpRay;
  10513. /**
  10514. * Creates a new ray
  10515. * @param origin origin point
  10516. * @param direction direction
  10517. * @param length length of the ray
  10518. */
  10519. constructor(
  10520. /** origin point */
  10521. origin: Vector3,
  10522. /** direction */
  10523. direction: Vector3,
  10524. /** length of the ray */
  10525. length?: number);
  10526. /**
  10527. * Checks if the ray intersects a box
  10528. * This does not account for the ray lenght by design to improve perfs.
  10529. * @param minimum bound of the box
  10530. * @param maximum bound of the box
  10531. * @param intersectionTreshold extra extend to be added to the box in all direction
  10532. * @returns if the box was hit
  10533. */
  10534. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10535. /**
  10536. * Checks if the ray intersects a box
  10537. * This does not account for the ray lenght by design to improve perfs.
  10538. * @param box the bounding box to check
  10539. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10540. * @returns if the box was hit
  10541. */
  10542. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10543. /**
  10544. * If the ray hits a sphere
  10545. * @param sphere the bounding sphere to check
  10546. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10547. * @returns true if it hits the sphere
  10548. */
  10549. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10550. /**
  10551. * If the ray hits a triange
  10552. * @param vertex0 triangle vertex
  10553. * @param vertex1 triangle vertex
  10554. * @param vertex2 triangle vertex
  10555. * @returns intersection information if hit
  10556. */
  10557. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10558. /**
  10559. * Checks if ray intersects a plane
  10560. * @param plane the plane to check
  10561. * @returns the distance away it was hit
  10562. */
  10563. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10564. /**
  10565. * Calculate the intercept of a ray on a given axis
  10566. * @param axis to check 'x' | 'y' | 'z'
  10567. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10568. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10569. */
  10570. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10571. /**
  10572. * Checks if ray intersects a mesh
  10573. * @param mesh the mesh to check
  10574. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10575. * @returns picking info of the intersecton
  10576. */
  10577. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10578. /**
  10579. * Checks if ray intersects a mesh
  10580. * @param meshes the meshes to check
  10581. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10582. * @param results array to store result in
  10583. * @returns Array of picking infos
  10584. */
  10585. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10586. private _comparePickingInfo;
  10587. private static smallnum;
  10588. private static rayl;
  10589. /**
  10590. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10591. * @param sega the first point of the segment to test the intersection against
  10592. * @param segb the second point of the segment to test the intersection against
  10593. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10594. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10595. */
  10596. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10597. /**
  10598. * Update the ray from viewport position
  10599. * @param x position
  10600. * @param y y position
  10601. * @param viewportWidth viewport width
  10602. * @param viewportHeight viewport height
  10603. * @param world world matrix
  10604. * @param view view matrix
  10605. * @param projection projection matrix
  10606. * @returns this ray updated
  10607. */
  10608. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10609. /**
  10610. * Creates a ray with origin and direction of 0,0,0
  10611. * @returns the new ray
  10612. */
  10613. static Zero(): Ray;
  10614. /**
  10615. * Creates a new ray from screen space and viewport
  10616. * @param x position
  10617. * @param y y position
  10618. * @param viewportWidth viewport width
  10619. * @param viewportHeight viewport height
  10620. * @param world world matrix
  10621. * @param view view matrix
  10622. * @param projection projection matrix
  10623. * @returns new ray
  10624. */
  10625. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10626. /**
  10627. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10628. * transformed to the given world matrix.
  10629. * @param origin The origin point
  10630. * @param end The end point
  10631. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10632. * @returns the new ray
  10633. */
  10634. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10635. /**
  10636. * Transforms a ray by a matrix
  10637. * @param ray ray to transform
  10638. * @param matrix matrix to apply
  10639. * @returns the resulting new ray
  10640. */
  10641. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10642. /**
  10643. * Transforms a ray by a matrix
  10644. * @param ray ray to transform
  10645. * @param matrix matrix to apply
  10646. * @param result ray to store result in
  10647. */
  10648. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10649. /**
  10650. * Unproject a ray from screen space to object space
  10651. * @param sourceX defines the screen space x coordinate to use
  10652. * @param sourceY defines the screen space y coordinate to use
  10653. * @param viewportWidth defines the current width of the viewport
  10654. * @param viewportHeight defines the current height of the viewport
  10655. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10656. * @param view defines the view matrix to use
  10657. * @param projection defines the projection matrix to use
  10658. */
  10659. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10660. }
  10661. /**
  10662. * Type used to define predicate used to select faces when a mesh intersection is detected
  10663. */
  10664. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10665. interface Scene {
  10666. /** @hidden */
  10667. _tempPickingRay: Nullable<Ray>;
  10668. /** @hidden */
  10669. _cachedRayForTransform: Ray;
  10670. /** @hidden */
  10671. _pickWithRayInverseMatrix: Matrix;
  10672. /** @hidden */
  10673. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10674. /** @hidden */
  10675. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10676. /** @hidden */
  10677. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10678. }
  10679. }
  10680. declare module BABYLON {
  10681. /**
  10682. * Groups all the scene component constants in one place to ease maintenance.
  10683. * @hidden
  10684. */
  10685. export class SceneComponentConstants {
  10686. static readonly NAME_EFFECTLAYER: string;
  10687. static readonly NAME_LAYER: string;
  10688. static readonly NAME_LENSFLARESYSTEM: string;
  10689. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10690. static readonly NAME_PARTICLESYSTEM: string;
  10691. static readonly NAME_GAMEPAD: string;
  10692. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10693. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10694. static readonly NAME_PREPASSRENDERER: string;
  10695. static readonly NAME_DEPTHRENDERER: string;
  10696. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10697. static readonly NAME_SPRITE: string;
  10698. static readonly NAME_SUBSURFACE: string;
  10699. static readonly NAME_OUTLINERENDERER: string;
  10700. static readonly NAME_PROCEDURALTEXTURE: string;
  10701. static readonly NAME_SHADOWGENERATOR: string;
  10702. static readonly NAME_OCTREE: string;
  10703. static readonly NAME_PHYSICSENGINE: string;
  10704. static readonly NAME_AUDIO: string;
  10705. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10706. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10707. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10708. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10709. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10710. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10711. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10712. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10713. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10714. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10715. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10716. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10717. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10718. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10719. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10720. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10721. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10722. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10723. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10724. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10725. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10726. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10727. static readonly STEP_AFTERRENDER_AUDIO: number;
  10728. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10729. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10730. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10731. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10732. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10733. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10734. static readonly STEP_POINTERMOVE_SPRITE: number;
  10735. static readonly STEP_POINTERDOWN_SPRITE: number;
  10736. static readonly STEP_POINTERUP_SPRITE: number;
  10737. }
  10738. /**
  10739. * This represents a scene component.
  10740. *
  10741. * This is used to decouple the dependency the scene is having on the different workloads like
  10742. * layers, post processes...
  10743. */
  10744. export interface ISceneComponent {
  10745. /**
  10746. * The name of the component. Each component must have a unique name.
  10747. */
  10748. name: string;
  10749. /**
  10750. * The scene the component belongs to.
  10751. */
  10752. scene: Scene;
  10753. /**
  10754. * Register the component to one instance of a scene.
  10755. */
  10756. register(): void;
  10757. /**
  10758. * Rebuilds the elements related to this component in case of
  10759. * context lost for instance.
  10760. */
  10761. rebuild(): void;
  10762. /**
  10763. * Disposes the component and the associated ressources.
  10764. */
  10765. dispose(): void;
  10766. }
  10767. /**
  10768. * This represents a SERIALIZABLE scene component.
  10769. *
  10770. * This extends Scene Component to add Serialization methods on top.
  10771. */
  10772. export interface ISceneSerializableComponent extends ISceneComponent {
  10773. /**
  10774. * Adds all the elements from the container to the scene
  10775. * @param container the container holding the elements
  10776. */
  10777. addFromContainer(container: AbstractScene): void;
  10778. /**
  10779. * Removes all the elements in the container from the scene
  10780. * @param container contains the elements to remove
  10781. * @param dispose if the removed element should be disposed (default: false)
  10782. */
  10783. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10784. /**
  10785. * Serializes the component data to the specified json object
  10786. * @param serializationObject The object to serialize to
  10787. */
  10788. serialize(serializationObject: any): void;
  10789. }
  10790. /**
  10791. * Strong typing of a Mesh related stage step action
  10792. */
  10793. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10794. /**
  10795. * Strong typing of a Evaluate Sub Mesh related stage step action
  10796. */
  10797. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10798. /**
  10799. * Strong typing of a Active Mesh related stage step action
  10800. */
  10801. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10802. /**
  10803. * Strong typing of a Camera related stage step action
  10804. */
  10805. export type CameraStageAction = (camera: Camera) => void;
  10806. /**
  10807. * Strong typing of a Camera Frame buffer related stage step action
  10808. */
  10809. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10810. /**
  10811. * Strong typing of a Render Target related stage step action
  10812. */
  10813. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10814. /**
  10815. * Strong typing of a RenderingGroup related stage step action
  10816. */
  10817. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10818. /**
  10819. * Strong typing of a Mesh Render related stage step action
  10820. */
  10821. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10822. /**
  10823. * Strong typing of a simple stage step action
  10824. */
  10825. export type SimpleStageAction = () => void;
  10826. /**
  10827. * Strong typing of a render target action.
  10828. */
  10829. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10830. /**
  10831. * Strong typing of a pointer move action.
  10832. */
  10833. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10834. /**
  10835. * Strong typing of a pointer up/down action.
  10836. */
  10837. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10838. /**
  10839. * Representation of a stage in the scene (Basically a list of ordered steps)
  10840. * @hidden
  10841. */
  10842. export class Stage<T extends Function> extends Array<{
  10843. index: number;
  10844. component: ISceneComponent;
  10845. action: T;
  10846. }> {
  10847. /**
  10848. * Hide ctor from the rest of the world.
  10849. * @param items The items to add.
  10850. */
  10851. private constructor();
  10852. /**
  10853. * Creates a new Stage.
  10854. * @returns A new instance of a Stage
  10855. */
  10856. static Create<T extends Function>(): Stage<T>;
  10857. /**
  10858. * Registers a step in an ordered way in the targeted stage.
  10859. * @param index Defines the position to register the step in
  10860. * @param component Defines the component attached to the step
  10861. * @param action Defines the action to launch during the step
  10862. */
  10863. registerStep(index: number, component: ISceneComponent, action: T): void;
  10864. /**
  10865. * Clears all the steps from the stage.
  10866. */
  10867. clear(): void;
  10868. }
  10869. }
  10870. declare module BABYLON {
  10871. interface Scene {
  10872. /** @hidden */
  10873. _pointerOverSprite: Nullable<Sprite>;
  10874. /** @hidden */
  10875. _pickedDownSprite: Nullable<Sprite>;
  10876. /** @hidden */
  10877. _tempSpritePickingRay: Nullable<Ray>;
  10878. /**
  10879. * All of the sprite managers added to this scene
  10880. * @see https://doc.babylonjs.com/babylon101/sprites
  10881. */
  10882. spriteManagers: Array<ISpriteManager>;
  10883. /**
  10884. * An event triggered when sprites rendering is about to start
  10885. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10886. */
  10887. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10888. /**
  10889. * An event triggered when sprites rendering is done
  10890. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10891. */
  10892. onAfterSpritesRenderingObservable: Observable<Scene>;
  10893. /** @hidden */
  10894. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10895. /** Launch a ray to try to pick a sprite in the scene
  10896. * @param x position on screen
  10897. * @param y position on screen
  10898. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10899. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10900. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10901. * @returns a PickingInfo
  10902. */
  10903. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10904. /** Use the given ray to pick a sprite in the scene
  10905. * @param ray The ray (in world space) to use to pick meshes
  10906. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10907. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10908. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10909. * @returns a PickingInfo
  10910. */
  10911. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10912. /** @hidden */
  10913. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10914. /** Launch a ray to try to pick sprites in the scene
  10915. * @param x position on screen
  10916. * @param y position on screen
  10917. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10918. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10919. * @returns a PickingInfo array
  10920. */
  10921. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10922. /** Use the given ray to pick sprites in the scene
  10923. * @param ray The ray (in world space) to use to pick meshes
  10924. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10925. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10926. * @returns a PickingInfo array
  10927. */
  10928. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10929. /**
  10930. * Force the sprite under the pointer
  10931. * @param sprite defines the sprite to use
  10932. */
  10933. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10934. /**
  10935. * Gets the sprite under the pointer
  10936. * @returns a Sprite or null if no sprite is under the pointer
  10937. */
  10938. getPointerOverSprite(): Nullable<Sprite>;
  10939. }
  10940. /**
  10941. * Defines the sprite scene component responsible to manage sprites
  10942. * in a given scene.
  10943. */
  10944. export class SpriteSceneComponent implements ISceneComponent {
  10945. /**
  10946. * The component name helpfull to identify the component in the list of scene components.
  10947. */
  10948. readonly name: string;
  10949. /**
  10950. * The scene the component belongs to.
  10951. */
  10952. scene: Scene;
  10953. /** @hidden */
  10954. private _spritePredicate;
  10955. /**
  10956. * Creates a new instance of the component for the given scene
  10957. * @param scene Defines the scene to register the component in
  10958. */
  10959. constructor(scene: Scene);
  10960. /**
  10961. * Registers the component in a given scene
  10962. */
  10963. register(): void;
  10964. /**
  10965. * Rebuilds the elements related to this component in case of
  10966. * context lost for instance.
  10967. */
  10968. rebuild(): void;
  10969. /**
  10970. * Disposes the component and the associated ressources.
  10971. */
  10972. dispose(): void;
  10973. private _pickSpriteButKeepRay;
  10974. private _pointerMove;
  10975. private _pointerDown;
  10976. private _pointerUp;
  10977. }
  10978. }
  10979. declare module BABYLON {
  10980. /** @hidden */
  10981. export var fogFragmentDeclaration: {
  10982. name: string;
  10983. shader: string;
  10984. };
  10985. }
  10986. declare module BABYLON {
  10987. /** @hidden */
  10988. export var fogFragment: {
  10989. name: string;
  10990. shader: string;
  10991. };
  10992. }
  10993. declare module BABYLON {
  10994. /** @hidden */
  10995. export var imageProcessingCompatibility: {
  10996. name: string;
  10997. shader: string;
  10998. };
  10999. }
  11000. declare module BABYLON {
  11001. /** @hidden */
  11002. export var spritesPixelShader: {
  11003. name: string;
  11004. shader: string;
  11005. };
  11006. }
  11007. declare module BABYLON {
  11008. /** @hidden */
  11009. export var fogVertexDeclaration: {
  11010. name: string;
  11011. shader: string;
  11012. };
  11013. }
  11014. declare module BABYLON {
  11015. /** @hidden */
  11016. export var spritesVertexShader: {
  11017. name: string;
  11018. shader: string;
  11019. };
  11020. }
  11021. declare module BABYLON {
  11022. /**
  11023. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11024. */
  11025. export interface ISpriteManager extends IDisposable {
  11026. /**
  11027. * Gets manager's name
  11028. */
  11029. name: string;
  11030. /**
  11031. * Restricts the camera to viewing objects with the same layerMask.
  11032. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11033. */
  11034. layerMask: number;
  11035. /**
  11036. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11037. */
  11038. isPickable: boolean;
  11039. /**
  11040. * Gets the hosting scene
  11041. */
  11042. scene: Scene;
  11043. /**
  11044. * Specifies the rendering group id for this mesh (0 by default)
  11045. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11046. */
  11047. renderingGroupId: number;
  11048. /**
  11049. * Defines the list of sprites managed by the manager.
  11050. */
  11051. sprites: Array<Sprite>;
  11052. /**
  11053. * Gets or sets the spritesheet texture
  11054. */
  11055. texture: Texture;
  11056. /** Defines the default width of a cell in the spritesheet */
  11057. cellWidth: number;
  11058. /** Defines the default height of a cell in the spritesheet */
  11059. cellHeight: number;
  11060. /**
  11061. * Tests the intersection of a sprite with a specific ray.
  11062. * @param ray The ray we are sending to test the collision
  11063. * @param camera The camera space we are sending rays in
  11064. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11065. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11066. * @returns picking info or null.
  11067. */
  11068. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11069. /**
  11070. * Intersects the sprites with a ray
  11071. * @param ray defines the ray to intersect with
  11072. * @param camera defines the current active camera
  11073. * @param predicate defines a predicate used to select candidate sprites
  11074. * @returns null if no hit or a PickingInfo array
  11075. */
  11076. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11077. /**
  11078. * Renders the list of sprites on screen.
  11079. */
  11080. render(): void;
  11081. }
  11082. /**
  11083. * Class used to manage multiple sprites on the same spritesheet
  11084. * @see https://doc.babylonjs.com/babylon101/sprites
  11085. */
  11086. export class SpriteManager implements ISpriteManager {
  11087. /** defines the manager's name */
  11088. name: string;
  11089. /** Define the Url to load snippets */
  11090. static SnippetUrl: string;
  11091. /** Snippet ID if the manager was created from the snippet server */
  11092. snippetId: string;
  11093. /** Gets the list of sprites */
  11094. sprites: Sprite[];
  11095. /** Gets or sets the rendering group id (0 by default) */
  11096. renderingGroupId: number;
  11097. /** Gets or sets camera layer mask */
  11098. layerMask: number;
  11099. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11100. fogEnabled: boolean;
  11101. /** Gets or sets a boolean indicating if the sprites are pickable */
  11102. isPickable: boolean;
  11103. /** Defines the default width of a cell in the spritesheet */
  11104. cellWidth: number;
  11105. /** Defines the default height of a cell in the spritesheet */
  11106. cellHeight: number;
  11107. /** Associative array from JSON sprite data file */
  11108. private _cellData;
  11109. /** Array of sprite names from JSON sprite data file */
  11110. private _spriteMap;
  11111. /** True when packed cell data from JSON file is ready*/
  11112. private _packedAndReady;
  11113. private _textureContent;
  11114. private _useInstancing;
  11115. /**
  11116. * An event triggered when the manager is disposed.
  11117. */
  11118. onDisposeObservable: Observable<SpriteManager>;
  11119. private _onDisposeObserver;
  11120. /**
  11121. * Callback called when the manager is disposed
  11122. */
  11123. set onDispose(callback: () => void);
  11124. private _capacity;
  11125. private _fromPacked;
  11126. private _spriteTexture;
  11127. private _epsilon;
  11128. private _scene;
  11129. private _vertexData;
  11130. private _buffer;
  11131. private _vertexBuffers;
  11132. private _spriteBuffer;
  11133. private _indexBuffer;
  11134. private _effectBase;
  11135. private _effectFog;
  11136. private _vertexBufferSize;
  11137. /**
  11138. * Gets or sets the unique id of the sprite
  11139. */
  11140. uniqueId: number;
  11141. /**
  11142. * Gets the array of sprites
  11143. */
  11144. get children(): Sprite[];
  11145. /**
  11146. * Gets the hosting scene
  11147. */
  11148. get scene(): Scene;
  11149. /**
  11150. * Gets the capacity of the manager
  11151. */
  11152. get capacity(): number;
  11153. /**
  11154. * Gets or sets the spritesheet texture
  11155. */
  11156. get texture(): Texture;
  11157. set texture(value: Texture);
  11158. private _blendMode;
  11159. /**
  11160. * Blend mode use to render the particle, it can be any of
  11161. * the static Constants.ALPHA_x properties provided in this class.
  11162. * Default value is Constants.ALPHA_COMBINE
  11163. */
  11164. get blendMode(): number;
  11165. set blendMode(blendMode: number);
  11166. /** Disables writing to the depth buffer when rendering the sprites.
  11167. * It can be handy to disable depth writing when using textures without alpha channel
  11168. * and setting some specific blend modes.
  11169. */
  11170. disableDepthWrite: boolean;
  11171. /**
  11172. * Creates a new sprite manager
  11173. * @param name defines the manager's name
  11174. * @param imgUrl defines the sprite sheet url
  11175. * @param capacity defines the maximum allowed number of sprites
  11176. * @param cellSize defines the size of a sprite cell
  11177. * @param scene defines the hosting scene
  11178. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11179. * @param samplingMode defines the smapling mode to use with spritesheet
  11180. * @param fromPacked set to false; do not alter
  11181. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11182. */
  11183. constructor(
  11184. /** defines the manager's name */
  11185. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11186. /**
  11187. * Returns the string "SpriteManager"
  11188. * @returns "SpriteManager"
  11189. */
  11190. getClassName(): string;
  11191. private _makePacked;
  11192. private _appendSpriteVertex;
  11193. private _checkTextureAlpha;
  11194. /**
  11195. * Intersects the sprites with a ray
  11196. * @param ray defines the ray to intersect with
  11197. * @param camera defines the current active camera
  11198. * @param predicate defines a predicate used to select candidate sprites
  11199. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11200. * @returns null if no hit or a PickingInfo
  11201. */
  11202. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11203. /**
  11204. * Intersects the sprites with a ray
  11205. * @param ray defines the ray to intersect with
  11206. * @param camera defines the current active camera
  11207. * @param predicate defines a predicate used to select candidate sprites
  11208. * @returns null if no hit or a PickingInfo array
  11209. */
  11210. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11211. /**
  11212. * Render all child sprites
  11213. */
  11214. render(): void;
  11215. /**
  11216. * Release associated resources
  11217. */
  11218. dispose(): void;
  11219. /**
  11220. * Serializes the sprite manager to a JSON object
  11221. * @param serializeTexture defines if the texture must be serialized as well
  11222. * @returns the JSON object
  11223. */
  11224. serialize(serializeTexture?: boolean): any;
  11225. /**
  11226. * Parses a JSON object to create a new sprite manager.
  11227. * @param parsedManager The JSON object to parse
  11228. * @param scene The scene to create the sprite managerin
  11229. * @param rootUrl The root url to use to load external dependencies like texture
  11230. * @returns the new sprite manager
  11231. */
  11232. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11233. /**
  11234. * Creates a sprite manager from a snippet saved in a remote file
  11235. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11236. * @param url defines the url to load from
  11237. * @param scene defines the hosting scene
  11238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11239. * @returns a promise that will resolve to the new sprite manager
  11240. */
  11241. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11242. /**
  11243. * Creates a sprite manager from a snippet saved by the sprite editor
  11244. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11245. * @param scene defines the hosting scene
  11246. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11247. * @returns a promise that will resolve to the new sprite manager
  11248. */
  11249. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11250. }
  11251. }
  11252. declare module BABYLON {
  11253. /** Interface used by value gradients (color, factor, ...) */
  11254. export interface IValueGradient {
  11255. /**
  11256. * Gets or sets the gradient value (between 0 and 1)
  11257. */
  11258. gradient: number;
  11259. }
  11260. /** Class used to store color4 gradient */
  11261. export class ColorGradient implements IValueGradient {
  11262. /**
  11263. * Gets or sets the gradient value (between 0 and 1)
  11264. */
  11265. gradient: number;
  11266. /**
  11267. * Gets or sets first associated color
  11268. */
  11269. color1: Color4;
  11270. /**
  11271. * Gets or sets second associated color
  11272. */
  11273. color2?: Color4 | undefined;
  11274. /**
  11275. * Creates a new color4 gradient
  11276. * @param gradient gets or sets the gradient value (between 0 and 1)
  11277. * @param color1 gets or sets first associated color
  11278. * @param color2 gets or sets first second color
  11279. */
  11280. constructor(
  11281. /**
  11282. * Gets or sets the gradient value (between 0 and 1)
  11283. */
  11284. gradient: number,
  11285. /**
  11286. * Gets or sets first associated color
  11287. */
  11288. color1: Color4,
  11289. /**
  11290. * Gets or sets second associated color
  11291. */
  11292. color2?: Color4 | undefined);
  11293. /**
  11294. * Will get a color picked randomly between color1 and color2.
  11295. * If color2 is undefined then color1 will be used
  11296. * @param result defines the target Color4 to store the result in
  11297. */
  11298. getColorToRef(result: Color4): void;
  11299. }
  11300. /** Class used to store color 3 gradient */
  11301. export class Color3Gradient implements IValueGradient {
  11302. /**
  11303. * Gets or sets the gradient value (between 0 and 1)
  11304. */
  11305. gradient: number;
  11306. /**
  11307. * Gets or sets the associated color
  11308. */
  11309. color: Color3;
  11310. /**
  11311. * Creates a new color3 gradient
  11312. * @param gradient gets or sets the gradient value (between 0 and 1)
  11313. * @param color gets or sets associated color
  11314. */
  11315. constructor(
  11316. /**
  11317. * Gets or sets the gradient value (between 0 and 1)
  11318. */
  11319. gradient: number,
  11320. /**
  11321. * Gets or sets the associated color
  11322. */
  11323. color: Color3);
  11324. }
  11325. /** Class used to store factor gradient */
  11326. export class FactorGradient implements IValueGradient {
  11327. /**
  11328. * Gets or sets the gradient value (between 0 and 1)
  11329. */
  11330. gradient: number;
  11331. /**
  11332. * Gets or sets first associated factor
  11333. */
  11334. factor1: number;
  11335. /**
  11336. * Gets or sets second associated factor
  11337. */
  11338. factor2?: number | undefined;
  11339. /**
  11340. * Creates a new factor gradient
  11341. * @param gradient gets or sets the gradient value (between 0 and 1)
  11342. * @param factor1 gets or sets first associated factor
  11343. * @param factor2 gets or sets second associated factor
  11344. */
  11345. constructor(
  11346. /**
  11347. * Gets or sets the gradient value (between 0 and 1)
  11348. */
  11349. gradient: number,
  11350. /**
  11351. * Gets or sets first associated factor
  11352. */
  11353. factor1: number,
  11354. /**
  11355. * Gets or sets second associated factor
  11356. */
  11357. factor2?: number | undefined);
  11358. /**
  11359. * Will get a number picked randomly between factor1 and factor2.
  11360. * If factor2 is undefined then factor1 will be used
  11361. * @returns the picked number
  11362. */
  11363. getFactor(): number;
  11364. }
  11365. /**
  11366. * Helper used to simplify some generic gradient tasks
  11367. */
  11368. export class GradientHelper {
  11369. /**
  11370. * Gets the current gradient from an array of IValueGradient
  11371. * @param ratio defines the current ratio to get
  11372. * @param gradients defines the array of IValueGradient
  11373. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11374. */
  11375. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11376. }
  11377. }
  11378. declare module BABYLON {
  11379. interface ThinEngine {
  11380. /**
  11381. * Creates a raw texture
  11382. * @param data defines the data to store in the texture
  11383. * @param width defines the width of the texture
  11384. * @param height defines the height of the texture
  11385. * @param format defines the format of the data
  11386. * @param generateMipMaps defines if the engine should generate the mip levels
  11387. * @param invertY defines if data must be stored with Y axis inverted
  11388. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11389. * @param compression defines the compression used (null by default)
  11390. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11391. * @returns the raw texture inside an InternalTexture
  11392. */
  11393. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11394. /**
  11395. * Update a raw texture
  11396. * @param texture defines the texture to update
  11397. * @param data defines the data to store in the texture
  11398. * @param format defines the format of the data
  11399. * @param invertY defines if data must be stored with Y axis inverted
  11400. */
  11401. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11402. /**
  11403. * Update a raw texture
  11404. * @param texture defines the texture to update
  11405. * @param data defines the data to store in the texture
  11406. * @param format defines the format of the data
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param compression defines the compression used (null by default)
  11409. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11410. */
  11411. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11412. /**
  11413. * Creates a new raw cube texture
  11414. * @param data defines the array of data to use to create each face
  11415. * @param size defines the size of the textures
  11416. * @param format defines the format of the data
  11417. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11418. * @param generateMipMaps defines if the engine should generate the mip levels
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11421. * @param compression defines the compression used (null by default)
  11422. * @returns the cube texture as an InternalTexture
  11423. */
  11424. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11425. /**
  11426. * Update a raw cube texture
  11427. * @param texture defines the texture to udpdate
  11428. * @param data defines the data to store
  11429. * @param format defines the data format
  11430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11431. * @param invertY defines if data must be stored with Y axis inverted
  11432. */
  11433. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11434. /**
  11435. * Update a raw cube texture
  11436. * @param texture defines the texture to udpdate
  11437. * @param data defines the data to store
  11438. * @param format defines the data format
  11439. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param compression defines the compression used (null by default)
  11442. */
  11443. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11444. /**
  11445. * Update a raw cube texture
  11446. * @param texture defines the texture to udpdate
  11447. * @param data defines the data to store
  11448. * @param format defines the data format
  11449. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @param compression defines the compression used (null by default)
  11452. * @param level defines which level of the texture to update
  11453. */
  11454. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11455. /**
  11456. * Creates a new raw cube texture from a specified url
  11457. * @param url defines the url where the data is located
  11458. * @param scene defines the current scene
  11459. * @param size defines the size of the textures
  11460. * @param format defines the format of the data
  11461. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11462. * @param noMipmap defines if the engine should avoid generating the mip levels
  11463. * @param callback defines a callback used to extract texture data from loaded data
  11464. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11465. * @param onLoad defines a callback called when texture is loaded
  11466. * @param onError defines a callback called if there is an error
  11467. * @returns the cube texture as an InternalTexture
  11468. */
  11469. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11470. /**
  11471. * Creates a new raw cube texture from a specified url
  11472. * @param url defines the url where the data is located
  11473. * @param scene defines the current scene
  11474. * @param size defines the size of the textures
  11475. * @param format defines the format of the data
  11476. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11477. * @param noMipmap defines if the engine should avoid generating the mip levels
  11478. * @param callback defines a callback used to extract texture data from loaded data
  11479. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11480. * @param onLoad defines a callback called when texture is loaded
  11481. * @param onError defines a callback called if there is an error
  11482. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @returns the cube texture as an InternalTexture
  11485. */
  11486. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11487. /**
  11488. * Creates a new raw 3D texture
  11489. * @param data defines the data used to create the texture
  11490. * @param width defines the width of the texture
  11491. * @param height defines the height of the texture
  11492. * @param depth defines the depth of the texture
  11493. * @param format defines the format of the texture
  11494. * @param generateMipMaps defines if the engine must generate mip levels
  11495. * @param invertY defines if data must be stored with Y axis inverted
  11496. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11497. * @param compression defines the compressed used (can be null)
  11498. * @param textureType defines the compressed used (can be null)
  11499. * @returns a new raw 3D texture (stored in an InternalTexture)
  11500. */
  11501. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11502. /**
  11503. * Update a raw 3D texture
  11504. * @param texture defines the texture to update
  11505. * @param data defines the data to store
  11506. * @param format defines the data format
  11507. * @param invertY defines if data must be stored with Y axis inverted
  11508. */
  11509. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11510. /**
  11511. * Update a raw 3D texture
  11512. * @param texture defines the texture to update
  11513. * @param data defines the data to store
  11514. * @param format defines the data format
  11515. * @param invertY defines if data must be stored with Y axis inverted
  11516. * @param compression defines the used compression (can be null)
  11517. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11518. */
  11519. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11520. /**
  11521. * Creates a new raw 2D array texture
  11522. * @param data defines the data used to create the texture
  11523. * @param width defines the width of the texture
  11524. * @param height defines the height of the texture
  11525. * @param depth defines the number of layers of the texture
  11526. * @param format defines the format of the texture
  11527. * @param generateMipMaps defines if the engine must generate mip levels
  11528. * @param invertY defines if data must be stored with Y axis inverted
  11529. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11530. * @param compression defines the compressed used (can be null)
  11531. * @param textureType defines the compressed used (can be null)
  11532. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11533. */
  11534. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11535. /**
  11536. * Update a raw 2D array texture
  11537. * @param texture defines the texture to update
  11538. * @param data defines the data to store
  11539. * @param format defines the data format
  11540. * @param invertY defines if data must be stored with Y axis inverted
  11541. */
  11542. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11543. /**
  11544. * Update a raw 2D array texture
  11545. * @param texture defines the texture to update
  11546. * @param data defines the data to store
  11547. * @param format defines the data format
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param compression defines the used compression (can be null)
  11550. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11551. */
  11552. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11553. }
  11554. }
  11555. declare module BABYLON {
  11556. /**
  11557. * Raw texture can help creating a texture directly from an array of data.
  11558. * This can be super useful if you either get the data from an uncompressed source or
  11559. * if you wish to create your texture pixel by pixel.
  11560. */
  11561. export class RawTexture extends Texture {
  11562. /**
  11563. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11564. */
  11565. format: number;
  11566. /**
  11567. * Instantiates a new RawTexture.
  11568. * Raw texture can help creating a texture directly from an array of data.
  11569. * This can be super useful if you either get the data from an uncompressed source or
  11570. * if you wish to create your texture pixel by pixel.
  11571. * @param data define the array of data to use to create the texture
  11572. * @param width define the width of the texture
  11573. * @param height define the height of the texture
  11574. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11575. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11576. * @param generateMipMaps define whether mip maps should be generated or not
  11577. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11578. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11579. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11580. */
  11581. constructor(data: ArrayBufferView, width: number, height: number,
  11582. /**
  11583. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11584. */
  11585. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11586. /**
  11587. * Updates the texture underlying data.
  11588. * @param data Define the new data of the texture
  11589. */
  11590. update(data: ArrayBufferView): void;
  11591. /**
  11592. * Creates a luminance texture from some data.
  11593. * @param data Define the texture data
  11594. * @param width Define the width of the texture
  11595. * @param height Define the height of the texture
  11596. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11597. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11598. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11599. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11600. * @returns the luminance texture
  11601. */
  11602. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11603. /**
  11604. * Creates a luminance alpha texture from some data.
  11605. * @param data Define the texture data
  11606. * @param width Define the width of the texture
  11607. * @param height Define the height of the texture
  11608. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11609. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11610. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11611. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11612. * @returns the luminance alpha texture
  11613. */
  11614. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11615. /**
  11616. * Creates an alpha texture from some data.
  11617. * @param data Define the texture data
  11618. * @param width Define the width of the texture
  11619. * @param height Define the height of the texture
  11620. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11621. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11622. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11623. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11624. * @returns the alpha texture
  11625. */
  11626. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11627. /**
  11628. * Creates a RGB texture from some data.
  11629. * @param data Define the texture data
  11630. * @param width Define the width of the texture
  11631. * @param height Define the height of the texture
  11632. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11633. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11636. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11637. * @returns the RGB alpha texture
  11638. */
  11639. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11640. /**
  11641. * Creates a RGBA texture from some data.
  11642. * @param data Define the texture data
  11643. * @param width Define the width of the texture
  11644. * @param height Define the height of the texture
  11645. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11646. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11647. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11648. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11649. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11650. * @returns the RGBA texture
  11651. */
  11652. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11653. /**
  11654. * Creates a R texture from some data.
  11655. * @param data Define the texture data
  11656. * @param width Define the width of the texture
  11657. * @param height Define the height of the texture
  11658. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11659. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11662. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11663. * @returns the R texture
  11664. */
  11665. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11666. }
  11667. }
  11668. declare module BABYLON {
  11669. interface ThinEngine {
  11670. /**
  11671. * Update a dynamic index buffer
  11672. * @param indexBuffer defines the target index buffer
  11673. * @param indices defines the data to update
  11674. * @param offset defines the offset in the target index buffer where update should start
  11675. */
  11676. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11677. /**
  11678. * Updates a dynamic vertex buffer.
  11679. * @param vertexBuffer the vertex buffer to update
  11680. * @param data the data used to update the vertex buffer
  11681. * @param byteOffset the byte offset of the data
  11682. * @param byteLength the byte length of the data
  11683. */
  11684. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11685. }
  11686. }
  11687. declare module BABYLON {
  11688. interface AbstractScene {
  11689. /**
  11690. * The list of procedural textures added to the scene
  11691. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11692. */
  11693. proceduralTextures: Array<ProceduralTexture>;
  11694. }
  11695. /**
  11696. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11697. * in a given scene.
  11698. */
  11699. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11700. /**
  11701. * The component name helpfull to identify the component in the list of scene components.
  11702. */
  11703. readonly name: string;
  11704. /**
  11705. * The scene the component belongs to.
  11706. */
  11707. scene: Scene;
  11708. /**
  11709. * Creates a new instance of the component for the given scene
  11710. * @param scene Defines the scene to register the component in
  11711. */
  11712. constructor(scene: Scene);
  11713. /**
  11714. * Registers the component in a given scene
  11715. */
  11716. register(): void;
  11717. /**
  11718. * Rebuilds the elements related to this component in case of
  11719. * context lost for instance.
  11720. */
  11721. rebuild(): void;
  11722. /**
  11723. * Disposes the component and the associated ressources.
  11724. */
  11725. dispose(): void;
  11726. private _beforeClear;
  11727. }
  11728. }
  11729. declare module BABYLON {
  11730. interface ThinEngine {
  11731. /**
  11732. * Creates a new render target cube texture
  11733. * @param size defines the size of the texture
  11734. * @param options defines the options used to create the texture
  11735. * @returns a new render target cube texture stored in an InternalTexture
  11736. */
  11737. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11738. }
  11739. }
  11740. declare module BABYLON {
  11741. /** @hidden */
  11742. export var proceduralVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module BABYLON {
  11748. /**
  11749. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11750. * This is the base class of any Procedural texture and contains most of the shareable code.
  11751. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11752. */
  11753. export class ProceduralTexture extends Texture {
  11754. /**
  11755. * Define if the texture is enabled or not (disabled texture will not render)
  11756. */
  11757. isEnabled: boolean;
  11758. /**
  11759. * Define if the texture must be cleared before rendering (default is true)
  11760. */
  11761. autoClear: boolean;
  11762. /**
  11763. * Callback called when the texture is generated
  11764. */
  11765. onGenerated: () => void;
  11766. /**
  11767. * Event raised when the texture is generated
  11768. */
  11769. onGeneratedObservable: Observable<ProceduralTexture>;
  11770. /**
  11771. * Event raised before the texture is generated
  11772. */
  11773. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11774. /**
  11775. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11776. */
  11777. nodeMaterialSource: Nullable<NodeMaterial>;
  11778. /** @hidden */
  11779. _generateMipMaps: boolean;
  11780. /** @hidden **/
  11781. _effect: Effect;
  11782. /** @hidden */
  11783. _textures: {
  11784. [key: string]: Texture;
  11785. };
  11786. /** @hidden */
  11787. protected _fallbackTexture: Nullable<Texture>;
  11788. private _size;
  11789. private _currentRefreshId;
  11790. private _frameId;
  11791. private _refreshRate;
  11792. private _vertexBuffers;
  11793. private _indexBuffer;
  11794. private _uniforms;
  11795. private _samplers;
  11796. private _fragment;
  11797. private _floats;
  11798. private _ints;
  11799. private _floatsArrays;
  11800. private _colors3;
  11801. private _colors4;
  11802. private _vectors2;
  11803. private _vectors3;
  11804. private _matrices;
  11805. private _fallbackTextureUsed;
  11806. private _fullEngine;
  11807. private _cachedDefines;
  11808. private _contentUpdateId;
  11809. private _contentData;
  11810. /**
  11811. * Instantiates a new procedural texture.
  11812. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11813. * This is the base class of any Procedural texture and contains most of the shareable code.
  11814. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11815. * @param name Define the name of the texture
  11816. * @param size Define the size of the texture to create
  11817. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11818. * @param scene Define the scene the texture belongs to
  11819. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11820. * @param generateMipMaps Define if the texture should creates mip maps or not
  11821. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11822. * @param textureType The FBO internal texture type
  11823. */
  11824. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11825. /**
  11826. * The effect that is created when initializing the post process.
  11827. * @returns The created effect corresponding the the postprocess.
  11828. */
  11829. getEffect(): Effect;
  11830. /**
  11831. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11832. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11833. */
  11834. getContent(): Nullable<ArrayBufferView>;
  11835. private _createIndexBuffer;
  11836. /** @hidden */
  11837. _rebuild(): void;
  11838. /**
  11839. * Resets the texture in order to recreate its associated resources.
  11840. * This can be called in case of context loss
  11841. */
  11842. reset(): void;
  11843. protected _getDefines(): string;
  11844. /**
  11845. * Is the texture ready to be used ? (rendered at least once)
  11846. * @returns true if ready, otherwise, false.
  11847. */
  11848. isReady(): boolean;
  11849. /**
  11850. * Resets the refresh counter of the texture and start bak from scratch.
  11851. * Could be useful to regenerate the texture if it is setup to render only once.
  11852. */
  11853. resetRefreshCounter(): void;
  11854. /**
  11855. * Set the fragment shader to use in order to render the texture.
  11856. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11857. */
  11858. setFragment(fragment: any): void;
  11859. /**
  11860. * Define the refresh rate of the texture or the rendering frequency.
  11861. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11862. */
  11863. get refreshRate(): number;
  11864. set refreshRate(value: number);
  11865. /** @hidden */
  11866. _shouldRender(): boolean;
  11867. /**
  11868. * Get the size the texture is rendering at.
  11869. * @returns the size (on cube texture it is always squared)
  11870. */
  11871. getRenderSize(): RenderTargetTextureSize;
  11872. /**
  11873. * Resize the texture to new value.
  11874. * @param size Define the new size the texture should have
  11875. * @param generateMipMaps Define whether the new texture should create mip maps
  11876. */
  11877. resize(size: number, generateMipMaps: boolean): void;
  11878. private _checkUniform;
  11879. /**
  11880. * Set a texture in the shader program used to render.
  11881. * @param name Define the name of the uniform samplers as defined in the shader
  11882. * @param texture Define the texture to bind to this sampler
  11883. * @return the texture itself allowing "fluent" like uniform updates
  11884. */
  11885. setTexture(name: string, texture: Texture): ProceduralTexture;
  11886. /**
  11887. * Set a float in the shader.
  11888. * @param name Define the name of the uniform as defined in the shader
  11889. * @param value Define the value to give to the uniform
  11890. * @return the texture itself allowing "fluent" like uniform updates
  11891. */
  11892. setFloat(name: string, value: number): ProceduralTexture;
  11893. /**
  11894. * Set a int in the shader.
  11895. * @param name Define the name of the uniform as defined in the shader
  11896. * @param value Define the value to give to the uniform
  11897. * @return the texture itself allowing "fluent" like uniform updates
  11898. */
  11899. setInt(name: string, value: number): ProceduralTexture;
  11900. /**
  11901. * Set an array of floats in the shader.
  11902. * @param name Define the name of the uniform as defined in the shader
  11903. * @param value Define the value to give to the uniform
  11904. * @return the texture itself allowing "fluent" like uniform updates
  11905. */
  11906. setFloats(name: string, value: number[]): ProceduralTexture;
  11907. /**
  11908. * Set a vec3 in the shader from a Color3.
  11909. * @param name Define the name of the uniform as defined in the shader
  11910. * @param value Define the value to give to the uniform
  11911. * @return the texture itself allowing "fluent" like uniform updates
  11912. */
  11913. setColor3(name: string, value: Color3): ProceduralTexture;
  11914. /**
  11915. * Set a vec4 in the shader from a Color4.
  11916. * @param name Define the name of the uniform as defined in the shader
  11917. * @param value Define the value to give to the uniform
  11918. * @return the texture itself allowing "fluent" like uniform updates
  11919. */
  11920. setColor4(name: string, value: Color4): ProceduralTexture;
  11921. /**
  11922. * Set a vec2 in the shader from a Vector2.
  11923. * @param name Define the name of the uniform as defined in the shader
  11924. * @param value Define the value to give to the uniform
  11925. * @return the texture itself allowing "fluent" like uniform updates
  11926. */
  11927. setVector2(name: string, value: Vector2): ProceduralTexture;
  11928. /**
  11929. * Set a vec3 in the shader from a Vector3.
  11930. * @param name Define the name of the uniform as defined in the shader
  11931. * @param value Define the value to give to the uniform
  11932. * @return the texture itself allowing "fluent" like uniform updates
  11933. */
  11934. setVector3(name: string, value: Vector3): ProceduralTexture;
  11935. /**
  11936. * Set a mat4 in the shader from a MAtrix.
  11937. * @param name Define the name of the uniform as defined in the shader
  11938. * @param value Define the value to give to the uniform
  11939. * @return the texture itself allowing "fluent" like uniform updates
  11940. */
  11941. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11942. /**
  11943. * Render the texture to its associated render target.
  11944. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11945. */
  11946. render(useCameraPostProcess?: boolean): void;
  11947. /**
  11948. * Clone the texture.
  11949. * @returns the cloned texture
  11950. */
  11951. clone(): ProceduralTexture;
  11952. /**
  11953. * Dispose the texture and release its asoociated resources.
  11954. */
  11955. dispose(): void;
  11956. }
  11957. }
  11958. declare module BABYLON {
  11959. /**
  11960. * This represents the base class for particle system in Babylon.
  11961. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11962. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11963. * @example https://doc.babylonjs.com/babylon101/particles
  11964. */
  11965. export class BaseParticleSystem {
  11966. /**
  11967. * Source color is added to the destination color without alpha affecting the result
  11968. */
  11969. static BLENDMODE_ONEONE: number;
  11970. /**
  11971. * Blend current color and particle color using particle’s alpha
  11972. */
  11973. static BLENDMODE_STANDARD: number;
  11974. /**
  11975. * Add current color and particle color multiplied by particle’s alpha
  11976. */
  11977. static BLENDMODE_ADD: number;
  11978. /**
  11979. * Multiply current color with particle color
  11980. */
  11981. static BLENDMODE_MULTIPLY: number;
  11982. /**
  11983. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11984. */
  11985. static BLENDMODE_MULTIPLYADD: number;
  11986. /**
  11987. * List of animations used by the particle system.
  11988. */
  11989. animations: Animation[];
  11990. /**
  11991. * Gets or sets the unique id of the particle system
  11992. */
  11993. uniqueId: number;
  11994. /**
  11995. * The id of the Particle system.
  11996. */
  11997. id: string;
  11998. /**
  11999. * The friendly name of the Particle system.
  12000. */
  12001. name: string;
  12002. /**
  12003. * Snippet ID if the particle system was created from the snippet server
  12004. */
  12005. snippetId: string;
  12006. /**
  12007. * The rendering group used by the Particle system to chose when to render.
  12008. */
  12009. renderingGroupId: number;
  12010. /**
  12011. * The emitter represents the Mesh or position we are attaching the particle system to.
  12012. */
  12013. emitter: Nullable<AbstractMesh | Vector3>;
  12014. /**
  12015. * The maximum number of particles to emit per frame
  12016. */
  12017. emitRate: number;
  12018. /**
  12019. * If you want to launch only a few particles at once, that can be done, as well.
  12020. */
  12021. manualEmitCount: number;
  12022. /**
  12023. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12024. */
  12025. updateSpeed: number;
  12026. /**
  12027. * The amount of time the particle system is running (depends of the overall update speed).
  12028. */
  12029. targetStopDuration: number;
  12030. /**
  12031. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12032. */
  12033. disposeOnStop: boolean;
  12034. /**
  12035. * Minimum power of emitting particles.
  12036. */
  12037. minEmitPower: number;
  12038. /**
  12039. * Maximum power of emitting particles.
  12040. */
  12041. maxEmitPower: number;
  12042. /**
  12043. * Minimum life time of emitting particles.
  12044. */
  12045. minLifeTime: number;
  12046. /**
  12047. * Maximum life time of emitting particles.
  12048. */
  12049. maxLifeTime: number;
  12050. /**
  12051. * Minimum Size of emitting particles.
  12052. */
  12053. minSize: number;
  12054. /**
  12055. * Maximum Size of emitting particles.
  12056. */
  12057. maxSize: number;
  12058. /**
  12059. * Minimum scale of emitting particles on X axis.
  12060. */
  12061. minScaleX: number;
  12062. /**
  12063. * Maximum scale of emitting particles on X axis.
  12064. */
  12065. maxScaleX: number;
  12066. /**
  12067. * Minimum scale of emitting particles on Y axis.
  12068. */
  12069. minScaleY: number;
  12070. /**
  12071. * Maximum scale of emitting particles on Y axis.
  12072. */
  12073. maxScaleY: number;
  12074. /**
  12075. * Gets or sets the minimal initial rotation in radians.
  12076. */
  12077. minInitialRotation: number;
  12078. /**
  12079. * Gets or sets the maximal initial rotation in radians.
  12080. */
  12081. maxInitialRotation: number;
  12082. /**
  12083. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12084. */
  12085. minAngularSpeed: number;
  12086. /**
  12087. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12088. */
  12089. maxAngularSpeed: number;
  12090. /**
  12091. * The texture used to render each particle. (this can be a spritesheet)
  12092. */
  12093. particleTexture: Nullable<BaseTexture>;
  12094. /**
  12095. * The layer mask we are rendering the particles through.
  12096. */
  12097. layerMask: number;
  12098. /**
  12099. * This can help using your own shader to render the particle system.
  12100. * The according effect will be created
  12101. */
  12102. customShader: any;
  12103. /**
  12104. * By default particle system starts as soon as they are created. This prevents the
  12105. * automatic start to happen and let you decide when to start emitting particles.
  12106. */
  12107. preventAutoStart: boolean;
  12108. private _noiseTexture;
  12109. /**
  12110. * Gets or sets a texture used to add random noise to particle positions
  12111. */
  12112. get noiseTexture(): Nullable<ProceduralTexture>;
  12113. set noiseTexture(value: Nullable<ProceduralTexture>);
  12114. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12115. noiseStrength: Vector3;
  12116. /**
  12117. * Callback triggered when the particle animation is ending.
  12118. */
  12119. onAnimationEnd: Nullable<() => void>;
  12120. /**
  12121. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12122. */
  12123. blendMode: number;
  12124. /**
  12125. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12126. * to override the particles.
  12127. */
  12128. forceDepthWrite: boolean;
  12129. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12130. preWarmCycles: number;
  12131. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12132. preWarmStepOffset: number;
  12133. /**
  12134. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12135. */
  12136. spriteCellChangeSpeed: number;
  12137. /**
  12138. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12139. */
  12140. startSpriteCellID: number;
  12141. /**
  12142. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12143. */
  12144. endSpriteCellID: number;
  12145. /**
  12146. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12147. */
  12148. spriteCellWidth: number;
  12149. /**
  12150. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12151. */
  12152. spriteCellHeight: number;
  12153. /**
  12154. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12155. */
  12156. spriteRandomStartCell: boolean;
  12157. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12158. translationPivot: Vector2;
  12159. /** @hidden */
  12160. protected _isAnimationSheetEnabled: boolean;
  12161. /**
  12162. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12163. */
  12164. beginAnimationOnStart: boolean;
  12165. /**
  12166. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12167. */
  12168. beginAnimationFrom: number;
  12169. /**
  12170. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12171. */
  12172. beginAnimationTo: number;
  12173. /**
  12174. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12175. */
  12176. beginAnimationLoop: boolean;
  12177. /**
  12178. * Gets or sets a world offset applied to all particles
  12179. */
  12180. worldOffset: Vector3;
  12181. /**
  12182. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12183. */
  12184. get isAnimationSheetEnabled(): boolean;
  12185. set isAnimationSheetEnabled(value: boolean);
  12186. /**
  12187. * Get hosting scene
  12188. * @returns the scene
  12189. */
  12190. getScene(): Nullable<Scene>;
  12191. /**
  12192. * You can use gravity if you want to give an orientation to your particles.
  12193. */
  12194. gravity: Vector3;
  12195. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12196. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12197. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12198. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12199. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12200. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12201. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12202. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12203. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12204. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12205. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12206. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12207. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12208. /**
  12209. * Defines the delay in milliseconds before starting the system (0 by default)
  12210. */
  12211. startDelay: number;
  12212. /**
  12213. * Gets the current list of drag gradients.
  12214. * You must use addDragGradient and removeDragGradient to udpate this list
  12215. * @returns the list of drag gradients
  12216. */
  12217. getDragGradients(): Nullable<Array<FactorGradient>>;
  12218. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12219. limitVelocityDamping: number;
  12220. /**
  12221. * Gets the current list of limit velocity gradients.
  12222. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12223. * @returns the list of limit velocity gradients
  12224. */
  12225. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12226. /**
  12227. * Gets the current list of color gradients.
  12228. * You must use addColorGradient and removeColorGradient to udpate this list
  12229. * @returns the list of color gradients
  12230. */
  12231. getColorGradients(): Nullable<Array<ColorGradient>>;
  12232. /**
  12233. * Gets the current list of size gradients.
  12234. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12235. * @returns the list of size gradients
  12236. */
  12237. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12238. /**
  12239. * Gets the current list of color remap gradients.
  12240. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12241. * @returns the list of color remap gradients
  12242. */
  12243. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12244. /**
  12245. * Gets the current list of alpha remap gradients.
  12246. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12247. * @returns the list of alpha remap gradients
  12248. */
  12249. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12250. /**
  12251. * Gets the current list of life time gradients.
  12252. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12253. * @returns the list of life time gradients
  12254. */
  12255. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12256. /**
  12257. * Gets the current list of angular speed gradients.
  12258. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12259. * @returns the list of angular speed gradients
  12260. */
  12261. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12262. /**
  12263. * Gets the current list of velocity gradients.
  12264. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12265. * @returns the list of velocity gradients
  12266. */
  12267. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12268. /**
  12269. * Gets the current list of start size gradients.
  12270. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12271. * @returns the list of start size gradients
  12272. */
  12273. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12274. /**
  12275. * Gets the current list of emit rate gradients.
  12276. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12277. * @returns the list of emit rate gradients
  12278. */
  12279. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12280. /**
  12281. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12283. */
  12284. get direction1(): Vector3;
  12285. set direction1(value: Vector3);
  12286. /**
  12287. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12288. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12289. */
  12290. get direction2(): Vector3;
  12291. set direction2(value: Vector3);
  12292. /**
  12293. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12295. */
  12296. get minEmitBox(): Vector3;
  12297. set minEmitBox(value: Vector3);
  12298. /**
  12299. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12300. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12301. */
  12302. get maxEmitBox(): Vector3;
  12303. set maxEmitBox(value: Vector3);
  12304. /**
  12305. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12306. */
  12307. color1: Color4;
  12308. /**
  12309. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12310. */
  12311. color2: Color4;
  12312. /**
  12313. * Color the particle will have at the end of its lifetime
  12314. */
  12315. colorDead: Color4;
  12316. /**
  12317. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12318. */
  12319. textureMask: Color4;
  12320. /**
  12321. * The particle emitter type defines the emitter used by the particle system.
  12322. * It can be for example box, sphere, or cone...
  12323. */
  12324. particleEmitterType: IParticleEmitterType;
  12325. /** @hidden */
  12326. _isSubEmitter: boolean;
  12327. /**
  12328. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12329. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12330. */
  12331. billboardMode: number;
  12332. protected _isBillboardBased: boolean;
  12333. /**
  12334. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12335. */
  12336. get isBillboardBased(): boolean;
  12337. set isBillboardBased(value: boolean);
  12338. /**
  12339. * The scene the particle system belongs to.
  12340. */
  12341. protected _scene: Nullable<Scene>;
  12342. /**
  12343. * The engine the particle system belongs to.
  12344. */
  12345. protected _engine: ThinEngine;
  12346. /**
  12347. * Local cache of defines for image processing.
  12348. */
  12349. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12350. /**
  12351. * Default configuration related to image processing available in the standard Material.
  12352. */
  12353. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12354. /**
  12355. * Gets the image processing configuration used either in this material.
  12356. */
  12357. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12358. /**
  12359. * Sets the Default image processing configuration used either in the this material.
  12360. *
  12361. * If sets to null, the scene one is in use.
  12362. */
  12363. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12364. /**
  12365. * Attaches a new image processing configuration to the Standard Material.
  12366. * @param configuration
  12367. */
  12368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12369. /** @hidden */
  12370. protected _reset(): void;
  12371. /** @hidden */
  12372. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12373. /**
  12374. * Instantiates a particle system.
  12375. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12376. * @param name The name of the particle system
  12377. */
  12378. constructor(name: string);
  12379. /**
  12380. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12383. * @returns the emitter
  12384. */
  12385. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12386. /**
  12387. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12388. * @param radius The radius of the hemisphere to emit from
  12389. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12390. * @returns the emitter
  12391. */
  12392. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12393. /**
  12394. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12395. * @param radius The radius of the sphere to emit from
  12396. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12397. * @returns the emitter
  12398. */
  12399. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12400. /**
  12401. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12402. * @param radius The radius of the sphere to emit from
  12403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12405. * @returns the emitter
  12406. */
  12407. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12408. /**
  12409. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12410. * @param radius The radius of the emission cylinder
  12411. * @param height The height of the emission cylinder
  12412. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12413. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12414. * @returns the emitter
  12415. */
  12416. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12417. /**
  12418. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12419. * @param radius The radius of the cylinder to emit from
  12420. * @param height The height of the emission cylinder
  12421. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12424. * @returns the emitter
  12425. */
  12426. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12427. /**
  12428. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12429. * @param radius The radius of the cone to emit from
  12430. * @param angle The base angle of the cone
  12431. * @returns the emitter
  12432. */
  12433. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12434. /**
  12435. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12438. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12439. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12440. * @returns the emitter
  12441. */
  12442. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12443. }
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * Type of sub emitter
  12448. */
  12449. export enum SubEmitterType {
  12450. /**
  12451. * Attached to the particle over it's lifetime
  12452. */
  12453. ATTACHED = 0,
  12454. /**
  12455. * Created when the particle dies
  12456. */
  12457. END = 1
  12458. }
  12459. /**
  12460. * Sub emitter class used to emit particles from an existing particle
  12461. */
  12462. export class SubEmitter {
  12463. /**
  12464. * the particle system to be used by the sub emitter
  12465. */
  12466. particleSystem: ParticleSystem;
  12467. /**
  12468. * Type of the submitter (Default: END)
  12469. */
  12470. type: SubEmitterType;
  12471. /**
  12472. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12473. * Note: This only is supported when using an emitter of type Mesh
  12474. */
  12475. inheritDirection: boolean;
  12476. /**
  12477. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12478. */
  12479. inheritedVelocityAmount: number;
  12480. /**
  12481. * Creates a sub emitter
  12482. * @param particleSystem the particle system to be used by the sub emitter
  12483. */
  12484. constructor(
  12485. /**
  12486. * the particle system to be used by the sub emitter
  12487. */
  12488. particleSystem: ParticleSystem);
  12489. /**
  12490. * Clones the sub emitter
  12491. * @returns the cloned sub emitter
  12492. */
  12493. clone(): SubEmitter;
  12494. /**
  12495. * Serialize current object to a JSON object
  12496. * @returns the serialized object
  12497. */
  12498. serialize(): any;
  12499. /** @hidden */
  12500. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12501. /**
  12502. * Creates a new SubEmitter from a serialized JSON version
  12503. * @param serializationObject defines the JSON object to read from
  12504. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12505. * @param rootUrl defines the rootUrl for data loading
  12506. * @returns a new SubEmitter
  12507. */
  12508. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12509. /** Release associated resources */
  12510. dispose(): void;
  12511. }
  12512. }
  12513. declare module BABYLON {
  12514. /** @hidden */
  12515. export var imageProcessingDeclaration: {
  12516. name: string;
  12517. shader: string;
  12518. };
  12519. }
  12520. declare module BABYLON {
  12521. /** @hidden */
  12522. export var imageProcessingFunctions: {
  12523. name: string;
  12524. shader: string;
  12525. };
  12526. }
  12527. declare module BABYLON {
  12528. /** @hidden */
  12529. export var particlesPixelShader: {
  12530. name: string;
  12531. shader: string;
  12532. };
  12533. }
  12534. declare module BABYLON {
  12535. /** @hidden */
  12536. export var particlesVertexShader: {
  12537. name: string;
  12538. shader: string;
  12539. };
  12540. }
  12541. declare module BABYLON {
  12542. /**
  12543. * Interface used to define entities containing multiple clip planes
  12544. */
  12545. export interface IClipPlanesHolder {
  12546. /**
  12547. * Gets or sets the active clipplane 1
  12548. */
  12549. clipPlane: Nullable<Plane>;
  12550. /**
  12551. * Gets or sets the active clipplane 2
  12552. */
  12553. clipPlane2: Nullable<Plane>;
  12554. /**
  12555. * Gets or sets the active clipplane 3
  12556. */
  12557. clipPlane3: Nullable<Plane>;
  12558. /**
  12559. * Gets or sets the active clipplane 4
  12560. */
  12561. clipPlane4: Nullable<Plane>;
  12562. /**
  12563. * Gets or sets the active clipplane 5
  12564. */
  12565. clipPlane5: Nullable<Plane>;
  12566. /**
  12567. * Gets or sets the active clipplane 6
  12568. */
  12569. clipPlane6: Nullable<Plane>;
  12570. }
  12571. }
  12572. declare module BABYLON {
  12573. /**
  12574. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12575. *
  12576. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12577. *
  12578. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12579. */
  12580. export class ThinMaterialHelper {
  12581. /**
  12582. * Binds the clip plane information from the holder to the effect.
  12583. * @param effect The effect we are binding the data to
  12584. * @param holder The entity containing the clip plane information
  12585. */
  12586. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. interface ThinEngine {
  12591. /**
  12592. * Sets alpha constants used by some alpha blending modes
  12593. * @param r defines the red component
  12594. * @param g defines the green component
  12595. * @param b defines the blue component
  12596. * @param a defines the alpha component
  12597. */
  12598. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12599. /**
  12600. * Sets the current alpha mode
  12601. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12602. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12603. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12604. */
  12605. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12606. /**
  12607. * Gets the current alpha mode
  12608. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12609. * @returns the current alpha mode
  12610. */
  12611. getAlphaMode(): number;
  12612. /**
  12613. * Sets the current alpha equation
  12614. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12615. */
  12616. setAlphaEquation(equation: number): void;
  12617. /**
  12618. * Gets the current alpha equation.
  12619. * @returns the current alpha equation
  12620. */
  12621. getAlphaEquation(): number;
  12622. }
  12623. }
  12624. declare module BABYLON {
  12625. /**
  12626. * This represents a particle system in Babylon.
  12627. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12628. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12629. * @example https://doc.babylonjs.com/babylon101/particles
  12630. */
  12631. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12632. /**
  12633. * Billboard mode will only apply to Y axis
  12634. */
  12635. static readonly BILLBOARDMODE_Y: number;
  12636. /**
  12637. * Billboard mode will apply to all axes
  12638. */
  12639. static readonly BILLBOARDMODE_ALL: number;
  12640. /**
  12641. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12642. */
  12643. static readonly BILLBOARDMODE_STRETCHED: number;
  12644. /**
  12645. * This function can be defined to provide custom update for active particles.
  12646. * This function will be called instead of regular update (age, position, color, etc.).
  12647. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12648. */
  12649. updateFunction: (particles: Particle[]) => void;
  12650. private _emitterWorldMatrix;
  12651. /**
  12652. * This function can be defined to specify initial direction for every new particle.
  12653. * It by default use the emitterType defined function
  12654. */
  12655. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12656. /**
  12657. * This function can be defined to specify initial position for every new particle.
  12658. * It by default use the emitterType defined function
  12659. */
  12660. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12661. /**
  12662. * @hidden
  12663. */
  12664. _inheritedVelocityOffset: Vector3;
  12665. /**
  12666. * An event triggered when the system is disposed
  12667. */
  12668. onDisposeObservable: Observable<IParticleSystem>;
  12669. /**
  12670. * An event triggered when the system is stopped
  12671. */
  12672. onStoppedObservable: Observable<IParticleSystem>;
  12673. private _onDisposeObserver;
  12674. /**
  12675. * Sets a callback that will be triggered when the system is disposed
  12676. */
  12677. set onDispose(callback: () => void);
  12678. private _particles;
  12679. private _epsilon;
  12680. private _capacity;
  12681. private _stockParticles;
  12682. private _newPartsExcess;
  12683. private _vertexData;
  12684. private _vertexBuffer;
  12685. private _vertexBuffers;
  12686. private _spriteBuffer;
  12687. private _indexBuffer;
  12688. private _effect;
  12689. private _customEffect;
  12690. private _cachedDefines;
  12691. private _scaledColorStep;
  12692. private _colorDiff;
  12693. private _scaledDirection;
  12694. private _scaledGravity;
  12695. private _currentRenderId;
  12696. private _alive;
  12697. private _useInstancing;
  12698. private _started;
  12699. private _stopped;
  12700. private _actualFrame;
  12701. private _scaledUpdateSpeed;
  12702. private _vertexBufferSize;
  12703. /** @hidden */
  12704. _currentEmitRateGradient: Nullable<FactorGradient>;
  12705. /** @hidden */
  12706. _currentEmitRate1: number;
  12707. /** @hidden */
  12708. _currentEmitRate2: number;
  12709. /** @hidden */
  12710. _currentStartSizeGradient: Nullable<FactorGradient>;
  12711. /** @hidden */
  12712. _currentStartSize1: number;
  12713. /** @hidden */
  12714. _currentStartSize2: number;
  12715. private readonly _rawTextureWidth;
  12716. private _rampGradientsTexture;
  12717. private _useRampGradients;
  12718. /** Gets or sets a matrix to use to compute projection */
  12719. defaultProjectionMatrix: Matrix;
  12720. /** Gets or sets a matrix to use to compute view */
  12721. defaultViewMatrix: Matrix;
  12722. /** Gets or sets a boolean indicating that ramp gradients must be used
  12723. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12724. */
  12725. get useRampGradients(): boolean;
  12726. set useRampGradients(value: boolean);
  12727. /**
  12728. * 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.
  12729. * 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: [])
  12730. */
  12731. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12732. private _subEmitters;
  12733. /**
  12734. * @hidden
  12735. * If the particle systems emitter should be disposed when the particle system is disposed
  12736. */
  12737. _disposeEmitterOnDispose: boolean;
  12738. /**
  12739. * The current active Sub-systems, this property is used by the root particle system only.
  12740. */
  12741. activeSubSystems: Array<ParticleSystem>;
  12742. /**
  12743. * Specifies if the particles are updated in emitter local space or world space
  12744. */
  12745. isLocal: boolean;
  12746. private _rootParticleSystem;
  12747. /**
  12748. * Gets the current list of active particles
  12749. */
  12750. get particles(): Particle[];
  12751. /**
  12752. * Gets the number of particles active at the same time.
  12753. * @returns The number of active particles.
  12754. */
  12755. getActiveCount(): number;
  12756. /**
  12757. * Returns the string "ParticleSystem"
  12758. * @returns a string containing the class name
  12759. */
  12760. getClassName(): string;
  12761. /**
  12762. * Gets a boolean indicating that the system is stopping
  12763. * @returns true if the system is currently stopping
  12764. */
  12765. isStopping(): boolean;
  12766. /**
  12767. * Gets the custom effect used to render the particles
  12768. * @param blendMode Blend mode for which the effect should be retrieved
  12769. * @returns The effect
  12770. */
  12771. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12772. /**
  12773. * Sets the custom effect used to render the particles
  12774. * @param effect The effect to set
  12775. * @param blendMode Blend mode for which the effect should be set
  12776. */
  12777. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12778. /** @hidden */
  12779. private _onBeforeDrawParticlesObservable;
  12780. /**
  12781. * Observable that will be called just before the particles are drawn
  12782. */
  12783. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12784. /**
  12785. * Gets the name of the particle vertex shader
  12786. */
  12787. get vertexShaderName(): string;
  12788. /**
  12789. * Instantiates a particle system.
  12790. * 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.
  12791. * @param name The name of the particle system
  12792. * @param capacity The max number of particles alive at the same time
  12793. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12794. * @param customEffect a custom effect used to change the way particles are rendered by default
  12795. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12796. * @param epsilon Offset used to render the particles
  12797. */
  12798. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12799. private _addFactorGradient;
  12800. private _removeFactorGradient;
  12801. /**
  12802. * Adds a new life time gradient
  12803. * @param gradient defines the gradient to use (between 0 and 1)
  12804. * @param factor defines the life time factor to affect to the specified gradient
  12805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12806. * @returns the current particle system
  12807. */
  12808. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12809. /**
  12810. * Remove a specific life time gradient
  12811. * @param gradient defines the gradient to remove
  12812. * @returns the current particle system
  12813. */
  12814. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12815. /**
  12816. * Adds a new size gradient
  12817. * @param gradient defines the gradient to use (between 0 and 1)
  12818. * @param factor defines the size factor to affect to the specified gradient
  12819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12820. * @returns the current particle system
  12821. */
  12822. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12823. /**
  12824. * Remove a specific size gradient
  12825. * @param gradient defines the gradient to remove
  12826. * @returns the current particle system
  12827. */
  12828. removeSizeGradient(gradient: number): IParticleSystem;
  12829. /**
  12830. * Adds a new color remap gradient
  12831. * @param gradient defines the gradient to use (between 0 and 1)
  12832. * @param min defines the color remap minimal range
  12833. * @param max defines the color remap maximal range
  12834. * @returns the current particle system
  12835. */
  12836. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12837. /**
  12838. * Remove a specific color remap gradient
  12839. * @param gradient defines the gradient to remove
  12840. * @returns the current particle system
  12841. */
  12842. removeColorRemapGradient(gradient: number): IParticleSystem;
  12843. /**
  12844. * Adds a new alpha remap gradient
  12845. * @param gradient defines the gradient to use (between 0 and 1)
  12846. * @param min defines the alpha remap minimal range
  12847. * @param max defines the alpha remap maximal range
  12848. * @returns the current particle system
  12849. */
  12850. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12851. /**
  12852. * Remove a specific alpha remap gradient
  12853. * @param gradient defines the gradient to remove
  12854. * @returns the current particle system
  12855. */
  12856. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12857. /**
  12858. * Adds a new angular speed gradient
  12859. * @param gradient defines the gradient to use (between 0 and 1)
  12860. * @param factor defines the angular speed to affect to the specified gradient
  12861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12862. * @returns the current particle system
  12863. */
  12864. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12865. /**
  12866. * Remove a specific angular speed gradient
  12867. * @param gradient defines the gradient to remove
  12868. * @returns the current particle system
  12869. */
  12870. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12871. /**
  12872. * Adds a new velocity gradient
  12873. * @param gradient defines the gradient to use (between 0 and 1)
  12874. * @param factor defines the velocity to affect to the specified gradient
  12875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12876. * @returns the current particle system
  12877. */
  12878. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12879. /**
  12880. * Remove a specific velocity gradient
  12881. * @param gradient defines the gradient to remove
  12882. * @returns the current particle system
  12883. */
  12884. removeVelocityGradient(gradient: number): IParticleSystem;
  12885. /**
  12886. * Adds a new limit velocity gradient
  12887. * @param gradient defines the gradient to use (between 0 and 1)
  12888. * @param factor defines the limit velocity value to affect to the specified gradient
  12889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12890. * @returns the current particle system
  12891. */
  12892. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12893. /**
  12894. * Remove a specific limit velocity gradient
  12895. * @param gradient defines the gradient to remove
  12896. * @returns the current particle system
  12897. */
  12898. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12899. /**
  12900. * Adds a new drag gradient
  12901. * @param gradient defines the gradient to use (between 0 and 1)
  12902. * @param factor defines the drag value to affect to the specified gradient
  12903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12904. * @returns the current particle system
  12905. */
  12906. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12907. /**
  12908. * Remove a specific drag gradient
  12909. * @param gradient defines the gradient to remove
  12910. * @returns the current particle system
  12911. */
  12912. removeDragGradient(gradient: number): IParticleSystem;
  12913. /**
  12914. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12915. * @param gradient defines the gradient to use (between 0 and 1)
  12916. * @param factor defines the emit rate value to affect to the specified gradient
  12917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12918. * @returns the current particle system
  12919. */
  12920. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12921. /**
  12922. * Remove a specific emit rate gradient
  12923. * @param gradient defines the gradient to remove
  12924. * @returns the current particle system
  12925. */
  12926. removeEmitRateGradient(gradient: number): IParticleSystem;
  12927. /**
  12928. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12929. * @param gradient defines the gradient to use (between 0 and 1)
  12930. * @param factor defines the start size value to affect to the specified gradient
  12931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12932. * @returns the current particle system
  12933. */
  12934. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12935. /**
  12936. * Remove a specific start size gradient
  12937. * @param gradient defines the gradient to remove
  12938. * @returns the current particle system
  12939. */
  12940. removeStartSizeGradient(gradient: number): IParticleSystem;
  12941. private _createRampGradientTexture;
  12942. /**
  12943. * Gets the current list of ramp gradients.
  12944. * You must use addRampGradient and removeRampGradient to udpate this list
  12945. * @returns the list of ramp gradients
  12946. */
  12947. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12948. /** Force the system to rebuild all gradients that need to be resync */
  12949. forceRefreshGradients(): void;
  12950. private _syncRampGradientTexture;
  12951. /**
  12952. * Adds a new ramp gradient used to remap particle colors
  12953. * @param gradient defines the gradient to use (between 0 and 1)
  12954. * @param color defines the color to affect to the specified gradient
  12955. * @returns the current particle system
  12956. */
  12957. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12958. /**
  12959. * Remove a specific ramp gradient
  12960. * @param gradient defines the gradient to remove
  12961. * @returns the current particle system
  12962. */
  12963. removeRampGradient(gradient: number): ParticleSystem;
  12964. /**
  12965. * Adds a new color gradient
  12966. * @param gradient defines the gradient to use (between 0 and 1)
  12967. * @param color1 defines the color to affect to the specified gradient
  12968. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12969. * @returns this particle system
  12970. */
  12971. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12972. /**
  12973. * Remove a specific color gradient
  12974. * @param gradient defines the gradient to remove
  12975. * @returns this particle system
  12976. */
  12977. removeColorGradient(gradient: number): IParticleSystem;
  12978. private _fetchR;
  12979. protected _reset(): void;
  12980. private _resetEffect;
  12981. private _createVertexBuffers;
  12982. private _createIndexBuffer;
  12983. /**
  12984. * Gets the maximum number of particles active at the same time.
  12985. * @returns The max number of active particles.
  12986. */
  12987. getCapacity(): number;
  12988. /**
  12989. * Gets whether there are still active particles in the system.
  12990. * @returns True if it is alive, otherwise false.
  12991. */
  12992. isAlive(): boolean;
  12993. /**
  12994. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12995. * @returns True if it has been started, otherwise false.
  12996. */
  12997. isStarted(): boolean;
  12998. private _prepareSubEmitterInternalArray;
  12999. /**
  13000. * Starts the particle system and begins to emit
  13001. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13002. */
  13003. start(delay?: number): void;
  13004. /**
  13005. * Stops the particle system.
  13006. * @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.
  13007. */
  13008. stop(stopSubEmitters?: boolean): void;
  13009. /**
  13010. * Remove all active particles
  13011. */
  13012. reset(): void;
  13013. /**
  13014. * @hidden (for internal use only)
  13015. */
  13016. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13017. /**
  13018. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13019. * Its lifetime will start back at 0.
  13020. */
  13021. recycleParticle: (particle: Particle) => void;
  13022. private _stopSubEmitters;
  13023. private _createParticle;
  13024. private _removeFromRoot;
  13025. private _emitFromParticle;
  13026. private _update;
  13027. /** @hidden */
  13028. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13029. /** @hidden */
  13030. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13031. /**
  13032. * Fill the defines array according to the current settings of the particle system
  13033. * @param defines Array to be updated
  13034. * @param blendMode blend mode to take into account when updating the array
  13035. */
  13036. fillDefines(defines: Array<string>, blendMode: number): void;
  13037. /**
  13038. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13039. * @param uniforms Uniforms array to fill
  13040. * @param attributes Attributes array to fill
  13041. * @param samplers Samplers array to fill
  13042. */
  13043. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13044. /** @hidden */
  13045. private _getEffect;
  13046. /**
  13047. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13048. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13049. */
  13050. animate(preWarmOnly?: boolean): void;
  13051. private _appendParticleVertices;
  13052. /**
  13053. * Rebuilds the particle system.
  13054. */
  13055. rebuild(): void;
  13056. /**
  13057. * Is this system ready to be used/rendered
  13058. * @return true if the system is ready
  13059. */
  13060. isReady(): boolean;
  13061. private _render;
  13062. /**
  13063. * Renders the particle system in its current state.
  13064. * @returns the current number of particles
  13065. */
  13066. render(): number;
  13067. /**
  13068. * Disposes the particle system and free the associated resources
  13069. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13070. */
  13071. dispose(disposeTexture?: boolean): void;
  13072. /**
  13073. * Clones the particle system.
  13074. * @param name The name of the cloned object
  13075. * @param newEmitter The new emitter to use
  13076. * @returns the cloned particle system
  13077. */
  13078. clone(name: string, newEmitter: any): ParticleSystem;
  13079. /**
  13080. * Serializes the particle system to a JSON object
  13081. * @param serializeTexture defines if the texture must be serialized as well
  13082. * @returns the JSON object
  13083. */
  13084. serialize(serializeTexture?: boolean): any;
  13085. /** @hidden */
  13086. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13087. /** @hidden */
  13088. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13089. /**
  13090. * Parses a JSON object to create a particle system.
  13091. * @param parsedParticleSystem The JSON object to parse
  13092. * @param sceneOrEngine The scene or the engine to create the particle system in
  13093. * @param rootUrl The root url to use to load external dependencies like texture
  13094. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13095. * @returns the Parsed particle system
  13096. */
  13097. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13098. }
  13099. }
  13100. declare module BABYLON {
  13101. /**
  13102. * A particle represents one of the element emitted by a particle system.
  13103. * This is mainly define by its coordinates, direction, velocity and age.
  13104. */
  13105. export class Particle {
  13106. /**
  13107. * The particle system the particle belongs to.
  13108. */
  13109. particleSystem: ParticleSystem;
  13110. private static _Count;
  13111. /**
  13112. * Unique ID of the particle
  13113. */
  13114. id: number;
  13115. /**
  13116. * The world position of the particle in the scene.
  13117. */
  13118. position: Vector3;
  13119. /**
  13120. * The world direction of the particle in the scene.
  13121. */
  13122. direction: Vector3;
  13123. /**
  13124. * The color of the particle.
  13125. */
  13126. color: Color4;
  13127. /**
  13128. * The color change of the particle per step.
  13129. */
  13130. colorStep: Color4;
  13131. /**
  13132. * Defines how long will the life of the particle be.
  13133. */
  13134. lifeTime: number;
  13135. /**
  13136. * The current age of the particle.
  13137. */
  13138. age: number;
  13139. /**
  13140. * The current size of the particle.
  13141. */
  13142. size: number;
  13143. /**
  13144. * The current scale of the particle.
  13145. */
  13146. scale: Vector2;
  13147. /**
  13148. * The current angle of the particle.
  13149. */
  13150. angle: number;
  13151. /**
  13152. * Defines how fast is the angle changing.
  13153. */
  13154. angularSpeed: number;
  13155. /**
  13156. * Defines the cell index used by the particle to be rendered from a sprite.
  13157. */
  13158. cellIndex: number;
  13159. /**
  13160. * The information required to support color remapping
  13161. */
  13162. remapData: Vector4;
  13163. /** @hidden */
  13164. _randomCellOffset?: number;
  13165. /** @hidden */
  13166. _initialDirection: Nullable<Vector3>;
  13167. /** @hidden */
  13168. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13169. /** @hidden */
  13170. _initialStartSpriteCellID: number;
  13171. /** @hidden */
  13172. _initialEndSpriteCellID: number;
  13173. /** @hidden */
  13174. _currentColorGradient: Nullable<ColorGradient>;
  13175. /** @hidden */
  13176. _currentColor1: Color4;
  13177. /** @hidden */
  13178. _currentColor2: Color4;
  13179. /** @hidden */
  13180. _currentSizeGradient: Nullable<FactorGradient>;
  13181. /** @hidden */
  13182. _currentSize1: number;
  13183. /** @hidden */
  13184. _currentSize2: number;
  13185. /** @hidden */
  13186. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13187. /** @hidden */
  13188. _currentAngularSpeed1: number;
  13189. /** @hidden */
  13190. _currentAngularSpeed2: number;
  13191. /** @hidden */
  13192. _currentVelocityGradient: Nullable<FactorGradient>;
  13193. /** @hidden */
  13194. _currentVelocity1: number;
  13195. /** @hidden */
  13196. _currentVelocity2: number;
  13197. /** @hidden */
  13198. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13199. /** @hidden */
  13200. _currentLimitVelocity1: number;
  13201. /** @hidden */
  13202. _currentLimitVelocity2: number;
  13203. /** @hidden */
  13204. _currentDragGradient: Nullable<FactorGradient>;
  13205. /** @hidden */
  13206. _currentDrag1: number;
  13207. /** @hidden */
  13208. _currentDrag2: number;
  13209. /** @hidden */
  13210. _randomNoiseCoordinates1: Vector3;
  13211. /** @hidden */
  13212. _randomNoiseCoordinates2: Vector3;
  13213. /** @hidden */
  13214. _localPosition?: Vector3;
  13215. /**
  13216. * Creates a new instance Particle
  13217. * @param particleSystem the particle system the particle belongs to
  13218. */
  13219. constructor(
  13220. /**
  13221. * The particle system the particle belongs to.
  13222. */
  13223. particleSystem: ParticleSystem);
  13224. private updateCellInfoFromSystem;
  13225. /**
  13226. * Defines how the sprite cell index is updated for the particle
  13227. */
  13228. updateCellIndex(): void;
  13229. /** @hidden */
  13230. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13231. /** @hidden */
  13232. _inheritParticleInfoToSubEmitters(): void;
  13233. /** @hidden */
  13234. _reset(): void;
  13235. /**
  13236. * Copy the properties of particle to another one.
  13237. * @param other the particle to copy the information to.
  13238. */
  13239. copyTo(other: Particle): void;
  13240. }
  13241. }
  13242. declare module BABYLON {
  13243. /**
  13244. * Particle emitter represents a volume emitting particles.
  13245. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13246. */
  13247. export interface IParticleEmitterType {
  13248. /**
  13249. * Called by the particle System when the direction is computed for the created particle.
  13250. * @param worldMatrix is the world matrix of the particle system
  13251. * @param directionToUpdate is the direction vector to update with the result
  13252. * @param particle is the particle we are computed the direction for
  13253. * @param isLocal defines if the direction should be set in local space
  13254. */
  13255. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13256. /**
  13257. * Called by the particle System when the position is computed for the created particle.
  13258. * @param worldMatrix is the world matrix of the particle system
  13259. * @param positionToUpdate is the position vector to update with the result
  13260. * @param particle is the particle we are computed the position for
  13261. * @param isLocal defines if the position should be set in local space
  13262. */
  13263. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13264. /**
  13265. * Clones the current emitter and returns a copy of it
  13266. * @returns the new emitter
  13267. */
  13268. clone(): IParticleEmitterType;
  13269. /**
  13270. * Called by the GPUParticleSystem to setup the update shader
  13271. * @param effect defines the update shader
  13272. */
  13273. applyToShader(effect: Effect): void;
  13274. /**
  13275. * Returns a string to use to update the GPU particles update shader
  13276. * @returns the effect defines string
  13277. */
  13278. getEffectDefines(): string;
  13279. /**
  13280. * Returns a string representing the class name
  13281. * @returns a string containing the class name
  13282. */
  13283. getClassName(): string;
  13284. /**
  13285. * Serializes the particle system to a JSON object.
  13286. * @returns the JSON object
  13287. */
  13288. serialize(): any;
  13289. /**
  13290. * Parse properties from a JSON object
  13291. * @param serializationObject defines the JSON object
  13292. * @param scene defines the hosting scene
  13293. */
  13294. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13295. }
  13296. }
  13297. declare module BABYLON {
  13298. /**
  13299. * Particle emitter emitting particles from the inside of a box.
  13300. * It emits the particles randomly between 2 given directions.
  13301. */
  13302. export class BoxParticleEmitter implements IParticleEmitterType {
  13303. /**
  13304. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13305. */
  13306. direction1: Vector3;
  13307. /**
  13308. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13309. */
  13310. direction2: Vector3;
  13311. /**
  13312. * 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.
  13313. */
  13314. minEmitBox: Vector3;
  13315. /**
  13316. * 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.
  13317. */
  13318. maxEmitBox: Vector3;
  13319. /**
  13320. * Creates a new instance BoxParticleEmitter
  13321. */
  13322. constructor();
  13323. /**
  13324. * Called by the particle System when the direction is computed for the created particle.
  13325. * @param worldMatrix is the world matrix of the particle system
  13326. * @param directionToUpdate is the direction vector to update with the result
  13327. * @param particle is the particle we are computed the direction for
  13328. * @param isLocal defines if the direction should be set in local space
  13329. */
  13330. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13331. /**
  13332. * Called by the particle System when the position is computed for the created particle.
  13333. * @param worldMatrix is the world matrix of the particle system
  13334. * @param positionToUpdate is the position vector to update with the result
  13335. * @param particle is the particle we are computed the position for
  13336. * @param isLocal defines if the position should be set in local space
  13337. */
  13338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13339. /**
  13340. * Clones the current emitter and returns a copy of it
  13341. * @returns the new emitter
  13342. */
  13343. clone(): BoxParticleEmitter;
  13344. /**
  13345. * Called by the GPUParticleSystem to setup the update shader
  13346. * @param effect defines the update shader
  13347. */
  13348. applyToShader(effect: Effect): void;
  13349. /**
  13350. * Returns a string to use to update the GPU particles update shader
  13351. * @returns a string containng the defines string
  13352. */
  13353. getEffectDefines(): string;
  13354. /**
  13355. * Returns the string "BoxParticleEmitter"
  13356. * @returns a string containing the class name
  13357. */
  13358. getClassName(): string;
  13359. /**
  13360. * Serializes the particle system to a JSON object.
  13361. * @returns the JSON object
  13362. */
  13363. serialize(): any;
  13364. /**
  13365. * Parse properties from a JSON object
  13366. * @param serializationObject defines the JSON object
  13367. */
  13368. parse(serializationObject: any): void;
  13369. }
  13370. }
  13371. declare module BABYLON {
  13372. /**
  13373. * Particle emitter emitting particles from the inside of a cone.
  13374. * It emits the particles alongside the cone volume from the base to the particle.
  13375. * The emission direction might be randomized.
  13376. */
  13377. export class ConeParticleEmitter implements IParticleEmitterType {
  13378. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13379. directionRandomizer: number;
  13380. private _radius;
  13381. private _angle;
  13382. private _height;
  13383. /**
  13384. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13385. */
  13386. radiusRange: number;
  13387. /**
  13388. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13389. */
  13390. heightRange: number;
  13391. /**
  13392. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13393. */
  13394. emitFromSpawnPointOnly: boolean;
  13395. /**
  13396. * Gets or sets the radius of the emission cone
  13397. */
  13398. get radius(): number;
  13399. set radius(value: number);
  13400. /**
  13401. * Gets or sets the angle of the emission cone
  13402. */
  13403. get angle(): number;
  13404. set angle(value: number);
  13405. private _buildHeight;
  13406. /**
  13407. * Creates a new instance ConeParticleEmitter
  13408. * @param radius the radius of the emission cone (1 by default)
  13409. * @param angle the cone base angle (PI by default)
  13410. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13411. */
  13412. constructor(radius?: number, angle?: number,
  13413. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13414. directionRandomizer?: number);
  13415. /**
  13416. * Called by the particle System when the direction is computed for the created particle.
  13417. * @param worldMatrix is the world matrix of the particle system
  13418. * @param directionToUpdate is the direction vector to update with the result
  13419. * @param particle is the particle we are computed the direction for
  13420. * @param isLocal defines if the direction should be set in local space
  13421. */
  13422. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13423. /**
  13424. * Called by the particle System when the position is computed for the created particle.
  13425. * @param worldMatrix is the world matrix of the particle system
  13426. * @param positionToUpdate is the position vector to update with the result
  13427. * @param particle is the particle we are computed the position for
  13428. * @param isLocal defines if the position should be set in local space
  13429. */
  13430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13431. /**
  13432. * Clones the current emitter and returns a copy of it
  13433. * @returns the new emitter
  13434. */
  13435. clone(): ConeParticleEmitter;
  13436. /**
  13437. * Called by the GPUParticleSystem to setup the update shader
  13438. * @param effect defines the update shader
  13439. */
  13440. applyToShader(effect: Effect): void;
  13441. /**
  13442. * Returns a string to use to update the GPU particles update shader
  13443. * @returns a string containng the defines string
  13444. */
  13445. getEffectDefines(): string;
  13446. /**
  13447. * Returns the string "ConeParticleEmitter"
  13448. * @returns a string containing the class name
  13449. */
  13450. getClassName(): string;
  13451. /**
  13452. * Serializes the particle system to a JSON object.
  13453. * @returns the JSON object
  13454. */
  13455. serialize(): any;
  13456. /**
  13457. * Parse properties from a JSON object
  13458. * @param serializationObject defines the JSON object
  13459. */
  13460. parse(serializationObject: any): void;
  13461. }
  13462. }
  13463. declare module BABYLON {
  13464. /**
  13465. * Particle emitter emitting particles from the inside of a cylinder.
  13466. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13467. */
  13468. export class CylinderParticleEmitter implements IParticleEmitterType {
  13469. /**
  13470. * The radius of the emission cylinder.
  13471. */
  13472. radius: number;
  13473. /**
  13474. * The height of the emission cylinder.
  13475. */
  13476. height: number;
  13477. /**
  13478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13479. */
  13480. radiusRange: number;
  13481. /**
  13482. * How much to randomize the particle direction [0-1].
  13483. */
  13484. directionRandomizer: number;
  13485. /**
  13486. * Creates a new instance CylinderParticleEmitter
  13487. * @param radius the radius of the emission cylinder (1 by default)
  13488. * @param height the height of the emission cylinder (1 by default)
  13489. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13490. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13491. */
  13492. constructor(
  13493. /**
  13494. * The radius of the emission cylinder.
  13495. */
  13496. radius?: number,
  13497. /**
  13498. * The height of the emission cylinder.
  13499. */
  13500. height?: number,
  13501. /**
  13502. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13503. */
  13504. radiusRange?: number,
  13505. /**
  13506. * How much to randomize the particle direction [0-1].
  13507. */
  13508. directionRandomizer?: number);
  13509. /**
  13510. * Called by the particle System when the direction is computed for the created particle.
  13511. * @param worldMatrix is the world matrix of the particle system
  13512. * @param directionToUpdate is the direction vector to update with the result
  13513. * @param particle is the particle we are computed the direction for
  13514. * @param isLocal defines if the direction should be set in local space
  13515. */
  13516. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13517. /**
  13518. * Called by the particle System when the position is computed for the created particle.
  13519. * @param worldMatrix is the world matrix of the particle system
  13520. * @param positionToUpdate is the position vector to update with the result
  13521. * @param particle is the particle we are computed the position for
  13522. * @param isLocal defines if the position should be set in local space
  13523. */
  13524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13525. /**
  13526. * Clones the current emitter and returns a copy of it
  13527. * @returns the new emitter
  13528. */
  13529. clone(): CylinderParticleEmitter;
  13530. /**
  13531. * Called by the GPUParticleSystem to setup the update shader
  13532. * @param effect defines the update shader
  13533. */
  13534. applyToShader(effect: Effect): void;
  13535. /**
  13536. * Returns a string to use to update the GPU particles update shader
  13537. * @returns a string containng the defines string
  13538. */
  13539. getEffectDefines(): string;
  13540. /**
  13541. * Returns the string "CylinderParticleEmitter"
  13542. * @returns a string containing the class name
  13543. */
  13544. getClassName(): string;
  13545. /**
  13546. * Serializes the particle system to a JSON object.
  13547. * @returns the JSON object
  13548. */
  13549. serialize(): any;
  13550. /**
  13551. * Parse properties from a JSON object
  13552. * @param serializationObject defines the JSON object
  13553. */
  13554. parse(serializationObject: any): void;
  13555. }
  13556. /**
  13557. * Particle emitter emitting particles from the inside of a cylinder.
  13558. * It emits the particles randomly between two vectors.
  13559. */
  13560. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13561. /**
  13562. * The min limit of the emission direction.
  13563. */
  13564. direction1: Vector3;
  13565. /**
  13566. * The max limit of the emission direction.
  13567. */
  13568. direction2: Vector3;
  13569. /**
  13570. * Creates a new instance CylinderDirectedParticleEmitter
  13571. * @param radius the radius of the emission cylinder (1 by default)
  13572. * @param height the height of the emission cylinder (1 by default)
  13573. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13574. * @param direction1 the min limit of the emission direction (up vector by default)
  13575. * @param direction2 the max limit of the emission direction (up vector by default)
  13576. */
  13577. constructor(radius?: number, height?: number, radiusRange?: number,
  13578. /**
  13579. * The min limit of the emission direction.
  13580. */
  13581. direction1?: Vector3,
  13582. /**
  13583. * The max limit of the emission direction.
  13584. */
  13585. direction2?: Vector3);
  13586. /**
  13587. * Called by the particle System when the direction is computed for the created particle.
  13588. * @param worldMatrix is the world matrix of the particle system
  13589. * @param directionToUpdate is the direction vector to update with the result
  13590. * @param particle is the particle we are computed the direction for
  13591. */
  13592. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13593. /**
  13594. * Clones the current emitter and returns a copy of it
  13595. * @returns the new emitter
  13596. */
  13597. clone(): CylinderDirectedParticleEmitter;
  13598. /**
  13599. * Called by the GPUParticleSystem to setup the update shader
  13600. * @param effect defines the update shader
  13601. */
  13602. applyToShader(effect: Effect): void;
  13603. /**
  13604. * Returns a string to use to update the GPU particles update shader
  13605. * @returns a string containng the defines string
  13606. */
  13607. getEffectDefines(): string;
  13608. /**
  13609. * Returns the string "CylinderDirectedParticleEmitter"
  13610. * @returns a string containing the class name
  13611. */
  13612. getClassName(): string;
  13613. /**
  13614. * Serializes the particle system to a JSON object.
  13615. * @returns the JSON object
  13616. */
  13617. serialize(): any;
  13618. /**
  13619. * Parse properties from a JSON object
  13620. * @param serializationObject defines the JSON object
  13621. */
  13622. parse(serializationObject: any): void;
  13623. }
  13624. }
  13625. declare module BABYLON {
  13626. /**
  13627. * Particle emitter emitting particles from the inside of a hemisphere.
  13628. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13629. */
  13630. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13631. /**
  13632. * The radius of the emission hemisphere.
  13633. */
  13634. radius: number;
  13635. /**
  13636. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13637. */
  13638. radiusRange: number;
  13639. /**
  13640. * How much to randomize the particle direction [0-1].
  13641. */
  13642. directionRandomizer: number;
  13643. /**
  13644. * Creates a new instance HemisphericParticleEmitter
  13645. * @param radius the radius of the emission hemisphere (1 by default)
  13646. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13647. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13648. */
  13649. constructor(
  13650. /**
  13651. * The radius of the emission hemisphere.
  13652. */
  13653. radius?: number,
  13654. /**
  13655. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13656. */
  13657. radiusRange?: number,
  13658. /**
  13659. * How much to randomize the particle direction [0-1].
  13660. */
  13661. directionRandomizer?: number);
  13662. /**
  13663. * Called by the particle System when the direction is computed for the created particle.
  13664. * @param worldMatrix is the world matrix of the particle system
  13665. * @param directionToUpdate is the direction vector to update with the result
  13666. * @param particle is the particle we are computed the direction for
  13667. * @param isLocal defines if the direction should be set in local space
  13668. */
  13669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13670. /**
  13671. * Called by the particle System when the position is computed for the created particle.
  13672. * @param worldMatrix is the world matrix of the particle system
  13673. * @param positionToUpdate is the position vector to update with the result
  13674. * @param particle is the particle we are computed the position for
  13675. * @param isLocal defines if the position should be set in local space
  13676. */
  13677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13678. /**
  13679. * Clones the current emitter and returns a copy of it
  13680. * @returns the new emitter
  13681. */
  13682. clone(): HemisphericParticleEmitter;
  13683. /**
  13684. * Called by the GPUParticleSystem to setup the update shader
  13685. * @param effect defines the update shader
  13686. */
  13687. applyToShader(effect: Effect): void;
  13688. /**
  13689. * Returns a string to use to update the GPU particles update shader
  13690. * @returns a string containng the defines string
  13691. */
  13692. getEffectDefines(): string;
  13693. /**
  13694. * Returns the string "HemisphericParticleEmitter"
  13695. * @returns a string containing the class name
  13696. */
  13697. getClassName(): string;
  13698. /**
  13699. * Serializes the particle system to a JSON object.
  13700. * @returns the JSON object
  13701. */
  13702. serialize(): any;
  13703. /**
  13704. * Parse properties from a JSON object
  13705. * @param serializationObject defines the JSON object
  13706. */
  13707. parse(serializationObject: any): void;
  13708. }
  13709. }
  13710. declare module BABYLON {
  13711. /**
  13712. * Particle emitter emitting particles from a point.
  13713. * It emits the particles randomly between 2 given directions.
  13714. */
  13715. export class PointParticleEmitter implements IParticleEmitterType {
  13716. /**
  13717. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13718. */
  13719. direction1: Vector3;
  13720. /**
  13721. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13722. */
  13723. direction2: Vector3;
  13724. /**
  13725. * Creates a new instance PointParticleEmitter
  13726. */
  13727. constructor();
  13728. /**
  13729. * Called by the particle System when the direction is computed for the created particle.
  13730. * @param worldMatrix is the world matrix of the particle system
  13731. * @param directionToUpdate is the direction vector to update with the result
  13732. * @param particle is the particle we are computed the direction for
  13733. * @param isLocal defines if the direction should be set in local space
  13734. */
  13735. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13736. /**
  13737. * Called by the particle System when the position is computed for the created particle.
  13738. * @param worldMatrix is the world matrix of the particle system
  13739. * @param positionToUpdate is the position vector to update with the result
  13740. * @param particle is the particle we are computed the position for
  13741. * @param isLocal defines if the position should be set in local space
  13742. */
  13743. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13744. /**
  13745. * Clones the current emitter and returns a copy of it
  13746. * @returns the new emitter
  13747. */
  13748. clone(): PointParticleEmitter;
  13749. /**
  13750. * Called by the GPUParticleSystem to setup the update shader
  13751. * @param effect defines the update shader
  13752. */
  13753. applyToShader(effect: Effect): void;
  13754. /**
  13755. * Returns a string to use to update the GPU particles update shader
  13756. * @returns a string containng the defines string
  13757. */
  13758. getEffectDefines(): string;
  13759. /**
  13760. * Returns the string "PointParticleEmitter"
  13761. * @returns a string containing the class name
  13762. */
  13763. getClassName(): string;
  13764. /**
  13765. * Serializes the particle system to a JSON object.
  13766. * @returns the JSON object
  13767. */
  13768. serialize(): any;
  13769. /**
  13770. * Parse properties from a JSON object
  13771. * @param serializationObject defines the JSON object
  13772. */
  13773. parse(serializationObject: any): void;
  13774. }
  13775. }
  13776. declare module BABYLON {
  13777. /**
  13778. * Particle emitter emitting particles from the inside of a sphere.
  13779. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13780. */
  13781. export class SphereParticleEmitter implements IParticleEmitterType {
  13782. /**
  13783. * The radius of the emission sphere.
  13784. */
  13785. radius: number;
  13786. /**
  13787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13788. */
  13789. radiusRange: number;
  13790. /**
  13791. * How much to randomize the particle direction [0-1].
  13792. */
  13793. directionRandomizer: number;
  13794. /**
  13795. * Creates a new instance SphereParticleEmitter
  13796. * @param radius the radius of the emission sphere (1 by default)
  13797. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13798. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13799. */
  13800. constructor(
  13801. /**
  13802. * The radius of the emission sphere.
  13803. */
  13804. radius?: number,
  13805. /**
  13806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13807. */
  13808. radiusRange?: number,
  13809. /**
  13810. * How much to randomize the particle direction [0-1].
  13811. */
  13812. directionRandomizer?: number);
  13813. /**
  13814. * Called by the particle System when the direction is computed for the created particle.
  13815. * @param worldMatrix is the world matrix of the particle system
  13816. * @param directionToUpdate is the direction vector to update with the result
  13817. * @param particle is the particle we are computed the direction for
  13818. * @param isLocal defines if the direction should be set in local space
  13819. */
  13820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13821. /**
  13822. * Called by the particle System when the position is computed for the created particle.
  13823. * @param worldMatrix is the world matrix of the particle system
  13824. * @param positionToUpdate is the position vector to update with the result
  13825. * @param particle is the particle we are computed the position for
  13826. * @param isLocal defines if the position should be set in local space
  13827. */
  13828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13829. /**
  13830. * Clones the current emitter and returns a copy of it
  13831. * @returns the new emitter
  13832. */
  13833. clone(): SphereParticleEmitter;
  13834. /**
  13835. * Called by the GPUParticleSystem to setup the update shader
  13836. * @param effect defines the update shader
  13837. */
  13838. applyToShader(effect: Effect): void;
  13839. /**
  13840. * Returns a string to use to update the GPU particles update shader
  13841. * @returns a string containng the defines string
  13842. */
  13843. getEffectDefines(): string;
  13844. /**
  13845. * Returns the string "SphereParticleEmitter"
  13846. * @returns a string containing the class name
  13847. */
  13848. getClassName(): string;
  13849. /**
  13850. * Serializes the particle system to a JSON object.
  13851. * @returns the JSON object
  13852. */
  13853. serialize(): any;
  13854. /**
  13855. * Parse properties from a JSON object
  13856. * @param serializationObject defines the JSON object
  13857. */
  13858. parse(serializationObject: any): void;
  13859. }
  13860. /**
  13861. * Particle emitter emitting particles from the inside of a sphere.
  13862. * It emits the particles randomly between two vectors.
  13863. */
  13864. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13865. /**
  13866. * The min limit of the emission direction.
  13867. */
  13868. direction1: Vector3;
  13869. /**
  13870. * The max limit of the emission direction.
  13871. */
  13872. direction2: Vector3;
  13873. /**
  13874. * Creates a new instance SphereDirectedParticleEmitter
  13875. * @param radius the radius of the emission sphere (1 by default)
  13876. * @param direction1 the min limit of the emission direction (up vector by default)
  13877. * @param direction2 the max limit of the emission direction (up vector by default)
  13878. */
  13879. constructor(radius?: number,
  13880. /**
  13881. * The min limit of the emission direction.
  13882. */
  13883. direction1?: Vector3,
  13884. /**
  13885. * The max limit of the emission direction.
  13886. */
  13887. direction2?: Vector3);
  13888. /**
  13889. * Called by the particle System when the direction is computed for the created particle.
  13890. * @param worldMatrix is the world matrix of the particle system
  13891. * @param directionToUpdate is the direction vector to update with the result
  13892. * @param particle is the particle we are computed the direction for
  13893. */
  13894. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13895. /**
  13896. * Clones the current emitter and returns a copy of it
  13897. * @returns the new emitter
  13898. */
  13899. clone(): SphereDirectedParticleEmitter;
  13900. /**
  13901. * Called by the GPUParticleSystem to setup the update shader
  13902. * @param effect defines the update shader
  13903. */
  13904. applyToShader(effect: Effect): void;
  13905. /**
  13906. * Returns a string to use to update the GPU particles update shader
  13907. * @returns a string containng the defines string
  13908. */
  13909. getEffectDefines(): string;
  13910. /**
  13911. * Returns the string "SphereDirectedParticleEmitter"
  13912. * @returns a string containing the class name
  13913. */
  13914. getClassName(): string;
  13915. /**
  13916. * Serializes the particle system to a JSON object.
  13917. * @returns the JSON object
  13918. */
  13919. serialize(): any;
  13920. /**
  13921. * Parse properties from a JSON object
  13922. * @param serializationObject defines the JSON object
  13923. */
  13924. parse(serializationObject: any): void;
  13925. }
  13926. }
  13927. declare module BABYLON {
  13928. /**
  13929. * Particle emitter emitting particles from a custom list of positions.
  13930. */
  13931. export class CustomParticleEmitter implements IParticleEmitterType {
  13932. /**
  13933. * Gets or sets the position generator that will create the inital position of each particle.
  13934. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13935. */
  13936. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13937. /**
  13938. * Gets or sets the destination generator that will create the final destination of each particle.
  13939. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13940. */
  13941. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13942. /**
  13943. * Creates a new instance CustomParticleEmitter
  13944. */
  13945. constructor();
  13946. /**
  13947. * Called by the particle System when the direction is computed for the created particle.
  13948. * @param worldMatrix is the world matrix of the particle system
  13949. * @param directionToUpdate is the direction vector to update with the result
  13950. * @param particle is the particle we are computed the direction for
  13951. * @param isLocal defines if the direction should be set in local space
  13952. */
  13953. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13954. /**
  13955. * Called by the particle System when the position is computed for the created particle.
  13956. * @param worldMatrix is the world matrix of the particle system
  13957. * @param positionToUpdate is the position vector to update with the result
  13958. * @param particle is the particle we are computed the position for
  13959. * @param isLocal defines if the position should be set in local space
  13960. */
  13961. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13962. /**
  13963. * Clones the current emitter and returns a copy of it
  13964. * @returns the new emitter
  13965. */
  13966. clone(): CustomParticleEmitter;
  13967. /**
  13968. * Called by the GPUParticleSystem to setup the update shader
  13969. * @param effect defines the update shader
  13970. */
  13971. applyToShader(effect: Effect): void;
  13972. /**
  13973. * Returns a string to use to update the GPU particles update shader
  13974. * @returns a string containng the defines string
  13975. */
  13976. getEffectDefines(): string;
  13977. /**
  13978. * Returns the string "PointParticleEmitter"
  13979. * @returns a string containing the class name
  13980. */
  13981. getClassName(): string;
  13982. /**
  13983. * Serializes the particle system to a JSON object.
  13984. * @returns the JSON object
  13985. */
  13986. serialize(): any;
  13987. /**
  13988. * Parse properties from a JSON object
  13989. * @param serializationObject defines the JSON object
  13990. */
  13991. parse(serializationObject: any): void;
  13992. }
  13993. }
  13994. declare module BABYLON {
  13995. /**
  13996. * Particle emitter emitting particles from the inside of a box.
  13997. * It emits the particles randomly between 2 given directions.
  13998. */
  13999. export class MeshParticleEmitter implements IParticleEmitterType {
  14000. private _indices;
  14001. private _positions;
  14002. private _normals;
  14003. private _storedNormal;
  14004. private _mesh;
  14005. /**
  14006. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14007. */
  14008. direction1: Vector3;
  14009. /**
  14010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14011. */
  14012. direction2: Vector3;
  14013. /**
  14014. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14015. */
  14016. useMeshNormalsForDirection: boolean;
  14017. /** Defines the mesh to use as source */
  14018. get mesh(): Nullable<AbstractMesh>;
  14019. set mesh(value: Nullable<AbstractMesh>);
  14020. /**
  14021. * Creates a new instance MeshParticleEmitter
  14022. * @param mesh defines the mesh to use as source
  14023. */
  14024. constructor(mesh?: Nullable<AbstractMesh>);
  14025. /**
  14026. * Called by the particle System when the direction is computed for the created particle.
  14027. * @param worldMatrix is the world matrix of the particle system
  14028. * @param directionToUpdate is the direction vector to update with the result
  14029. * @param particle is the particle we are computed the direction for
  14030. * @param isLocal defines if the direction should be set in local space
  14031. */
  14032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14033. /**
  14034. * Called by the particle System when the position is computed for the created particle.
  14035. * @param worldMatrix is the world matrix of the particle system
  14036. * @param positionToUpdate is the position vector to update with the result
  14037. * @param particle is the particle we are computed the position for
  14038. * @param isLocal defines if the position should be set in local space
  14039. */
  14040. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14041. /**
  14042. * Clones the current emitter and returns a copy of it
  14043. * @returns the new emitter
  14044. */
  14045. clone(): MeshParticleEmitter;
  14046. /**
  14047. * Called by the GPUParticleSystem to setup the update shader
  14048. * @param effect defines the update shader
  14049. */
  14050. applyToShader(effect: Effect): void;
  14051. /**
  14052. * Returns a string to use to update the GPU particles update shader
  14053. * @returns a string containng the defines string
  14054. */
  14055. getEffectDefines(): string;
  14056. /**
  14057. * Returns the string "BoxParticleEmitter"
  14058. * @returns a string containing the class name
  14059. */
  14060. getClassName(): string;
  14061. /**
  14062. * Serializes the particle system to a JSON object.
  14063. * @returns the JSON object
  14064. */
  14065. serialize(): any;
  14066. /**
  14067. * Parse properties from a JSON object
  14068. * @param serializationObject defines the JSON object
  14069. * @param scene defines the hosting scene
  14070. */
  14071. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14072. }
  14073. }
  14074. declare module BABYLON {
  14075. /**
  14076. * Interface representing a particle system in Babylon.js.
  14077. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14078. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14079. */
  14080. export interface IParticleSystem {
  14081. /**
  14082. * List of animations used by the particle system.
  14083. */
  14084. animations: Animation[];
  14085. /**
  14086. * The id of the Particle system.
  14087. */
  14088. id: string;
  14089. /**
  14090. * The name of the Particle system.
  14091. */
  14092. name: string;
  14093. /**
  14094. * The emitter represents the Mesh or position we are attaching the particle system to.
  14095. */
  14096. emitter: Nullable<AbstractMesh | Vector3>;
  14097. /**
  14098. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14099. */
  14100. isBillboardBased: boolean;
  14101. /**
  14102. * The rendering group used by the Particle system to chose when to render.
  14103. */
  14104. renderingGroupId: number;
  14105. /**
  14106. * The layer mask we are rendering the particles through.
  14107. */
  14108. layerMask: number;
  14109. /**
  14110. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14111. */
  14112. updateSpeed: number;
  14113. /**
  14114. * The amount of time the particle system is running (depends of the overall update speed).
  14115. */
  14116. targetStopDuration: number;
  14117. /**
  14118. * The texture used to render each particle. (this can be a spritesheet)
  14119. */
  14120. particleTexture: Nullable<BaseTexture>;
  14121. /**
  14122. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14123. */
  14124. blendMode: number;
  14125. /**
  14126. * Minimum life time of emitting particles.
  14127. */
  14128. minLifeTime: number;
  14129. /**
  14130. * Maximum life time of emitting particles.
  14131. */
  14132. maxLifeTime: number;
  14133. /**
  14134. * Minimum Size of emitting particles.
  14135. */
  14136. minSize: number;
  14137. /**
  14138. * Maximum Size of emitting particles.
  14139. */
  14140. maxSize: number;
  14141. /**
  14142. * Minimum scale of emitting particles on X axis.
  14143. */
  14144. minScaleX: number;
  14145. /**
  14146. * Maximum scale of emitting particles on X axis.
  14147. */
  14148. maxScaleX: number;
  14149. /**
  14150. * Minimum scale of emitting particles on Y axis.
  14151. */
  14152. minScaleY: number;
  14153. /**
  14154. * Maximum scale of emitting particles on Y axis.
  14155. */
  14156. maxScaleY: number;
  14157. /**
  14158. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14159. */
  14160. color1: Color4;
  14161. /**
  14162. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14163. */
  14164. color2: Color4;
  14165. /**
  14166. * Color the particle will have at the end of its lifetime.
  14167. */
  14168. colorDead: Color4;
  14169. /**
  14170. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14171. */
  14172. emitRate: number;
  14173. /**
  14174. * You can use gravity if you want to give an orientation to your particles.
  14175. */
  14176. gravity: Vector3;
  14177. /**
  14178. * Minimum power of emitting particles.
  14179. */
  14180. minEmitPower: number;
  14181. /**
  14182. * Maximum power of emitting particles.
  14183. */
  14184. maxEmitPower: number;
  14185. /**
  14186. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14187. */
  14188. minAngularSpeed: number;
  14189. /**
  14190. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14191. */
  14192. maxAngularSpeed: number;
  14193. /**
  14194. * Gets or sets the minimal initial rotation in radians.
  14195. */
  14196. minInitialRotation: number;
  14197. /**
  14198. * Gets or sets the maximal initial rotation in radians.
  14199. */
  14200. maxInitialRotation: number;
  14201. /**
  14202. * The particle emitter type defines the emitter used by the particle system.
  14203. * It can be for example box, sphere, or cone...
  14204. */
  14205. particleEmitterType: Nullable<IParticleEmitterType>;
  14206. /**
  14207. * Defines the delay in milliseconds before starting the system (0 by default)
  14208. */
  14209. startDelay: number;
  14210. /**
  14211. * 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
  14212. */
  14213. preWarmCycles: number;
  14214. /**
  14215. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14216. */
  14217. preWarmStepOffset: number;
  14218. /**
  14219. * 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)
  14220. */
  14221. spriteCellChangeSpeed: number;
  14222. /**
  14223. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14224. */
  14225. startSpriteCellID: number;
  14226. /**
  14227. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14228. */
  14229. endSpriteCellID: number;
  14230. /**
  14231. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14232. */
  14233. spriteCellWidth: number;
  14234. /**
  14235. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14236. */
  14237. spriteCellHeight: number;
  14238. /**
  14239. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14240. */
  14241. spriteRandomStartCell: boolean;
  14242. /**
  14243. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14244. */
  14245. isAnimationSheetEnabled: boolean;
  14246. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14247. translationPivot: Vector2;
  14248. /**
  14249. * Gets or sets a texture used to add random noise to particle positions
  14250. */
  14251. noiseTexture: Nullable<BaseTexture>;
  14252. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14253. noiseStrength: Vector3;
  14254. /**
  14255. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14256. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14257. */
  14258. billboardMode: number;
  14259. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14260. limitVelocityDamping: number;
  14261. /**
  14262. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14263. */
  14264. beginAnimationOnStart: boolean;
  14265. /**
  14266. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14267. */
  14268. beginAnimationFrom: number;
  14269. /**
  14270. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14271. */
  14272. beginAnimationTo: number;
  14273. /**
  14274. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14275. */
  14276. beginAnimationLoop: boolean;
  14277. /**
  14278. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14279. */
  14280. disposeOnStop: boolean;
  14281. /**
  14282. * Specifies if the particles are updated in emitter local space or world space
  14283. */
  14284. isLocal: boolean;
  14285. /** Snippet ID if the particle system was created from the snippet server */
  14286. snippetId: string;
  14287. /** Gets or sets a matrix to use to compute projection */
  14288. defaultProjectionMatrix: Matrix;
  14289. /**
  14290. * Gets the maximum number of particles active at the same time.
  14291. * @returns The max number of active particles.
  14292. */
  14293. getCapacity(): number;
  14294. /**
  14295. * Gets the number of particles active at the same time.
  14296. * @returns The number of active particles.
  14297. */
  14298. getActiveCount(): number;
  14299. /**
  14300. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14301. * @returns True if it has been started, otherwise false.
  14302. */
  14303. isStarted(): boolean;
  14304. /**
  14305. * Animates the particle system for this frame.
  14306. */
  14307. animate(): void;
  14308. /**
  14309. * Renders the particle system in its current state.
  14310. * @returns the current number of particles
  14311. */
  14312. render(): number;
  14313. /**
  14314. * Dispose the particle system and frees its associated resources.
  14315. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14316. */
  14317. dispose(disposeTexture?: boolean): void;
  14318. /**
  14319. * An event triggered when the system is disposed
  14320. */
  14321. onDisposeObservable: Observable<IParticleSystem>;
  14322. /**
  14323. * An event triggered when the system is stopped
  14324. */
  14325. onStoppedObservable: Observable<IParticleSystem>;
  14326. /**
  14327. * Clones the particle system.
  14328. * @param name The name of the cloned object
  14329. * @param newEmitter The new emitter to use
  14330. * @returns the cloned particle system
  14331. */
  14332. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14333. /**
  14334. * Serializes the particle system to a JSON object
  14335. * @param serializeTexture defines if the texture must be serialized as well
  14336. * @returns the JSON object
  14337. */
  14338. serialize(serializeTexture: boolean): any;
  14339. /**
  14340. * Rebuild the particle system
  14341. */
  14342. rebuild(): void;
  14343. /** Force the system to rebuild all gradients that need to be resync */
  14344. forceRefreshGradients(): void;
  14345. /**
  14346. * Starts the particle system and begins to emit
  14347. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14348. */
  14349. start(delay?: number): void;
  14350. /**
  14351. * Stops the particle system.
  14352. */
  14353. stop(): void;
  14354. /**
  14355. * Remove all active particles
  14356. */
  14357. reset(): void;
  14358. /**
  14359. * Gets a boolean indicating that the system is stopping
  14360. * @returns true if the system is currently stopping
  14361. */
  14362. isStopping(): boolean;
  14363. /**
  14364. * Is this system ready to be used/rendered
  14365. * @return true if the system is ready
  14366. */
  14367. isReady(): boolean;
  14368. /**
  14369. * Returns the string "ParticleSystem"
  14370. * @returns a string containing the class name
  14371. */
  14372. getClassName(): string;
  14373. /**
  14374. * Gets the custom effect used to render the particles
  14375. * @param blendMode Blend mode for which the effect should be retrieved
  14376. * @returns The effect
  14377. */
  14378. getCustomEffect(blendMode: number): Nullable<Effect>;
  14379. /**
  14380. * Sets the custom effect used to render the particles
  14381. * @param effect The effect to set
  14382. * @param blendMode Blend mode for which the effect should be set
  14383. */
  14384. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14385. /**
  14386. * Fill the defines array according to the current settings of the particle system
  14387. * @param defines Array to be updated
  14388. * @param blendMode blend mode to take into account when updating the array
  14389. */
  14390. fillDefines(defines: Array<string>, blendMode: number): void;
  14391. /**
  14392. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14393. * @param uniforms Uniforms array to fill
  14394. * @param attributes Attributes array to fill
  14395. * @param samplers Samplers array to fill
  14396. */
  14397. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14398. /**
  14399. * Observable that will be called just before the particles are drawn
  14400. */
  14401. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14402. /**
  14403. * Gets the name of the particle vertex shader
  14404. */
  14405. vertexShaderName: string;
  14406. /**
  14407. * Adds a new color gradient
  14408. * @param gradient defines the gradient to use (between 0 and 1)
  14409. * @param color1 defines the color to affect to the specified gradient
  14410. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14411. * @returns the current particle system
  14412. */
  14413. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14414. /**
  14415. * Remove a specific color gradient
  14416. * @param gradient defines the gradient to remove
  14417. * @returns the current particle system
  14418. */
  14419. removeColorGradient(gradient: number): IParticleSystem;
  14420. /**
  14421. * Adds a new size gradient
  14422. * @param gradient defines the gradient to use (between 0 and 1)
  14423. * @param factor defines the size factor to affect to the specified gradient
  14424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14425. * @returns the current particle system
  14426. */
  14427. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14428. /**
  14429. * Remove a specific size gradient
  14430. * @param gradient defines the gradient to remove
  14431. * @returns the current particle system
  14432. */
  14433. removeSizeGradient(gradient: number): IParticleSystem;
  14434. /**
  14435. * Gets the current list of color gradients.
  14436. * You must use addColorGradient and removeColorGradient to udpate this list
  14437. * @returns the list of color gradients
  14438. */
  14439. getColorGradients(): Nullable<Array<ColorGradient>>;
  14440. /**
  14441. * Gets the current list of size gradients.
  14442. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14443. * @returns the list of size gradients
  14444. */
  14445. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14446. /**
  14447. * Gets the current list of angular speed gradients.
  14448. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14449. * @returns the list of angular speed gradients
  14450. */
  14451. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14452. /**
  14453. * Adds a new angular speed gradient
  14454. * @param gradient defines the gradient to use (between 0 and 1)
  14455. * @param factor defines the angular speed to affect to the specified gradient
  14456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14457. * @returns the current particle system
  14458. */
  14459. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14460. /**
  14461. * Remove a specific angular speed gradient
  14462. * @param gradient defines the gradient to remove
  14463. * @returns the current particle system
  14464. */
  14465. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14466. /**
  14467. * Gets the current list of velocity gradients.
  14468. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14469. * @returns the list of velocity gradients
  14470. */
  14471. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14472. /**
  14473. * Adds a new velocity gradient
  14474. * @param gradient defines the gradient to use (between 0 and 1)
  14475. * @param factor defines the velocity to affect to the specified gradient
  14476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14477. * @returns the current particle system
  14478. */
  14479. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14480. /**
  14481. * Remove a specific velocity gradient
  14482. * @param gradient defines the gradient to remove
  14483. * @returns the current particle system
  14484. */
  14485. removeVelocityGradient(gradient: number): IParticleSystem;
  14486. /**
  14487. * Gets the current list of limit velocity gradients.
  14488. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14489. * @returns the list of limit velocity gradients
  14490. */
  14491. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14492. /**
  14493. * Adds a new limit velocity gradient
  14494. * @param gradient defines the gradient to use (between 0 and 1)
  14495. * @param factor defines the limit velocity to affect to the specified gradient
  14496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14497. * @returns the current particle system
  14498. */
  14499. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14500. /**
  14501. * Remove a specific limit velocity gradient
  14502. * @param gradient defines the gradient to remove
  14503. * @returns the current particle system
  14504. */
  14505. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14506. /**
  14507. * Adds a new drag gradient
  14508. * @param gradient defines the gradient to use (between 0 and 1)
  14509. * @param factor defines the drag to affect to the specified gradient
  14510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14511. * @returns the current particle system
  14512. */
  14513. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14514. /**
  14515. * Remove a specific drag gradient
  14516. * @param gradient defines the gradient to remove
  14517. * @returns the current particle system
  14518. */
  14519. removeDragGradient(gradient: number): IParticleSystem;
  14520. /**
  14521. * Gets the current list of drag gradients.
  14522. * You must use addDragGradient and removeDragGradient to udpate this list
  14523. * @returns the list of drag gradients
  14524. */
  14525. getDragGradients(): Nullable<Array<FactorGradient>>;
  14526. /**
  14527. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14528. * @param gradient defines the gradient to use (between 0 and 1)
  14529. * @param factor defines the emit rate to affect to the specified gradient
  14530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14531. * @returns the current particle system
  14532. */
  14533. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14534. /**
  14535. * Remove a specific emit rate gradient
  14536. * @param gradient defines the gradient to remove
  14537. * @returns the current particle system
  14538. */
  14539. removeEmitRateGradient(gradient: number): IParticleSystem;
  14540. /**
  14541. * Gets the current list of emit rate gradients.
  14542. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14543. * @returns the list of emit rate gradients
  14544. */
  14545. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14546. /**
  14547. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14548. * @param gradient defines the gradient to use (between 0 and 1)
  14549. * @param factor defines the start size to affect to the specified gradient
  14550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14551. * @returns the current particle system
  14552. */
  14553. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14554. /**
  14555. * Remove a specific start size gradient
  14556. * @param gradient defines the gradient to remove
  14557. * @returns the current particle system
  14558. */
  14559. removeStartSizeGradient(gradient: number): IParticleSystem;
  14560. /**
  14561. * Gets the current list of start size gradients.
  14562. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14563. * @returns the list of start size gradients
  14564. */
  14565. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14566. /**
  14567. * Adds a new life time gradient
  14568. * @param gradient defines the gradient to use (between 0 and 1)
  14569. * @param factor defines the life time factor to affect to the specified gradient
  14570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14571. * @returns the current particle system
  14572. */
  14573. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14574. /**
  14575. * Remove a specific life time gradient
  14576. * @param gradient defines the gradient to remove
  14577. * @returns the current particle system
  14578. */
  14579. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14580. /**
  14581. * Gets the current list of life time gradients.
  14582. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14583. * @returns the list of life time gradients
  14584. */
  14585. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14586. /**
  14587. * Gets the current list of color gradients.
  14588. * You must use addColorGradient and removeColorGradient to udpate this list
  14589. * @returns the list of color gradients
  14590. */
  14591. getColorGradients(): Nullable<Array<ColorGradient>>;
  14592. /**
  14593. * Adds a new ramp gradient used to remap particle colors
  14594. * @param gradient defines the gradient to use (between 0 and 1)
  14595. * @param color defines the color to affect to the specified gradient
  14596. * @returns the current particle system
  14597. */
  14598. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14599. /**
  14600. * Gets the current list of ramp gradients.
  14601. * You must use addRampGradient and removeRampGradient to udpate this list
  14602. * @returns the list of ramp gradients
  14603. */
  14604. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14605. /** Gets or sets a boolean indicating that ramp gradients must be used
  14606. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14607. */
  14608. useRampGradients: boolean;
  14609. /**
  14610. * Adds a new color remap gradient
  14611. * @param gradient defines the gradient to use (between 0 and 1)
  14612. * @param min defines the color remap minimal range
  14613. * @param max defines the color remap maximal range
  14614. * @returns the current particle system
  14615. */
  14616. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14617. /**
  14618. * Gets the current list of color remap gradients.
  14619. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14620. * @returns the list of color remap gradients
  14621. */
  14622. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14623. /**
  14624. * Adds a new alpha remap gradient
  14625. * @param gradient defines the gradient to use (between 0 and 1)
  14626. * @param min defines the alpha remap minimal range
  14627. * @param max defines the alpha remap maximal range
  14628. * @returns the current particle system
  14629. */
  14630. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14631. /**
  14632. * Gets the current list of alpha remap gradients.
  14633. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14634. * @returns the list of alpha remap gradients
  14635. */
  14636. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14637. /**
  14638. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14639. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14640. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14641. * @returns the emitter
  14642. */
  14643. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14644. /**
  14645. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14646. * @param radius The radius of the hemisphere to emit from
  14647. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14648. * @returns the emitter
  14649. */
  14650. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14651. /**
  14652. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14653. * @param radius The radius of the sphere to emit from
  14654. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14655. * @returns the emitter
  14656. */
  14657. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14658. /**
  14659. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14660. * @param radius The radius of the sphere to emit from
  14661. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14662. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14663. * @returns the emitter
  14664. */
  14665. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14666. /**
  14667. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14668. * @param radius The radius of the emission cylinder
  14669. * @param height The height of the emission cylinder
  14670. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14671. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14672. * @returns the emitter
  14673. */
  14674. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14675. /**
  14676. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14677. * @param radius The radius of the cylinder to emit from
  14678. * @param height The height of the emission cylinder
  14679. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14680. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14681. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14682. * @returns the emitter
  14683. */
  14684. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14685. /**
  14686. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14687. * @param radius The radius of the cone to emit from
  14688. * @param angle The base angle of the cone
  14689. * @returns the emitter
  14690. */
  14691. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14692. /**
  14693. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14696. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14697. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14698. * @returns the emitter
  14699. */
  14700. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14701. /**
  14702. * Get hosting scene
  14703. * @returns the scene
  14704. */
  14705. getScene(): Nullable<Scene>;
  14706. }
  14707. }
  14708. declare module BABYLON {
  14709. /**
  14710. * 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.
  14711. * @see https://doc.babylonjs.com/how_to/transformnode
  14712. */
  14713. export class TransformNode extends Node {
  14714. /**
  14715. * Object will not rotate to face the camera
  14716. */
  14717. static BILLBOARDMODE_NONE: number;
  14718. /**
  14719. * Object will rotate to face the camera but only on the x axis
  14720. */
  14721. static BILLBOARDMODE_X: number;
  14722. /**
  14723. * Object will rotate to face the camera but only on the y axis
  14724. */
  14725. static BILLBOARDMODE_Y: number;
  14726. /**
  14727. * Object will rotate to face the camera but only on the z axis
  14728. */
  14729. static BILLBOARDMODE_Z: number;
  14730. /**
  14731. * Object will rotate to face the camera
  14732. */
  14733. static BILLBOARDMODE_ALL: number;
  14734. /**
  14735. * Object will rotate to face the camera's position instead of orientation
  14736. */
  14737. static BILLBOARDMODE_USE_POSITION: number;
  14738. private static _TmpRotation;
  14739. private static _TmpScaling;
  14740. private static _TmpTranslation;
  14741. private _forward;
  14742. private _forwardInverted;
  14743. private _up;
  14744. private _right;
  14745. private _rightInverted;
  14746. private _position;
  14747. private _rotation;
  14748. private _rotationQuaternion;
  14749. protected _scaling: Vector3;
  14750. protected _isDirty: boolean;
  14751. private _transformToBoneReferal;
  14752. private _isAbsoluteSynced;
  14753. private _billboardMode;
  14754. /**
  14755. * Gets or sets the billboard mode. Default is 0.
  14756. *
  14757. * | Value | Type | Description |
  14758. * | --- | --- | --- |
  14759. * | 0 | BILLBOARDMODE_NONE | |
  14760. * | 1 | BILLBOARDMODE_X | |
  14761. * | 2 | BILLBOARDMODE_Y | |
  14762. * | 4 | BILLBOARDMODE_Z | |
  14763. * | 7 | BILLBOARDMODE_ALL | |
  14764. *
  14765. */
  14766. get billboardMode(): number;
  14767. set billboardMode(value: number);
  14768. private _preserveParentRotationForBillboard;
  14769. /**
  14770. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14771. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14772. */
  14773. get preserveParentRotationForBillboard(): boolean;
  14774. set preserveParentRotationForBillboard(value: boolean);
  14775. /**
  14776. * 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
  14777. */
  14778. scalingDeterminant: number;
  14779. private _infiniteDistance;
  14780. /**
  14781. * Gets or sets the distance of the object to max, often used by skybox
  14782. */
  14783. get infiniteDistance(): boolean;
  14784. set infiniteDistance(value: boolean);
  14785. /**
  14786. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14787. * By default the system will update normals to compensate
  14788. */
  14789. ignoreNonUniformScaling: boolean;
  14790. /**
  14791. * 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
  14792. */
  14793. reIntegrateRotationIntoRotationQuaternion: boolean;
  14794. /** @hidden */
  14795. _poseMatrix: Nullable<Matrix>;
  14796. /** @hidden */
  14797. _localMatrix: Matrix;
  14798. private _usePivotMatrix;
  14799. private _absolutePosition;
  14800. private _absoluteScaling;
  14801. private _absoluteRotationQuaternion;
  14802. private _pivotMatrix;
  14803. private _pivotMatrixInverse;
  14804. /** @hidden */
  14805. _postMultiplyPivotMatrix: boolean;
  14806. protected _isWorldMatrixFrozen: boolean;
  14807. /** @hidden */
  14808. _indexInSceneTransformNodesArray: number;
  14809. /**
  14810. * An event triggered after the world matrix is updated
  14811. */
  14812. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14813. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14814. /**
  14815. * Gets a string identifying the name of the class
  14816. * @returns "TransformNode" string
  14817. */
  14818. getClassName(): string;
  14819. /**
  14820. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14821. */
  14822. get position(): Vector3;
  14823. set position(newPosition: Vector3);
  14824. /**
  14825. * 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)).
  14826. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14827. */
  14828. get rotation(): Vector3;
  14829. set rotation(newRotation: Vector3);
  14830. /**
  14831. * 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)).
  14832. */
  14833. get scaling(): Vector3;
  14834. set scaling(newScaling: Vector3);
  14835. /**
  14836. * 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).
  14837. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14838. */
  14839. get rotationQuaternion(): Nullable<Quaternion>;
  14840. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14841. /**
  14842. * The forward direction of that transform in world space.
  14843. */
  14844. get forward(): Vector3;
  14845. /**
  14846. * The up direction of that transform in world space.
  14847. */
  14848. get up(): Vector3;
  14849. /**
  14850. * The right direction of that transform in world space.
  14851. */
  14852. get right(): Vector3;
  14853. /**
  14854. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14855. * @param matrix the matrix to copy the pose from
  14856. * @returns this TransformNode.
  14857. */
  14858. updatePoseMatrix(matrix: Matrix): TransformNode;
  14859. /**
  14860. * Returns the mesh Pose matrix.
  14861. * @returns the pose matrix
  14862. */
  14863. getPoseMatrix(): Matrix;
  14864. /** @hidden */
  14865. _isSynchronized(): boolean;
  14866. /** @hidden */
  14867. _initCache(): void;
  14868. /**
  14869. * Flag the transform node as dirty (Forcing it to update everything)
  14870. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14871. * @returns this transform node
  14872. */
  14873. markAsDirty(property: string): TransformNode;
  14874. /**
  14875. * Returns the current mesh absolute position.
  14876. * Returns a Vector3.
  14877. */
  14878. get absolutePosition(): Vector3;
  14879. /**
  14880. * Returns the current mesh absolute scaling.
  14881. * Returns a Vector3.
  14882. */
  14883. get absoluteScaling(): Vector3;
  14884. /**
  14885. * Returns the current mesh absolute rotation.
  14886. * Returns a Quaternion.
  14887. */
  14888. get absoluteRotationQuaternion(): Quaternion;
  14889. /**
  14890. * Sets a new matrix to apply before all other transformation
  14891. * @param matrix defines the transform matrix
  14892. * @returns the current TransformNode
  14893. */
  14894. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14895. /**
  14896. * Sets a new pivot matrix to the current node
  14897. * @param matrix defines the new pivot matrix to use
  14898. * @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
  14899. * @returns the current TransformNode
  14900. */
  14901. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14902. /**
  14903. * Returns the mesh pivot matrix.
  14904. * Default : Identity.
  14905. * @returns the matrix
  14906. */
  14907. getPivotMatrix(): Matrix;
  14908. /**
  14909. * Instantiate (when possible) or clone that node with its hierarchy
  14910. * @param newParent defines the new parent to use for the instance (or clone)
  14911. * @param options defines options to configure how copy is done
  14912. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14913. * @returns an instance (or a clone) of the current node with its hiearchy
  14914. */
  14915. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14916. doNotInstantiate: boolean;
  14917. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14918. /**
  14919. * Prevents the World matrix to be computed any longer
  14920. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14921. * @returns the TransformNode.
  14922. */
  14923. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14924. /**
  14925. * Allows back the World matrix computation.
  14926. * @returns the TransformNode.
  14927. */
  14928. unfreezeWorldMatrix(): this;
  14929. /**
  14930. * True if the World matrix has been frozen.
  14931. */
  14932. get isWorldMatrixFrozen(): boolean;
  14933. /**
  14934. * Retuns the mesh absolute position in the World.
  14935. * @returns a Vector3.
  14936. */
  14937. getAbsolutePosition(): Vector3;
  14938. /**
  14939. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14940. * @param absolutePosition the absolute position to set
  14941. * @returns the TransformNode.
  14942. */
  14943. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14944. /**
  14945. * Sets the mesh position in its local space.
  14946. * @param vector3 the position to set in localspace
  14947. * @returns the TransformNode.
  14948. */
  14949. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14950. /**
  14951. * Returns the mesh position in the local space from the current World matrix values.
  14952. * @returns a new Vector3.
  14953. */
  14954. getPositionExpressedInLocalSpace(): Vector3;
  14955. /**
  14956. * Translates the mesh along the passed Vector3 in its local space.
  14957. * @param vector3 the distance to translate in localspace
  14958. * @returns the TransformNode.
  14959. */
  14960. locallyTranslate(vector3: Vector3): TransformNode;
  14961. private static _lookAtVectorCache;
  14962. /**
  14963. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14964. * @param targetPoint the position (must be in same space as current mesh) to look at
  14965. * @param yawCor optional yaw (y-axis) correction in radians
  14966. * @param pitchCor optional pitch (x-axis) correction in radians
  14967. * @param rollCor optional roll (z-axis) correction in radians
  14968. * @param space the choosen space of the target
  14969. * @returns the TransformNode.
  14970. */
  14971. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14972. /**
  14973. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14974. * This Vector3 is expressed in the World space.
  14975. * @param localAxis axis to rotate
  14976. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14977. */
  14978. getDirection(localAxis: Vector3): Vector3;
  14979. /**
  14980. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14981. * localAxis is expressed in the mesh local space.
  14982. * result is computed in the Wordl space from the mesh World matrix.
  14983. * @param localAxis axis to rotate
  14984. * @param result the resulting transformnode
  14985. * @returns this TransformNode.
  14986. */
  14987. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14988. /**
  14989. * Sets this transform node rotation to the given local axis.
  14990. * @param localAxis the axis in local space
  14991. * @param yawCor optional yaw (y-axis) correction in radians
  14992. * @param pitchCor optional pitch (x-axis) correction in radians
  14993. * @param rollCor optional roll (z-axis) correction in radians
  14994. * @returns this TransformNode
  14995. */
  14996. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14997. /**
  14998. * Sets a new pivot point to the current node
  14999. * @param point defines the new pivot point to use
  15000. * @param space defines if the point is in world or local space (local by default)
  15001. * @returns the current TransformNode
  15002. */
  15003. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15004. /**
  15005. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15006. * @returns the pivot point
  15007. */
  15008. getPivotPoint(): Vector3;
  15009. /**
  15010. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15011. * @param result the vector3 to store the result
  15012. * @returns this TransformNode.
  15013. */
  15014. getPivotPointToRef(result: Vector3): TransformNode;
  15015. /**
  15016. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15017. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15018. */
  15019. getAbsolutePivotPoint(): Vector3;
  15020. /**
  15021. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15022. * @param result vector3 to store the result
  15023. * @returns this TransformNode.
  15024. */
  15025. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15026. /**
  15027. * Defines the passed node as the parent of the current node.
  15028. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15029. * @see https://doc.babylonjs.com/how_to/parenting
  15030. * @param node the node ot set as the parent
  15031. * @returns this TransformNode.
  15032. */
  15033. setParent(node: Nullable<Node>): TransformNode;
  15034. private _nonUniformScaling;
  15035. /**
  15036. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15037. */
  15038. get nonUniformScaling(): boolean;
  15039. /** @hidden */
  15040. _updateNonUniformScalingState(value: boolean): boolean;
  15041. /**
  15042. * Attach the current TransformNode to another TransformNode associated with a bone
  15043. * @param bone Bone affecting the TransformNode
  15044. * @param affectedTransformNode TransformNode associated with the bone
  15045. * @returns this object
  15046. */
  15047. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15048. /**
  15049. * Detach the transform node if its associated with a bone
  15050. * @returns this object
  15051. */
  15052. detachFromBone(): TransformNode;
  15053. private static _rotationAxisCache;
  15054. /**
  15055. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15056. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15057. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15058. * The passed axis is also normalized.
  15059. * @param axis the axis to rotate around
  15060. * @param amount the amount to rotate in radians
  15061. * @param space Space to rotate in (Default: local)
  15062. * @returns the TransformNode.
  15063. */
  15064. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15065. /**
  15066. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15067. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15068. * The passed axis is also normalized. .
  15069. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15070. * @param point the point to rotate around
  15071. * @param axis the axis to rotate around
  15072. * @param amount the amount to rotate in radians
  15073. * @returns the TransformNode
  15074. */
  15075. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15076. /**
  15077. * Translates the mesh along the axis vector for the passed distance in the given space.
  15078. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15079. * @param axis the axis to translate in
  15080. * @param distance the distance to translate
  15081. * @param space Space to rotate in (Default: local)
  15082. * @returns the TransformNode.
  15083. */
  15084. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15085. /**
  15086. * Adds a rotation step to the mesh current rotation.
  15087. * x, y, z are Euler angles expressed in radians.
  15088. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15089. * This means this rotation is made in the mesh local space only.
  15090. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15091. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15092. * ```javascript
  15093. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15094. * ```
  15095. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15096. * 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.
  15097. * @param x Rotation to add
  15098. * @param y Rotation to add
  15099. * @param z Rotation to add
  15100. * @returns the TransformNode.
  15101. */
  15102. addRotation(x: number, y: number, z: number): TransformNode;
  15103. /**
  15104. * @hidden
  15105. */
  15106. protected _getEffectiveParent(): Nullable<Node>;
  15107. /**
  15108. * Computes the world matrix of the node
  15109. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15110. * @returns the world matrix
  15111. */
  15112. computeWorldMatrix(force?: boolean): Matrix;
  15113. /**
  15114. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15115. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15116. */
  15117. resetLocalMatrix(independentOfChildren?: boolean): void;
  15118. protected _afterComputeWorldMatrix(): void;
  15119. /**
  15120. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15121. * @param func callback function to add
  15122. *
  15123. * @returns the TransformNode.
  15124. */
  15125. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15126. /**
  15127. * Removes a registered callback function.
  15128. * @param func callback function to remove
  15129. * @returns the TransformNode.
  15130. */
  15131. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15132. /**
  15133. * Gets the position of the current mesh in camera space
  15134. * @param camera defines the camera to use
  15135. * @returns a position
  15136. */
  15137. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15138. /**
  15139. * Returns the distance from the mesh to the active camera
  15140. * @param camera defines the camera to use
  15141. * @returns the distance
  15142. */
  15143. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15144. /**
  15145. * Clone the current transform node
  15146. * @param name Name of the new clone
  15147. * @param newParent New parent for the clone
  15148. * @param doNotCloneChildren Do not clone children hierarchy
  15149. * @returns the new transform node
  15150. */
  15151. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15152. /**
  15153. * Serializes the objects information.
  15154. * @param currentSerializationObject defines the object to serialize in
  15155. * @returns the serialized object
  15156. */
  15157. serialize(currentSerializationObject?: any): any;
  15158. /**
  15159. * Returns a new TransformNode object parsed from the source provided.
  15160. * @param parsedTransformNode is the source.
  15161. * @param scene the scne the object belongs to
  15162. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15163. * @returns a new TransformNode object parsed from the source provided.
  15164. */
  15165. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15166. /**
  15167. * Get all child-transformNodes of this node
  15168. * @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
  15169. * @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
  15170. * @returns an array of TransformNode
  15171. */
  15172. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15173. /**
  15174. * Releases resources associated with this transform node.
  15175. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15176. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15177. */
  15178. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15179. /**
  15180. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15181. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15182. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15183. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15184. * @returns the current mesh
  15185. */
  15186. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15187. private _syncAbsoluteScalingAndRotation;
  15188. }
  15189. }
  15190. declare module BABYLON {
  15191. /**
  15192. * Class used to override all child animations of a given target
  15193. */
  15194. export class AnimationPropertiesOverride {
  15195. /**
  15196. * Gets or sets a value indicating if animation blending must be used
  15197. */
  15198. enableBlending: boolean;
  15199. /**
  15200. * Gets or sets the blending speed to use when enableBlending is true
  15201. */
  15202. blendingSpeed: number;
  15203. /**
  15204. * Gets or sets the default loop mode to use
  15205. */
  15206. loopMode: number;
  15207. }
  15208. }
  15209. declare module BABYLON {
  15210. /**
  15211. * Class used to store bone information
  15212. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15213. */
  15214. export class Bone extends Node {
  15215. /**
  15216. * defines the bone name
  15217. */
  15218. name: string;
  15219. private static _tmpVecs;
  15220. private static _tmpQuat;
  15221. private static _tmpMats;
  15222. /**
  15223. * Gets the list of child bones
  15224. */
  15225. children: Bone[];
  15226. /** Gets the animations associated with this bone */
  15227. animations: Animation[];
  15228. /**
  15229. * Gets or sets bone length
  15230. */
  15231. length: number;
  15232. /**
  15233. * @hidden Internal only
  15234. * Set this value to map this bone to a different index in the transform matrices
  15235. * Set this value to -1 to exclude the bone from the transform matrices
  15236. */
  15237. _index: Nullable<number>;
  15238. private _skeleton;
  15239. private _localMatrix;
  15240. private _restPose;
  15241. private _bindPose;
  15242. private _baseMatrix;
  15243. private _absoluteTransform;
  15244. private _invertedAbsoluteTransform;
  15245. private _parent;
  15246. private _scalingDeterminant;
  15247. private _worldTransform;
  15248. private _localScaling;
  15249. private _localRotation;
  15250. private _localPosition;
  15251. private _needToDecompose;
  15252. private _needToCompose;
  15253. /** @hidden */
  15254. _linkedTransformNode: Nullable<TransformNode>;
  15255. /** @hidden */
  15256. _waitingTransformNodeId: Nullable<string>;
  15257. /** @hidden */
  15258. get _matrix(): Matrix;
  15259. /** @hidden */
  15260. set _matrix(value: Matrix);
  15261. /**
  15262. * Create a new bone
  15263. * @param name defines the bone name
  15264. * @param skeleton defines the parent skeleton
  15265. * @param parentBone defines the parent (can be null if the bone is the root)
  15266. * @param localMatrix defines the local matrix
  15267. * @param restPose defines the rest pose matrix
  15268. * @param baseMatrix defines the base matrix
  15269. * @param index defines index of the bone in the hiearchy
  15270. */
  15271. constructor(
  15272. /**
  15273. * defines the bone name
  15274. */
  15275. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15276. /**
  15277. * Gets the current object class name.
  15278. * @return the class name
  15279. */
  15280. getClassName(): string;
  15281. /**
  15282. * Gets the parent skeleton
  15283. * @returns a skeleton
  15284. */
  15285. getSkeleton(): Skeleton;
  15286. /**
  15287. * Gets parent bone
  15288. * @returns a bone or null if the bone is the root of the bone hierarchy
  15289. */
  15290. getParent(): Nullable<Bone>;
  15291. /**
  15292. * Returns an array containing the root bones
  15293. * @returns an array containing the root bones
  15294. */
  15295. getChildren(): Array<Bone>;
  15296. /**
  15297. * Gets the node index in matrix array generated for rendering
  15298. * @returns the node index
  15299. */
  15300. getIndex(): number;
  15301. /**
  15302. * Sets the parent bone
  15303. * @param parent defines the parent (can be null if the bone is the root)
  15304. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15305. */
  15306. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15307. /**
  15308. * Gets the local matrix
  15309. * @returns a matrix
  15310. */
  15311. getLocalMatrix(): Matrix;
  15312. /**
  15313. * Gets the base matrix (initial matrix which remains unchanged)
  15314. * @returns a matrix
  15315. */
  15316. getBaseMatrix(): Matrix;
  15317. /**
  15318. * Gets the rest pose matrix
  15319. * @returns a matrix
  15320. */
  15321. getRestPose(): Matrix;
  15322. /**
  15323. * Sets the rest pose matrix
  15324. * @param matrix the local-space rest pose to set for this bone
  15325. */
  15326. setRestPose(matrix: Matrix): void;
  15327. /**
  15328. * Gets the bind pose matrix
  15329. * @returns the bind pose matrix
  15330. */
  15331. getBindPose(): Matrix;
  15332. /**
  15333. * Sets the bind pose matrix
  15334. * @param matrix the local-space bind pose to set for this bone
  15335. */
  15336. setBindPose(matrix: Matrix): void;
  15337. /**
  15338. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15339. */
  15340. getWorldMatrix(): Matrix;
  15341. /**
  15342. * Sets the local matrix to rest pose matrix
  15343. */
  15344. returnToRest(): void;
  15345. /**
  15346. * Gets the inverse of the absolute transform matrix.
  15347. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15348. * @returns a matrix
  15349. */
  15350. getInvertedAbsoluteTransform(): Matrix;
  15351. /**
  15352. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15353. * @returns a matrix
  15354. */
  15355. getAbsoluteTransform(): Matrix;
  15356. /**
  15357. * Links with the given transform node.
  15358. * The local matrix of this bone is copied from the transform node every frame.
  15359. * @param transformNode defines the transform node to link to
  15360. */
  15361. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15362. /**
  15363. * Gets the node used to drive the bone's transformation
  15364. * @returns a transform node or null
  15365. */
  15366. getTransformNode(): Nullable<TransformNode>;
  15367. /** Gets or sets current position (in local space) */
  15368. get position(): Vector3;
  15369. set position(newPosition: Vector3);
  15370. /** Gets or sets current rotation (in local space) */
  15371. get rotation(): Vector3;
  15372. set rotation(newRotation: Vector3);
  15373. /** Gets or sets current rotation quaternion (in local space) */
  15374. get rotationQuaternion(): Quaternion;
  15375. set rotationQuaternion(newRotation: Quaternion);
  15376. /** Gets or sets current scaling (in local space) */
  15377. get scaling(): Vector3;
  15378. set scaling(newScaling: Vector3);
  15379. /**
  15380. * Gets the animation properties override
  15381. */
  15382. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15383. private _decompose;
  15384. private _compose;
  15385. /**
  15386. * Update the base and local matrices
  15387. * @param matrix defines the new base or local matrix
  15388. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15389. * @param updateLocalMatrix defines if the local matrix should be updated
  15390. */
  15391. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15392. /** @hidden */
  15393. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15394. /**
  15395. * Flag the bone as dirty (Forcing it to update everything)
  15396. */
  15397. markAsDirty(): void;
  15398. /** @hidden */
  15399. _markAsDirtyAndCompose(): void;
  15400. private _markAsDirtyAndDecompose;
  15401. /**
  15402. * Translate the bone in local or world space
  15403. * @param vec The amount to translate the bone
  15404. * @param space The space that the translation is in
  15405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15406. */
  15407. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15408. /**
  15409. * Set the postion of the bone in local or world space
  15410. * @param position The position to set the bone
  15411. * @param space The space that the position is in
  15412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15413. */
  15414. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15415. /**
  15416. * Set the absolute position of the bone (world space)
  15417. * @param position The position to set the bone
  15418. * @param mesh The mesh that this bone is attached to
  15419. */
  15420. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15421. /**
  15422. * Scale the bone on the x, y and z axes (in local space)
  15423. * @param x The amount to scale the bone on the x axis
  15424. * @param y The amount to scale the bone on the y axis
  15425. * @param z The amount to scale the bone on the z axis
  15426. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15427. */
  15428. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15429. /**
  15430. * Set the bone scaling in local space
  15431. * @param scale defines the scaling vector
  15432. */
  15433. setScale(scale: Vector3): void;
  15434. /**
  15435. * Gets the current scaling in local space
  15436. * @returns the current scaling vector
  15437. */
  15438. getScale(): Vector3;
  15439. /**
  15440. * Gets the current scaling in local space and stores it in a target vector
  15441. * @param result defines the target vector
  15442. */
  15443. getScaleToRef(result: Vector3): void;
  15444. /**
  15445. * Set the yaw, pitch, and roll of the bone in local or world space
  15446. * @param yaw The rotation of the bone on the y axis
  15447. * @param pitch The rotation of the bone on the x axis
  15448. * @param roll The rotation of the bone on the z axis
  15449. * @param space The space that the axes of rotation are in
  15450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15451. */
  15452. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15453. /**
  15454. * Add a rotation to the bone on an axis in local or world space
  15455. * @param axis The axis to rotate the bone on
  15456. * @param amount The amount to rotate the bone
  15457. * @param space The space that the axis is in
  15458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15459. */
  15460. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15461. /**
  15462. * Set the rotation of the bone to a particular axis angle in local or world space
  15463. * @param axis The axis to rotate the bone on
  15464. * @param angle The angle that the bone should be rotated to
  15465. * @param space The space that the axis is in
  15466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15467. */
  15468. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15469. /**
  15470. * Set the euler rotation of the bone in local or world space
  15471. * @param rotation The euler rotation that the bone should be set to
  15472. * @param space The space that the rotation is in
  15473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15474. */
  15475. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15476. /**
  15477. * Set the quaternion rotation of the bone in local or world space
  15478. * @param quat The quaternion rotation that the bone should be set to
  15479. * @param space The space that the rotation is in
  15480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15481. */
  15482. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15483. /**
  15484. * Set the rotation matrix of the bone in local or world space
  15485. * @param rotMat The rotation matrix that the bone should be set to
  15486. * @param space The space that the rotation is in
  15487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15488. */
  15489. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15490. private _rotateWithMatrix;
  15491. private _getNegativeRotationToRef;
  15492. /**
  15493. * Get the position of the bone in local or world space
  15494. * @param space The space that the returned position is in
  15495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15496. * @returns The position of the bone
  15497. */
  15498. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15499. /**
  15500. * Copy the position of the bone to a vector3 in local or world space
  15501. * @param space The space that the returned position is in
  15502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15503. * @param result The vector3 to copy the position to
  15504. */
  15505. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15506. /**
  15507. * Get the absolute position of the bone (world space)
  15508. * @param mesh The mesh that this bone is attached to
  15509. * @returns The absolute position of the bone
  15510. */
  15511. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15512. /**
  15513. * Copy the absolute position of the bone (world space) to the result param
  15514. * @param mesh The mesh that this bone is attached to
  15515. * @param result The vector3 to copy the absolute position to
  15516. */
  15517. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15518. /**
  15519. * Compute the absolute transforms of this bone and its children
  15520. */
  15521. computeAbsoluteTransforms(): void;
  15522. /**
  15523. * Get the world direction from an axis that is in the local space of the bone
  15524. * @param localAxis The local direction that is used to compute the world direction
  15525. * @param mesh The mesh that this bone is attached to
  15526. * @returns The world direction
  15527. */
  15528. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15529. /**
  15530. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15531. * @param localAxis The local direction that is used to compute the world direction
  15532. * @param mesh The mesh that this bone is attached to
  15533. * @param result The vector3 that the world direction will be copied to
  15534. */
  15535. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15536. /**
  15537. * Get the euler rotation of the bone in local or world space
  15538. * @param space The space that the rotation should be in
  15539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15540. * @returns The euler rotation
  15541. */
  15542. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15543. /**
  15544. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15545. * @param space The space that the rotation should be in
  15546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15547. * @param result The vector3 that the rotation should be copied to
  15548. */
  15549. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15550. /**
  15551. * Get the quaternion rotation of the bone in either local or world space
  15552. * @param space The space that the rotation should be in
  15553. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15554. * @returns The quaternion rotation
  15555. */
  15556. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15557. /**
  15558. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15559. * @param space The space that the rotation should be in
  15560. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15561. * @param result The quaternion that the rotation should be copied to
  15562. */
  15563. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15564. /**
  15565. * Get the rotation matrix of the bone in local or world space
  15566. * @param space The space that the rotation should be in
  15567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15568. * @returns The rotation matrix
  15569. */
  15570. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15571. /**
  15572. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15573. * @param space The space that the rotation should be in
  15574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15575. * @param result The quaternion that the rotation should be copied to
  15576. */
  15577. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15578. /**
  15579. * Get the world position of a point that is in the local space of the bone
  15580. * @param position The local position
  15581. * @param mesh The mesh that this bone is attached to
  15582. * @returns The world position
  15583. */
  15584. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15585. /**
  15586. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15587. * @param position The local position
  15588. * @param mesh The mesh that this bone is attached to
  15589. * @param result The vector3 that the world position should be copied to
  15590. */
  15591. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15592. /**
  15593. * Get the local position of a point that is in world space
  15594. * @param position The world position
  15595. * @param mesh The mesh that this bone is attached to
  15596. * @returns The local position
  15597. */
  15598. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15599. /**
  15600. * Get the local position of a point that is in world space and copy it to the result param
  15601. * @param position The world position
  15602. * @param mesh The mesh that this bone is attached to
  15603. * @param result The vector3 that the local position should be copied to
  15604. */
  15605. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15606. /**
  15607. * Set the current local matrix as the restPose for this bone.
  15608. */
  15609. setCurrentPoseAsRest(): void;
  15610. }
  15611. }
  15612. declare module BABYLON {
  15613. /**
  15614. * Defines a runtime animation
  15615. */
  15616. export class RuntimeAnimation {
  15617. private _events;
  15618. /**
  15619. * The current frame of the runtime animation
  15620. */
  15621. private _currentFrame;
  15622. /**
  15623. * The animation used by the runtime animation
  15624. */
  15625. private _animation;
  15626. /**
  15627. * The target of the runtime animation
  15628. */
  15629. private _target;
  15630. /**
  15631. * The initiating animatable
  15632. */
  15633. private _host;
  15634. /**
  15635. * The original value of the runtime animation
  15636. */
  15637. private _originalValue;
  15638. /**
  15639. * The original blend value of the runtime animation
  15640. */
  15641. private _originalBlendValue;
  15642. /**
  15643. * The offsets cache of the runtime animation
  15644. */
  15645. private _offsetsCache;
  15646. /**
  15647. * The high limits cache of the runtime animation
  15648. */
  15649. private _highLimitsCache;
  15650. /**
  15651. * Specifies if the runtime animation has been stopped
  15652. */
  15653. private _stopped;
  15654. /**
  15655. * The blending factor of the runtime animation
  15656. */
  15657. private _blendingFactor;
  15658. /**
  15659. * The BabylonJS scene
  15660. */
  15661. private _scene;
  15662. /**
  15663. * The current value of the runtime animation
  15664. */
  15665. private _currentValue;
  15666. /** @hidden */
  15667. _animationState: _IAnimationState;
  15668. /**
  15669. * The active target of the runtime animation
  15670. */
  15671. private _activeTargets;
  15672. private _currentActiveTarget;
  15673. private _directTarget;
  15674. /**
  15675. * The target path of the runtime animation
  15676. */
  15677. private _targetPath;
  15678. /**
  15679. * The weight of the runtime animation
  15680. */
  15681. private _weight;
  15682. /**
  15683. * The ratio offset of the runtime animation
  15684. */
  15685. private _ratioOffset;
  15686. /**
  15687. * The previous delay of the runtime animation
  15688. */
  15689. private _previousDelay;
  15690. /**
  15691. * The previous ratio of the runtime animation
  15692. */
  15693. private _previousRatio;
  15694. private _enableBlending;
  15695. private _keys;
  15696. private _minFrame;
  15697. private _maxFrame;
  15698. private _minValue;
  15699. private _maxValue;
  15700. private _targetIsArray;
  15701. /**
  15702. * Gets the current frame of the runtime animation
  15703. */
  15704. get currentFrame(): number;
  15705. /**
  15706. * Gets the weight of the runtime animation
  15707. */
  15708. get weight(): number;
  15709. /**
  15710. * Gets the current value of the runtime animation
  15711. */
  15712. get currentValue(): any;
  15713. /**
  15714. * Gets the target path of the runtime animation
  15715. */
  15716. get targetPath(): string;
  15717. /**
  15718. * Gets the actual target of the runtime animation
  15719. */
  15720. get target(): any;
  15721. /**
  15722. * Gets the additive state of the runtime animation
  15723. */
  15724. get isAdditive(): boolean;
  15725. /** @hidden */
  15726. _onLoop: () => void;
  15727. /**
  15728. * Create a new RuntimeAnimation object
  15729. * @param target defines the target of the animation
  15730. * @param animation defines the source animation object
  15731. * @param scene defines the hosting scene
  15732. * @param host defines the initiating Animatable
  15733. */
  15734. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15735. private _preparePath;
  15736. /**
  15737. * Gets the animation from the runtime animation
  15738. */
  15739. get animation(): Animation;
  15740. /**
  15741. * Resets the runtime animation to the beginning
  15742. * @param restoreOriginal defines whether to restore the target property to the original value
  15743. */
  15744. reset(restoreOriginal?: boolean): void;
  15745. /**
  15746. * Specifies if the runtime animation is stopped
  15747. * @returns Boolean specifying if the runtime animation is stopped
  15748. */
  15749. isStopped(): boolean;
  15750. /**
  15751. * Disposes of the runtime animation
  15752. */
  15753. dispose(): void;
  15754. /**
  15755. * Apply the interpolated value to the target
  15756. * @param currentValue defines the value computed by the animation
  15757. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15758. */
  15759. setValue(currentValue: any, weight: number): void;
  15760. private _getOriginalValues;
  15761. private _setValue;
  15762. /**
  15763. * Gets the loop pmode of the runtime animation
  15764. * @returns Loop Mode
  15765. */
  15766. private _getCorrectLoopMode;
  15767. /**
  15768. * Move the current animation to a given frame
  15769. * @param frame defines the frame to move to
  15770. */
  15771. goToFrame(frame: number): void;
  15772. /**
  15773. * @hidden Internal use only
  15774. */
  15775. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15776. /**
  15777. * Execute the current animation
  15778. * @param delay defines the delay to add to the current frame
  15779. * @param from defines the lower bound of the animation range
  15780. * @param to defines the upper bound of the animation range
  15781. * @param loop defines if the current animation must loop
  15782. * @param speedRatio defines the current speed ratio
  15783. * @param weight defines the weight of the animation (default is -1 so no weight)
  15784. * @param onLoop optional callback called when animation loops
  15785. * @returns a boolean indicating if the animation is running
  15786. */
  15787. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15788. }
  15789. }
  15790. declare module BABYLON {
  15791. /**
  15792. * Class used to store an actual running animation
  15793. */
  15794. export class Animatable {
  15795. /** defines the target object */
  15796. target: any;
  15797. /** defines the starting frame number (default is 0) */
  15798. fromFrame: number;
  15799. /** defines the ending frame number (default is 100) */
  15800. toFrame: number;
  15801. /** defines if the animation must loop (default is false) */
  15802. loopAnimation: boolean;
  15803. /** defines a callback to call when animation ends if it is not looping */
  15804. onAnimationEnd?: (() => void) | null | undefined;
  15805. /** defines a callback to call when animation loops */
  15806. onAnimationLoop?: (() => void) | null | undefined;
  15807. /** defines whether the animation should be evaluated additively */
  15808. isAdditive: boolean;
  15809. private _localDelayOffset;
  15810. private _pausedDelay;
  15811. private _runtimeAnimations;
  15812. private _paused;
  15813. private _scene;
  15814. private _speedRatio;
  15815. private _weight;
  15816. private _syncRoot;
  15817. /**
  15818. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15819. * This will only apply for non looping animation (default is true)
  15820. */
  15821. disposeOnEnd: boolean;
  15822. /**
  15823. * Gets a boolean indicating if the animation has started
  15824. */
  15825. animationStarted: boolean;
  15826. /**
  15827. * Observer raised when the animation ends
  15828. */
  15829. onAnimationEndObservable: Observable<Animatable>;
  15830. /**
  15831. * Observer raised when the animation loops
  15832. */
  15833. onAnimationLoopObservable: Observable<Animatable>;
  15834. /**
  15835. * Gets the root Animatable used to synchronize and normalize animations
  15836. */
  15837. get syncRoot(): Nullable<Animatable>;
  15838. /**
  15839. * Gets the current frame of the first RuntimeAnimation
  15840. * Used to synchronize Animatables
  15841. */
  15842. get masterFrame(): number;
  15843. /**
  15844. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15845. */
  15846. get weight(): number;
  15847. set weight(value: number);
  15848. /**
  15849. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15850. */
  15851. get speedRatio(): number;
  15852. set speedRatio(value: number);
  15853. /**
  15854. * Creates a new Animatable
  15855. * @param scene defines the hosting scene
  15856. * @param target defines the target object
  15857. * @param fromFrame defines the starting frame number (default is 0)
  15858. * @param toFrame defines the ending frame number (default is 100)
  15859. * @param loopAnimation defines if the animation must loop (default is false)
  15860. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15861. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15862. * @param animations defines a group of animation to add to the new Animatable
  15863. * @param onAnimationLoop defines a callback to call when animation loops
  15864. * @param isAdditive defines whether the animation should be evaluated additively
  15865. */
  15866. constructor(scene: Scene,
  15867. /** defines the target object */
  15868. target: any,
  15869. /** defines the starting frame number (default is 0) */
  15870. fromFrame?: number,
  15871. /** defines the ending frame number (default is 100) */
  15872. toFrame?: number,
  15873. /** defines if the animation must loop (default is false) */
  15874. loopAnimation?: boolean, speedRatio?: number,
  15875. /** defines a callback to call when animation ends if it is not looping */
  15876. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15877. /** defines a callback to call when animation loops */
  15878. onAnimationLoop?: (() => void) | null | undefined,
  15879. /** defines whether the animation should be evaluated additively */
  15880. isAdditive?: boolean);
  15881. /**
  15882. * Synchronize and normalize current Animatable with a source Animatable
  15883. * This is useful when using animation weights and when animations are not of the same length
  15884. * @param root defines the root Animatable to synchronize with
  15885. * @returns the current Animatable
  15886. */
  15887. syncWith(root: Animatable): Animatable;
  15888. /**
  15889. * Gets the list of runtime animations
  15890. * @returns an array of RuntimeAnimation
  15891. */
  15892. getAnimations(): RuntimeAnimation[];
  15893. /**
  15894. * Adds more animations to the current animatable
  15895. * @param target defines the target of the animations
  15896. * @param animations defines the new animations to add
  15897. */
  15898. appendAnimations(target: any, animations: Animation[]): void;
  15899. /**
  15900. * Gets the source animation for a specific property
  15901. * @param property defines the propertyu to look for
  15902. * @returns null or the source animation for the given property
  15903. */
  15904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15905. /**
  15906. * Gets the runtime animation for a specific property
  15907. * @param property defines the propertyu to look for
  15908. * @returns null or the runtime animation for the given property
  15909. */
  15910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15911. /**
  15912. * Resets the animatable to its original state
  15913. */
  15914. reset(): void;
  15915. /**
  15916. * Allows the animatable to blend with current running animations
  15917. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15918. * @param blendingSpeed defines the blending speed to use
  15919. */
  15920. enableBlending(blendingSpeed: number): void;
  15921. /**
  15922. * Disable animation blending
  15923. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15924. */
  15925. disableBlending(): void;
  15926. /**
  15927. * Jump directly to a given frame
  15928. * @param frame defines the frame to jump to
  15929. */
  15930. goToFrame(frame: number): void;
  15931. /**
  15932. * Pause the animation
  15933. */
  15934. pause(): void;
  15935. /**
  15936. * Restart the animation
  15937. */
  15938. restart(): void;
  15939. private _raiseOnAnimationEnd;
  15940. /**
  15941. * Stop and delete the current animation
  15942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15943. * @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)
  15944. */
  15945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15946. /**
  15947. * Wait asynchronously for the animation to end
  15948. * @returns a promise which will be fullfilled when the animation ends
  15949. */
  15950. waitAsync(): Promise<Animatable>;
  15951. /** @hidden */
  15952. _animate(delay: number): boolean;
  15953. }
  15954. interface Scene {
  15955. /** @hidden */
  15956. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15957. /** @hidden */
  15958. _processLateAnimationBindingsForMatrices(holder: {
  15959. totalWeight: number;
  15960. totalAdditiveWeight: number;
  15961. animations: RuntimeAnimation[];
  15962. additiveAnimations: RuntimeAnimation[];
  15963. originalValue: Matrix;
  15964. }): any;
  15965. /** @hidden */
  15966. _processLateAnimationBindingsForQuaternions(holder: {
  15967. totalWeight: number;
  15968. totalAdditiveWeight: number;
  15969. animations: RuntimeAnimation[];
  15970. additiveAnimations: RuntimeAnimation[];
  15971. originalValue: Quaternion;
  15972. }, refQuaternion: Quaternion): Quaternion;
  15973. /** @hidden */
  15974. _processLateAnimationBindings(): void;
  15975. /**
  15976. * Will start the animation sequence of a given target
  15977. * @param target defines the target
  15978. * @param from defines from which frame should animation start
  15979. * @param to defines until which frame should animation run.
  15980. * @param weight defines the weight to apply to the animation (1.0 by default)
  15981. * @param loop defines if the animation loops
  15982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15983. * @param onAnimationEnd defines the function to be executed when the animation ends
  15984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15985. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15986. * @param onAnimationLoop defines the callback to call when an animation loops
  15987. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15988. * @returns the animatable object created for this animation
  15989. */
  15990. 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;
  15991. /**
  15992. * Will start the animation sequence of a given target
  15993. * @param target defines the target
  15994. * @param from defines from which frame should animation start
  15995. * @param to defines until which frame should animation run.
  15996. * @param loop defines if the animation loops
  15997. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15998. * @param onAnimationEnd defines the function to be executed when the animation ends
  15999. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16000. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16001. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16002. * @param onAnimationLoop defines the callback to call when an animation loops
  16003. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16004. * @returns the animatable object created for this animation
  16005. */
  16006. 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;
  16007. /**
  16008. * Will start the animation sequence of a given target and its hierarchy
  16009. * @param target defines the target
  16010. * @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.
  16011. * @param from defines from which frame should animation start
  16012. * @param to defines until which frame should animation run.
  16013. * @param loop defines if the animation loops
  16014. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16015. * @param onAnimationEnd defines the function to be executed when the animation ends
  16016. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16017. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16018. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16019. * @param onAnimationLoop defines the callback to call when an animation loops
  16020. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16021. * @returns the list of created animatables
  16022. */
  16023. 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[];
  16024. /**
  16025. * Begin a new animation on a given node
  16026. * @param target defines the target where the animation will take place
  16027. * @param animations defines the list of animations to start
  16028. * @param from defines the initial value
  16029. * @param to defines the final value
  16030. * @param loop defines if you want animation to loop (off by default)
  16031. * @param speedRatio defines the speed ratio to apply to all animations
  16032. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16033. * @param onAnimationLoop defines the callback to call when an animation loops
  16034. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16035. * @returns the list of created animatables
  16036. */
  16037. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16038. /**
  16039. * Begin a new animation on a given node and its hierarchy
  16040. * @param target defines the root node where the animation will take place
  16041. * @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.
  16042. * @param animations defines the list of animations to start
  16043. * @param from defines the initial value
  16044. * @param to defines the final value
  16045. * @param loop defines if you want animation to loop (off by default)
  16046. * @param speedRatio defines the speed ratio to apply to all animations
  16047. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16048. * @param onAnimationLoop defines the callback to call when an animation loops
  16049. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16050. * @returns the list of animatables created for all nodes
  16051. */
  16052. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16053. /**
  16054. * Gets the animatable associated with a specific target
  16055. * @param target defines the target of the animatable
  16056. * @returns the required animatable if found
  16057. */
  16058. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16059. /**
  16060. * Gets all animatables associated with a given target
  16061. * @param target defines the target to look animatables for
  16062. * @returns an array of Animatables
  16063. */
  16064. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16065. /**
  16066. * Stops and removes all animations that have been applied to the scene
  16067. */
  16068. stopAllAnimations(): void;
  16069. /**
  16070. * Gets the current delta time used by animation engine
  16071. */
  16072. deltaTime: number;
  16073. }
  16074. interface Bone {
  16075. /**
  16076. * Copy an animation range from another bone
  16077. * @param source defines the source bone
  16078. * @param rangeName defines the range name to copy
  16079. * @param frameOffset defines the frame offset
  16080. * @param rescaleAsRequired defines if rescaling must be applied if required
  16081. * @param skelDimensionsRatio defines the scaling ratio
  16082. * @returns true if operation was successful
  16083. */
  16084. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16085. }
  16086. }
  16087. declare module BABYLON {
  16088. /**
  16089. * Class used to handle skinning animations
  16090. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16091. */
  16092. export class Skeleton implements IAnimatable {
  16093. /** defines the skeleton name */
  16094. name: string;
  16095. /** defines the skeleton Id */
  16096. id: string;
  16097. /**
  16098. * Defines the list of child bones
  16099. */
  16100. bones: Bone[];
  16101. /**
  16102. * Defines an estimate of the dimension of the skeleton at rest
  16103. */
  16104. dimensionsAtRest: Vector3;
  16105. /**
  16106. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16107. */
  16108. needInitialSkinMatrix: boolean;
  16109. /**
  16110. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16111. */
  16112. overrideMesh: Nullable<AbstractMesh>;
  16113. /**
  16114. * Gets the list of animations attached to this skeleton
  16115. */
  16116. animations: Array<Animation>;
  16117. private _scene;
  16118. private _isDirty;
  16119. private _transformMatrices;
  16120. private _transformMatrixTexture;
  16121. private _meshesWithPoseMatrix;
  16122. private _animatables;
  16123. private _identity;
  16124. private _synchronizedWithMesh;
  16125. private _ranges;
  16126. private _lastAbsoluteTransformsUpdateId;
  16127. private _canUseTextureForBones;
  16128. private _uniqueId;
  16129. /** @hidden */
  16130. _numBonesWithLinkedTransformNode: number;
  16131. /** @hidden */
  16132. _hasWaitingData: Nullable<boolean>;
  16133. /** @hidden */
  16134. _waitingOverrideMeshId: Nullable<string>;
  16135. /**
  16136. * Specifies if the skeleton should be serialized
  16137. */
  16138. doNotSerialize: boolean;
  16139. private _useTextureToStoreBoneMatrices;
  16140. /**
  16141. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16142. * Please note that this option is not available if the hardware does not support it
  16143. */
  16144. get useTextureToStoreBoneMatrices(): boolean;
  16145. set useTextureToStoreBoneMatrices(value: boolean);
  16146. private _animationPropertiesOverride;
  16147. /**
  16148. * Gets or sets the animation properties override
  16149. */
  16150. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16151. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16152. /**
  16153. * List of inspectable custom properties (used by the Inspector)
  16154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16155. */
  16156. inspectableCustomProperties: IInspectable[];
  16157. /**
  16158. * An observable triggered before computing the skeleton's matrices
  16159. */
  16160. onBeforeComputeObservable: Observable<Skeleton>;
  16161. /**
  16162. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16163. */
  16164. get isUsingTextureForMatrices(): boolean;
  16165. /**
  16166. * Gets the unique ID of this skeleton
  16167. */
  16168. get uniqueId(): number;
  16169. /**
  16170. * Creates a new skeleton
  16171. * @param name defines the skeleton name
  16172. * @param id defines the skeleton Id
  16173. * @param scene defines the hosting scene
  16174. */
  16175. constructor(
  16176. /** defines the skeleton name */
  16177. name: string,
  16178. /** defines the skeleton Id */
  16179. id: string, scene: Scene);
  16180. /**
  16181. * Gets the current object class name.
  16182. * @return the class name
  16183. */
  16184. getClassName(): string;
  16185. /**
  16186. * Returns an array containing the root bones
  16187. * @returns an array containing the root bones
  16188. */
  16189. getChildren(): Array<Bone>;
  16190. /**
  16191. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16192. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16193. * @returns a Float32Array containing matrices data
  16194. */
  16195. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16196. /**
  16197. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16198. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16199. * @returns a raw texture containing the data
  16200. */
  16201. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16202. /**
  16203. * Gets the current hosting scene
  16204. * @returns a scene object
  16205. */
  16206. getScene(): Scene;
  16207. /**
  16208. * Gets a string representing the current skeleton data
  16209. * @param fullDetails defines a boolean indicating if we want a verbose version
  16210. * @returns a string representing the current skeleton data
  16211. */
  16212. toString(fullDetails?: boolean): string;
  16213. /**
  16214. * Get bone's index searching by name
  16215. * @param name defines bone's name to search for
  16216. * @return the indice of the bone. Returns -1 if not found
  16217. */
  16218. getBoneIndexByName(name: string): number;
  16219. /**
  16220. * Creater a new animation range
  16221. * @param name defines the name of the range
  16222. * @param from defines the start key
  16223. * @param to defines the end key
  16224. */
  16225. createAnimationRange(name: string, from: number, to: number): void;
  16226. /**
  16227. * Delete a specific animation range
  16228. * @param name defines the name of the range
  16229. * @param deleteFrames defines if frames must be removed as well
  16230. */
  16231. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16232. /**
  16233. * Gets a specific animation range
  16234. * @param name defines the name of the range to look for
  16235. * @returns the requested animation range or null if not found
  16236. */
  16237. getAnimationRange(name: string): Nullable<AnimationRange>;
  16238. /**
  16239. * Gets the list of all animation ranges defined on this skeleton
  16240. * @returns an array
  16241. */
  16242. getAnimationRanges(): Nullable<AnimationRange>[];
  16243. /**
  16244. * Copy animation range from a source skeleton.
  16245. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16246. * @param source defines the source skeleton
  16247. * @param name defines the name of the range to copy
  16248. * @param rescaleAsRequired defines if rescaling must be applied if required
  16249. * @returns true if operation was successful
  16250. */
  16251. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16252. /**
  16253. * Forces the skeleton to go to rest pose
  16254. */
  16255. returnToRest(): void;
  16256. private _getHighestAnimationFrame;
  16257. /**
  16258. * Begin a specific animation range
  16259. * @param name defines the name of the range to start
  16260. * @param loop defines if looping must be turned on (false by default)
  16261. * @param speedRatio defines the speed ratio to apply (1 by default)
  16262. * @param onAnimationEnd defines a callback which will be called when animation will end
  16263. * @returns a new animatable
  16264. */
  16265. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16266. /**
  16267. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16268. * @param skeleton defines the Skeleton containing the animation range to convert
  16269. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16270. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16271. * @returns the original skeleton
  16272. */
  16273. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16274. /** @hidden */
  16275. _markAsDirty(): void;
  16276. /** @hidden */
  16277. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16278. /** @hidden */
  16279. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16280. private _computeTransformMatrices;
  16281. /**
  16282. * Build all resources required to render a skeleton
  16283. */
  16284. prepare(): void;
  16285. /**
  16286. * Gets the list of animatables currently running for this skeleton
  16287. * @returns an array of animatables
  16288. */
  16289. getAnimatables(): IAnimatable[];
  16290. /**
  16291. * Clone the current skeleton
  16292. * @param name defines the name of the new skeleton
  16293. * @param id defines the id of the new skeleton
  16294. * @returns the new skeleton
  16295. */
  16296. clone(name: string, id?: string): Skeleton;
  16297. /**
  16298. * Enable animation blending for this skeleton
  16299. * @param blendingSpeed defines the blending speed to apply
  16300. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16301. */
  16302. enableBlending(blendingSpeed?: number): void;
  16303. /**
  16304. * Releases all resources associated with the current skeleton
  16305. */
  16306. dispose(): void;
  16307. /**
  16308. * Serialize the skeleton in a JSON object
  16309. * @returns a JSON object
  16310. */
  16311. serialize(): any;
  16312. /**
  16313. * Creates a new skeleton from serialized data
  16314. * @param parsedSkeleton defines the serialized data
  16315. * @param scene defines the hosting scene
  16316. * @returns a new skeleton
  16317. */
  16318. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16319. /**
  16320. * Compute all node absolute transforms
  16321. * @param forceUpdate defines if computation must be done even if cache is up to date
  16322. */
  16323. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16324. /**
  16325. * Gets the root pose matrix
  16326. * @returns a matrix
  16327. */
  16328. getPoseMatrix(): Nullable<Matrix>;
  16329. /**
  16330. * Sorts bones per internal index
  16331. */
  16332. sortBones(): void;
  16333. private _sortBones;
  16334. /**
  16335. * Set the current local matrix as the restPose for all bones in the skeleton.
  16336. */
  16337. setCurrentPoseAsRest(): void;
  16338. }
  16339. }
  16340. declare module BABYLON {
  16341. /**
  16342. * Creates an instance based on a source mesh.
  16343. */
  16344. export class InstancedMesh extends AbstractMesh {
  16345. private _sourceMesh;
  16346. private _currentLOD;
  16347. /** @hidden */
  16348. _indexInSourceMeshInstanceArray: number;
  16349. constructor(name: string, source: Mesh);
  16350. /**
  16351. * Returns the string "InstancedMesh".
  16352. */
  16353. getClassName(): string;
  16354. /** Gets the list of lights affecting that mesh */
  16355. get lightSources(): Light[];
  16356. _resyncLightSources(): void;
  16357. _resyncLightSource(light: Light): void;
  16358. _removeLightSource(light: Light, dispose: boolean): void;
  16359. /**
  16360. * If the source mesh receives shadows
  16361. */
  16362. get receiveShadows(): boolean;
  16363. /**
  16364. * The material of the source mesh
  16365. */
  16366. get material(): Nullable<Material>;
  16367. /**
  16368. * Visibility of the source mesh
  16369. */
  16370. get visibility(): number;
  16371. /**
  16372. * Skeleton of the source mesh
  16373. */
  16374. get skeleton(): Nullable<Skeleton>;
  16375. /**
  16376. * Rendering ground id of the source mesh
  16377. */
  16378. get renderingGroupId(): number;
  16379. set renderingGroupId(value: number);
  16380. /**
  16381. * Returns the total number of vertices (integer).
  16382. */
  16383. getTotalVertices(): number;
  16384. /**
  16385. * Returns a positive integer : the total number of indices in this mesh geometry.
  16386. * @returns the numner of indices or zero if the mesh has no geometry.
  16387. */
  16388. getTotalIndices(): number;
  16389. /**
  16390. * The source mesh of the instance
  16391. */
  16392. get sourceMesh(): Mesh;
  16393. /**
  16394. * Creates a new InstancedMesh object from the mesh model.
  16395. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16396. * @param name defines the name of the new instance
  16397. * @returns a new InstancedMesh
  16398. */
  16399. createInstance(name: string): InstancedMesh;
  16400. /**
  16401. * Is this node ready to be used/rendered
  16402. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16403. * @return {boolean} is it ready
  16404. */
  16405. isReady(completeCheck?: boolean): boolean;
  16406. /**
  16407. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16408. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16409. * @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.
  16410. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16411. */
  16412. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16413. /**
  16414. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16415. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16416. * The `data` are either a numeric array either a Float32Array.
  16417. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16418. * 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).
  16419. * Note that a new underlying VertexBuffer object is created each call.
  16420. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16421. *
  16422. * Possible `kind` values :
  16423. * - VertexBuffer.PositionKind
  16424. * - VertexBuffer.UVKind
  16425. * - VertexBuffer.UV2Kind
  16426. * - VertexBuffer.UV3Kind
  16427. * - VertexBuffer.UV4Kind
  16428. * - VertexBuffer.UV5Kind
  16429. * - VertexBuffer.UV6Kind
  16430. * - VertexBuffer.ColorKind
  16431. * - VertexBuffer.MatricesIndicesKind
  16432. * - VertexBuffer.MatricesIndicesExtraKind
  16433. * - VertexBuffer.MatricesWeightsKind
  16434. * - VertexBuffer.MatricesWeightsExtraKind
  16435. *
  16436. * Returns the Mesh.
  16437. */
  16438. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16439. /**
  16440. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16441. * If the mesh has no geometry, it is simply returned as it is.
  16442. * The `data` are either a numeric array either a Float32Array.
  16443. * No new underlying VertexBuffer object is created.
  16444. * 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.
  16445. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16446. *
  16447. * Possible `kind` values :
  16448. * - VertexBuffer.PositionKind
  16449. * - VertexBuffer.UVKind
  16450. * - VertexBuffer.UV2Kind
  16451. * - VertexBuffer.UV3Kind
  16452. * - VertexBuffer.UV4Kind
  16453. * - VertexBuffer.UV5Kind
  16454. * - VertexBuffer.UV6Kind
  16455. * - VertexBuffer.ColorKind
  16456. * - VertexBuffer.MatricesIndicesKind
  16457. * - VertexBuffer.MatricesIndicesExtraKind
  16458. * - VertexBuffer.MatricesWeightsKind
  16459. * - VertexBuffer.MatricesWeightsExtraKind
  16460. *
  16461. * Returns the Mesh.
  16462. */
  16463. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16464. /**
  16465. * Sets the mesh indices.
  16466. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16467. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16468. * This method creates a new index buffer each call.
  16469. * Returns the Mesh.
  16470. */
  16471. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16472. /**
  16473. * Boolean : True if the mesh owns the requested kind of data.
  16474. */
  16475. isVerticesDataPresent(kind: string): boolean;
  16476. /**
  16477. * Returns an array of indices (IndicesArray).
  16478. */
  16479. getIndices(): Nullable<IndicesArray>;
  16480. get _positions(): Nullable<Vector3[]>;
  16481. /**
  16482. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16483. * This means the mesh underlying bounding box and sphere are recomputed.
  16484. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16485. * @returns the current mesh
  16486. */
  16487. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16488. /** @hidden */
  16489. _preActivate(): InstancedMesh;
  16490. /** @hidden */
  16491. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16492. /** @hidden */
  16493. _postActivate(): void;
  16494. getWorldMatrix(): Matrix;
  16495. get isAnInstance(): boolean;
  16496. /**
  16497. * Returns the current associated LOD AbstractMesh.
  16498. */
  16499. getLOD(camera: Camera): AbstractMesh;
  16500. /** @hidden */
  16501. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16502. /** @hidden */
  16503. _syncSubMeshes(): InstancedMesh;
  16504. /** @hidden */
  16505. _generatePointsArray(): boolean;
  16506. /** @hidden */
  16507. _updateBoundingInfo(): AbstractMesh;
  16508. /**
  16509. * Creates a new InstancedMesh from the current mesh.
  16510. * - name (string) : the cloned mesh name
  16511. * - newParent (optional Node) : the optional Node to parent the clone to.
  16512. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16513. *
  16514. * Returns the clone.
  16515. */
  16516. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16517. /**
  16518. * Disposes the InstancedMesh.
  16519. * Returns nothing.
  16520. */
  16521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16522. }
  16523. interface Mesh {
  16524. /**
  16525. * Register a custom buffer that will be instanced
  16526. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16527. * @param kind defines the buffer kind
  16528. * @param stride defines the stride in floats
  16529. */
  16530. registerInstancedBuffer(kind: string, stride: number): void;
  16531. /**
  16532. * true to use the edge renderer for all instances of this mesh
  16533. */
  16534. edgesShareWithInstances: boolean;
  16535. /** @hidden */
  16536. _userInstancedBuffersStorage: {
  16537. data: {
  16538. [key: string]: Float32Array;
  16539. };
  16540. sizes: {
  16541. [key: string]: number;
  16542. };
  16543. vertexBuffers: {
  16544. [key: string]: Nullable<VertexBuffer>;
  16545. };
  16546. strides: {
  16547. [key: string]: number;
  16548. };
  16549. };
  16550. }
  16551. interface AbstractMesh {
  16552. /**
  16553. * Object used to store instanced buffers defined by user
  16554. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16555. */
  16556. instancedBuffers: {
  16557. [key: string]: any;
  16558. };
  16559. }
  16560. }
  16561. declare module BABYLON {
  16562. /**
  16563. * Defines the options associated with the creation of a shader material.
  16564. */
  16565. export interface IShaderMaterialOptions {
  16566. /**
  16567. * Does the material work in alpha blend mode
  16568. */
  16569. needAlphaBlending: boolean;
  16570. /**
  16571. * Does the material work in alpha test mode
  16572. */
  16573. needAlphaTesting: boolean;
  16574. /**
  16575. * The list of attribute names used in the shader
  16576. */
  16577. attributes: string[];
  16578. /**
  16579. * The list of unifrom names used in the shader
  16580. */
  16581. uniforms: string[];
  16582. /**
  16583. * The list of UBO names used in the shader
  16584. */
  16585. uniformBuffers: string[];
  16586. /**
  16587. * The list of sampler names used in the shader
  16588. */
  16589. samplers: string[];
  16590. /**
  16591. * The list of defines used in the shader
  16592. */
  16593. defines: string[];
  16594. }
  16595. /**
  16596. * 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.
  16597. *
  16598. * This returned material effects how the mesh will look based on the code in the shaders.
  16599. *
  16600. * @see https://doc.babylonjs.com/how_to/shader_material
  16601. */
  16602. export class ShaderMaterial extends Material {
  16603. private _shaderPath;
  16604. private _options;
  16605. private _textures;
  16606. private _textureArrays;
  16607. private _floats;
  16608. private _ints;
  16609. private _floatsArrays;
  16610. private _colors3;
  16611. private _colors3Arrays;
  16612. private _colors4;
  16613. private _colors4Arrays;
  16614. private _vectors2;
  16615. private _vectors3;
  16616. private _vectors4;
  16617. private _matrices;
  16618. private _matrixArrays;
  16619. private _matrices3x3;
  16620. private _matrices2x2;
  16621. private _vectors2Arrays;
  16622. private _vectors3Arrays;
  16623. private _vectors4Arrays;
  16624. private _cachedWorldViewMatrix;
  16625. private _cachedWorldViewProjectionMatrix;
  16626. private _renderId;
  16627. private _multiview;
  16628. private _cachedDefines;
  16629. /** Define the Url to load snippets */
  16630. static SnippetUrl: string;
  16631. /** Snippet ID if the material was created from the snippet server */
  16632. snippetId: string;
  16633. /**
  16634. * Instantiate a new shader material.
  16635. * 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.
  16636. * This returned material effects how the mesh will look based on the code in the shaders.
  16637. * @see https://doc.babylonjs.com/how_to/shader_material
  16638. * @param name Define the name of the material in the scene
  16639. * @param scene Define the scene the material belongs to
  16640. * @param shaderPath Defines the route to the shader code in one of three ways:
  16641. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16642. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16643. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16644. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16645. * @param options Define the options used to create the shader
  16646. */
  16647. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16648. /**
  16649. * Gets the shader path used to define the shader code
  16650. * It can be modified to trigger a new compilation
  16651. */
  16652. get shaderPath(): any;
  16653. /**
  16654. * Sets the shader path used to define the shader code
  16655. * It can be modified to trigger a new compilation
  16656. */
  16657. set shaderPath(shaderPath: any);
  16658. /**
  16659. * Gets the options used to compile the shader.
  16660. * They can be modified to trigger a new compilation
  16661. */
  16662. get options(): IShaderMaterialOptions;
  16663. /**
  16664. * Gets the current class name of the material e.g. "ShaderMaterial"
  16665. * Mainly use in serialization.
  16666. * @returns the class name
  16667. */
  16668. getClassName(): string;
  16669. /**
  16670. * Specifies if the material will require alpha blending
  16671. * @returns a boolean specifying if alpha blending is needed
  16672. */
  16673. needAlphaBlending(): boolean;
  16674. /**
  16675. * Specifies if this material should be rendered in alpha test mode
  16676. * @returns a boolean specifying if an alpha test is needed.
  16677. */
  16678. needAlphaTesting(): boolean;
  16679. private _checkUniform;
  16680. /**
  16681. * Set a texture in the shader.
  16682. * @param name Define the name of the uniform samplers as defined in the shader
  16683. * @param texture Define the texture to bind to this sampler
  16684. * @return the material itself allowing "fluent" like uniform updates
  16685. */
  16686. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16687. /**
  16688. * Set a texture array in the shader.
  16689. * @param name Define the name of the uniform sampler array as defined in the shader
  16690. * @param textures Define the list of textures to bind to this sampler
  16691. * @return the material itself allowing "fluent" like uniform updates
  16692. */
  16693. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16694. /**
  16695. * Set a float in the shader.
  16696. * @param name Define the name of the uniform as defined in the shader
  16697. * @param value Define the value to give to the uniform
  16698. * @return the material itself allowing "fluent" like uniform updates
  16699. */
  16700. setFloat(name: string, value: number): ShaderMaterial;
  16701. /**
  16702. * Set a int in the shader.
  16703. * @param name Define the name of the uniform as defined in the shader
  16704. * @param value Define the value to give to the uniform
  16705. * @return the material itself allowing "fluent" like uniform updates
  16706. */
  16707. setInt(name: string, value: number): ShaderMaterial;
  16708. /**
  16709. * Set an array of floats in the shader.
  16710. * @param name Define the name of the uniform as defined in the shader
  16711. * @param value Define the value to give to the uniform
  16712. * @return the material itself allowing "fluent" like uniform updates
  16713. */
  16714. setFloats(name: string, value: number[]): ShaderMaterial;
  16715. /**
  16716. * Set a vec3 in the shader from a Color3.
  16717. * @param name Define the name of the uniform as defined in the shader
  16718. * @param value Define the value to give to the uniform
  16719. * @return the material itself allowing "fluent" like uniform updates
  16720. */
  16721. setColor3(name: string, value: Color3): ShaderMaterial;
  16722. /**
  16723. * Set a vec3 array in the shader from a Color3 array.
  16724. * @param name Define the name of the uniform as defined in the shader
  16725. * @param value Define the value to give to the uniform
  16726. * @return the material itself allowing "fluent" like uniform updates
  16727. */
  16728. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16729. /**
  16730. * Set a vec4 in the shader from a Color4.
  16731. * @param name Define the name of the uniform as defined in the shader
  16732. * @param value Define the value to give to the uniform
  16733. * @return the material itself allowing "fluent" like uniform updates
  16734. */
  16735. setColor4(name: string, value: Color4): ShaderMaterial;
  16736. /**
  16737. * Set a vec4 array in the shader from a Color4 array.
  16738. * @param name Define the name of the uniform as defined in the shader
  16739. * @param value Define the value to give to the uniform
  16740. * @return the material itself allowing "fluent" like uniform updates
  16741. */
  16742. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16743. /**
  16744. * Set a vec2 in the shader from a Vector2.
  16745. * @param name Define the name of the uniform as defined in the shader
  16746. * @param value Define the value to give to the uniform
  16747. * @return the material itself allowing "fluent" like uniform updates
  16748. */
  16749. setVector2(name: string, value: Vector2): ShaderMaterial;
  16750. /**
  16751. * Set a vec3 in the shader from a Vector3.
  16752. * @param name Define the name of the uniform as defined in the shader
  16753. * @param value Define the value to give to the uniform
  16754. * @return the material itself allowing "fluent" like uniform updates
  16755. */
  16756. setVector3(name: string, value: Vector3): ShaderMaterial;
  16757. /**
  16758. * Set a vec4 in the shader from a Vector4.
  16759. * @param name Define the name of the uniform as defined in the shader
  16760. * @param value Define the value to give to the uniform
  16761. * @return the material itself allowing "fluent" like uniform updates
  16762. */
  16763. setVector4(name: string, value: Vector4): ShaderMaterial;
  16764. /**
  16765. * Set a mat4 in the shader from a Matrix.
  16766. * @param name Define the name of the uniform as defined in the shader
  16767. * @param value Define the value to give to the uniform
  16768. * @return the material itself allowing "fluent" like uniform updates
  16769. */
  16770. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16771. /**
  16772. * Set a float32Array in the shader from a matrix array.
  16773. * @param name Define the name of the uniform as defined in the shader
  16774. * @param value Define the value to give to the uniform
  16775. * @return the material itself allowing "fluent" like uniform updates
  16776. */
  16777. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16778. /**
  16779. * Set a mat3 in the shader from a Float32Array.
  16780. * @param name Define the name of the uniform as defined in the shader
  16781. * @param value Define the value to give to the uniform
  16782. * @return the material itself allowing "fluent" like uniform updates
  16783. */
  16784. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16785. /**
  16786. * Set a mat2 in the shader from a Float32Array.
  16787. * @param name Define the name of the uniform as defined in the shader
  16788. * @param value Define the value to give to the uniform
  16789. * @return the material itself allowing "fluent" like uniform updates
  16790. */
  16791. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16792. /**
  16793. * Set a vec2 array in the shader from a number array.
  16794. * @param name Define the name of the uniform as defined in the shader
  16795. * @param value Define the value to give to the uniform
  16796. * @return the material itself allowing "fluent" like uniform updates
  16797. */
  16798. setArray2(name: string, value: number[]): ShaderMaterial;
  16799. /**
  16800. * Set a vec3 array in the shader from a number array.
  16801. * @param name Define the name of the uniform as defined in the shader
  16802. * @param value Define the value to give to the uniform
  16803. * @return the material itself allowing "fluent" like uniform updates
  16804. */
  16805. setArray3(name: string, value: number[]): ShaderMaterial;
  16806. /**
  16807. * Set a vec4 array in the shader from a number array.
  16808. * @param name Define the name of the uniform as defined in the shader
  16809. * @param value Define the value to give to the uniform
  16810. * @return the material itself allowing "fluent" like uniform updates
  16811. */
  16812. setArray4(name: string, value: number[]): ShaderMaterial;
  16813. private _checkCache;
  16814. /**
  16815. * Specifies that the submesh is ready to be used
  16816. * @param mesh defines the mesh to check
  16817. * @param subMesh defines which submesh to check
  16818. * @param useInstances specifies that instances should be used
  16819. * @returns a boolean indicating that the submesh is ready or not
  16820. */
  16821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16822. /**
  16823. * Checks if the material is ready to render the requested mesh
  16824. * @param mesh Define the mesh to render
  16825. * @param useInstances Define whether or not the material is used with instances
  16826. * @returns true if ready, otherwise false
  16827. */
  16828. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16829. /**
  16830. * Binds the world matrix to the material
  16831. * @param world defines the world transformation matrix
  16832. * @param effectOverride - If provided, use this effect instead of internal effect
  16833. */
  16834. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16835. /**
  16836. * Binds the submesh to this material by preparing the effect and shader to draw
  16837. * @param world defines the world transformation matrix
  16838. * @param mesh defines the mesh containing the submesh
  16839. * @param subMesh defines the submesh to bind the material to
  16840. */
  16841. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16842. /**
  16843. * Binds the material to the mesh
  16844. * @param world defines the world transformation matrix
  16845. * @param mesh defines the mesh to bind the material to
  16846. * @param effectOverride - If provided, use this effect instead of internal effect
  16847. */
  16848. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16849. protected _afterBind(mesh?: Mesh): void;
  16850. /**
  16851. * Gets the active textures from the material
  16852. * @returns an array of textures
  16853. */
  16854. getActiveTextures(): BaseTexture[];
  16855. /**
  16856. * Specifies if the material uses a texture
  16857. * @param texture defines the texture to check against the material
  16858. * @returns a boolean specifying if the material uses the texture
  16859. */
  16860. hasTexture(texture: BaseTexture): boolean;
  16861. /**
  16862. * Makes a duplicate of the material, and gives it a new name
  16863. * @param name defines the new name for the duplicated material
  16864. * @returns the cloned material
  16865. */
  16866. clone(name: string): ShaderMaterial;
  16867. /**
  16868. * Disposes the material
  16869. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16870. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16871. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16872. */
  16873. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16874. /**
  16875. * Serializes this material in a JSON representation
  16876. * @returns the serialized material object
  16877. */
  16878. serialize(): any;
  16879. /**
  16880. * Creates a shader material from parsed shader material data
  16881. * @param source defines the JSON represnetation of the material
  16882. * @param scene defines the hosting scene
  16883. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16884. * @returns a new material
  16885. */
  16886. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16887. /**
  16888. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16889. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16890. * @param url defines the url to load from
  16891. * @param scene defines the hosting scene
  16892. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16893. * @returns a promise that will resolve to the new ShaderMaterial
  16894. */
  16895. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16896. /**
  16897. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16898. * @param snippetId defines the snippet to load
  16899. * @param scene defines the hosting scene
  16900. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16901. * @returns a promise that will resolve to the new ShaderMaterial
  16902. */
  16903. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16904. }
  16905. }
  16906. declare module BABYLON {
  16907. /** @hidden */
  16908. export var colorPixelShader: {
  16909. name: string;
  16910. shader: string;
  16911. };
  16912. }
  16913. declare module BABYLON {
  16914. /** @hidden */
  16915. export var colorVertexShader: {
  16916. name: string;
  16917. shader: string;
  16918. };
  16919. }
  16920. declare module BABYLON {
  16921. /**
  16922. * Line mesh
  16923. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16924. */
  16925. export class LinesMesh extends Mesh {
  16926. /**
  16927. * If vertex color should be applied to the mesh
  16928. */
  16929. readonly useVertexColor?: boolean | undefined;
  16930. /**
  16931. * If vertex alpha should be applied to the mesh
  16932. */
  16933. readonly useVertexAlpha?: boolean | undefined;
  16934. /**
  16935. * Color of the line (Default: White)
  16936. */
  16937. color: Color3;
  16938. /**
  16939. * Alpha of the line (Default: 1)
  16940. */
  16941. alpha: number;
  16942. /**
  16943. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16944. * This margin is expressed in world space coordinates, so its value may vary.
  16945. * Default value is 0.1
  16946. */
  16947. intersectionThreshold: number;
  16948. private _colorShader;
  16949. private color4;
  16950. /**
  16951. * Creates a new LinesMesh
  16952. * @param name defines the name
  16953. * @param scene defines the hosting scene
  16954. * @param parent defines the parent mesh if any
  16955. * @param source defines the optional source LinesMesh used to clone data from
  16956. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16957. * When false, achieved by calling a clone(), also passing False.
  16958. * This will make creation of children, recursive.
  16959. * @param useVertexColor defines if this LinesMesh supports vertex color
  16960. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16961. */
  16962. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16963. /**
  16964. * If vertex color should be applied to the mesh
  16965. */
  16966. useVertexColor?: boolean | undefined,
  16967. /**
  16968. * If vertex alpha should be applied to the mesh
  16969. */
  16970. useVertexAlpha?: boolean | undefined);
  16971. private _addClipPlaneDefine;
  16972. private _removeClipPlaneDefine;
  16973. isReady(): boolean;
  16974. /**
  16975. * Returns the string "LineMesh"
  16976. */
  16977. getClassName(): string;
  16978. /**
  16979. * @hidden
  16980. */
  16981. get material(): Material;
  16982. /**
  16983. * @hidden
  16984. */
  16985. set material(value: Material);
  16986. /**
  16987. * @hidden
  16988. */
  16989. get checkCollisions(): boolean;
  16990. /** @hidden */
  16991. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16992. /** @hidden */
  16993. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16994. /**
  16995. * Disposes of the line mesh
  16996. * @param doNotRecurse If children should be disposed
  16997. */
  16998. dispose(doNotRecurse?: boolean): void;
  16999. /**
  17000. * Returns a new LineMesh object cloned from the current one.
  17001. */
  17002. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17003. /**
  17004. * Creates a new InstancedLinesMesh object from the mesh model.
  17005. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17006. * @param name defines the name of the new instance
  17007. * @returns a new InstancedLinesMesh
  17008. */
  17009. createInstance(name: string): InstancedLinesMesh;
  17010. }
  17011. /**
  17012. * Creates an instance based on a source LinesMesh
  17013. */
  17014. export class InstancedLinesMesh extends InstancedMesh {
  17015. /**
  17016. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17017. * This margin is expressed in world space coordinates, so its value may vary.
  17018. * Initilized with the intersectionThreshold value of the source LinesMesh
  17019. */
  17020. intersectionThreshold: number;
  17021. constructor(name: string, source: LinesMesh);
  17022. /**
  17023. * Returns the string "InstancedLinesMesh".
  17024. */
  17025. getClassName(): string;
  17026. }
  17027. }
  17028. declare module BABYLON {
  17029. /** @hidden */
  17030. export var linePixelShader: {
  17031. name: string;
  17032. shader: string;
  17033. };
  17034. }
  17035. declare module BABYLON {
  17036. /** @hidden */
  17037. export var lineVertexShader: {
  17038. name: string;
  17039. shader: string;
  17040. };
  17041. }
  17042. declare module BABYLON {
  17043. interface Scene {
  17044. /** @hidden */
  17045. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17046. }
  17047. interface AbstractMesh {
  17048. /**
  17049. * Gets the edgesRenderer associated with the mesh
  17050. */
  17051. edgesRenderer: Nullable<EdgesRenderer>;
  17052. }
  17053. interface LinesMesh {
  17054. /**
  17055. * Enables the edge rendering mode on the mesh.
  17056. * This mode makes the mesh edges visible
  17057. * @param epsilon defines the maximal distance between two angles to detect a face
  17058. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17059. * @returns the currentAbstractMesh
  17060. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17061. */
  17062. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17063. }
  17064. interface InstancedLinesMesh {
  17065. /**
  17066. * Enables the edge rendering mode on the mesh.
  17067. * This mode makes the mesh edges visible
  17068. * @param epsilon defines the maximal distance between two angles to detect a face
  17069. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17070. * @returns the current InstancedLinesMesh
  17071. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17072. */
  17073. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17074. }
  17075. /**
  17076. * Defines the minimum contract an Edges renderer should follow.
  17077. */
  17078. export interface IEdgesRenderer extends IDisposable {
  17079. /**
  17080. * Gets or sets a boolean indicating if the edgesRenderer is active
  17081. */
  17082. isEnabled: boolean;
  17083. /**
  17084. * Renders the edges of the attached mesh,
  17085. */
  17086. render(): void;
  17087. /**
  17088. * Checks wether or not the edges renderer is ready to render.
  17089. * @return true if ready, otherwise false.
  17090. */
  17091. isReady(): boolean;
  17092. /**
  17093. * List of instances to render in case the source mesh has instances
  17094. */
  17095. customInstances: SmartArray<Matrix>;
  17096. }
  17097. /**
  17098. * Defines the additional options of the edges renderer
  17099. */
  17100. export interface IEdgesRendererOptions {
  17101. /**
  17102. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17103. * If not defined, the default value is true
  17104. */
  17105. useAlternateEdgeFinder?: boolean;
  17106. /**
  17107. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17108. * If not defined, the default value is true.
  17109. * 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)
  17110. * This option is used only if useAlternateEdgeFinder = true
  17111. */
  17112. useFastVertexMerger?: boolean;
  17113. /**
  17114. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17115. * The default value is 1e-6
  17116. * This option is used only if useAlternateEdgeFinder = true
  17117. */
  17118. epsilonVertexMerge?: number;
  17119. /**
  17120. * 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
  17121. * 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.
  17122. * This option is used only if useAlternateEdgeFinder = true
  17123. */
  17124. applyTessellation?: boolean;
  17125. /**
  17126. * 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
  17127. * The default value is 1e-6
  17128. * This option is used only if useAlternateEdgeFinder = true
  17129. */
  17130. epsilonVertexAligned?: number;
  17131. }
  17132. /**
  17133. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17134. */
  17135. export class EdgesRenderer implements IEdgesRenderer {
  17136. /**
  17137. * Define the size of the edges with an orthographic camera
  17138. */
  17139. edgesWidthScalerForOrthographic: number;
  17140. /**
  17141. * Define the size of the edges with a perspective camera
  17142. */
  17143. edgesWidthScalerForPerspective: number;
  17144. protected _source: AbstractMesh;
  17145. protected _linesPositions: number[];
  17146. protected _linesNormals: number[];
  17147. protected _linesIndices: number[];
  17148. protected _epsilon: number;
  17149. protected _indicesCount: number;
  17150. protected _lineShader: ShaderMaterial;
  17151. protected _ib: DataBuffer;
  17152. protected _buffers: {
  17153. [key: string]: Nullable<VertexBuffer>;
  17154. };
  17155. protected _buffersForInstances: {
  17156. [key: string]: Nullable<VertexBuffer>;
  17157. };
  17158. protected _checkVerticesInsteadOfIndices: boolean;
  17159. protected _options: Nullable<IEdgesRendererOptions>;
  17160. private _meshRebuildObserver;
  17161. private _meshDisposeObserver;
  17162. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17163. isEnabled: boolean;
  17164. /**
  17165. * List of instances to render in case the source mesh has instances
  17166. */
  17167. customInstances: SmartArray<Matrix>;
  17168. private static GetShader;
  17169. /**
  17170. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17171. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17172. * @param source Mesh used to create edges
  17173. * @param epsilon sum of angles in adjacency to check for edge
  17174. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17175. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17176. * @param options The options to apply when generating the edges
  17177. */
  17178. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17179. protected _prepareRessources(): void;
  17180. /** @hidden */
  17181. _rebuild(): void;
  17182. /**
  17183. * Releases the required resources for the edges renderer
  17184. */
  17185. dispose(): void;
  17186. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17187. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17188. /**
  17189. * Checks if the pair of p0 and p1 is en edge
  17190. * @param faceIndex
  17191. * @param edge
  17192. * @param faceNormals
  17193. * @param p0
  17194. * @param p1
  17195. * @private
  17196. */
  17197. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17198. /**
  17199. * push line into the position, normal and index buffer
  17200. * @protected
  17201. */
  17202. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17203. /**
  17204. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17205. */
  17206. private _tessellateTriangle;
  17207. private _generateEdgesLinesAlternate;
  17208. /**
  17209. * Generates lines edges from adjacencjes
  17210. * @private
  17211. */
  17212. _generateEdgesLines(): void;
  17213. /**
  17214. * Checks wether or not the edges renderer is ready to render.
  17215. * @return true if ready, otherwise false.
  17216. */
  17217. isReady(): boolean;
  17218. /**
  17219. * Renders the edges of the attached mesh,
  17220. */
  17221. render(): void;
  17222. }
  17223. /**
  17224. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17225. */
  17226. export class LineEdgesRenderer extends EdgesRenderer {
  17227. /**
  17228. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17229. * @param source LineMesh used to generate edges
  17230. * @param epsilon not important (specified angle for edge detection)
  17231. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17232. */
  17233. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17234. /**
  17235. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17236. */
  17237. _generateEdgesLines(): void;
  17238. }
  17239. }
  17240. declare module BABYLON {
  17241. /**
  17242. * This represents the object necessary to create a rendering group.
  17243. * This is exclusively used and created by the rendering manager.
  17244. * To modify the behavior, you use the available helpers in your scene or meshes.
  17245. * @hidden
  17246. */
  17247. export class RenderingGroup {
  17248. index: number;
  17249. private static _zeroVector;
  17250. private _scene;
  17251. private _opaqueSubMeshes;
  17252. private _transparentSubMeshes;
  17253. private _alphaTestSubMeshes;
  17254. private _depthOnlySubMeshes;
  17255. private _particleSystems;
  17256. private _spriteManagers;
  17257. private _opaqueSortCompareFn;
  17258. private _alphaTestSortCompareFn;
  17259. private _transparentSortCompareFn;
  17260. private _renderOpaque;
  17261. private _renderAlphaTest;
  17262. private _renderTransparent;
  17263. /** @hidden */
  17264. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17265. onBeforeTransparentRendering: () => void;
  17266. /**
  17267. * Set the opaque sort comparison function.
  17268. * If null the sub meshes will be render in the order they were created
  17269. */
  17270. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17271. /**
  17272. * Set the alpha test sort comparison function.
  17273. * If null the sub meshes will be render in the order they were created
  17274. */
  17275. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17276. /**
  17277. * Set the transparent sort comparison function.
  17278. * If null the sub meshes will be render in the order they were created
  17279. */
  17280. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17281. /**
  17282. * Creates a new rendering group.
  17283. * @param index The rendering group index
  17284. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17285. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17286. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17287. */
  17288. 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>);
  17289. /**
  17290. * Render all the sub meshes contained in the group.
  17291. * @param customRenderFunction Used to override the default render behaviour of the group.
  17292. * @returns true if rendered some submeshes.
  17293. */
  17294. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17295. /**
  17296. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17297. * @param subMeshes The submeshes to render
  17298. */
  17299. private renderOpaqueSorted;
  17300. /**
  17301. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17302. * @param subMeshes The submeshes to render
  17303. */
  17304. private renderAlphaTestSorted;
  17305. /**
  17306. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17307. * @param subMeshes The submeshes to render
  17308. */
  17309. private renderTransparentSorted;
  17310. /**
  17311. * Renders the submeshes in a specified order.
  17312. * @param subMeshes The submeshes to sort before render
  17313. * @param sortCompareFn The comparison function use to sort
  17314. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17315. * @param transparent Specifies to activate blending if true
  17316. */
  17317. private static renderSorted;
  17318. /**
  17319. * Renders the submeshes in the order they were dispatched (no sort applied).
  17320. * @param subMeshes The submeshes to render
  17321. */
  17322. private static renderUnsorted;
  17323. /**
  17324. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17325. * are rendered back to front if in the same alpha index.
  17326. *
  17327. * @param a The first submesh
  17328. * @param b The second submesh
  17329. * @returns The result of the comparison
  17330. */
  17331. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17332. /**
  17333. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17334. * are rendered back to front.
  17335. *
  17336. * @param a The first submesh
  17337. * @param b The second submesh
  17338. * @returns The result of the comparison
  17339. */
  17340. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17341. /**
  17342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17343. * are rendered front to back (prevent overdraw).
  17344. *
  17345. * @param a The first submesh
  17346. * @param b The second submesh
  17347. * @returns The result of the comparison
  17348. */
  17349. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17350. /**
  17351. * Resets the different lists of submeshes to prepare a new frame.
  17352. */
  17353. prepare(): void;
  17354. dispose(): void;
  17355. /**
  17356. * Inserts the submesh in its correct queue depending on its material.
  17357. * @param subMesh The submesh to dispatch
  17358. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17359. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17360. */
  17361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17362. dispatchSprites(spriteManager: ISpriteManager): void;
  17363. dispatchParticles(particleSystem: IParticleSystem): void;
  17364. private _renderParticles;
  17365. private _renderSprites;
  17366. }
  17367. }
  17368. declare module BABYLON {
  17369. /**
  17370. * Interface describing the different options available in the rendering manager
  17371. * regarding Auto Clear between groups.
  17372. */
  17373. export interface IRenderingManagerAutoClearSetup {
  17374. /**
  17375. * Defines whether or not autoclear is enable.
  17376. */
  17377. autoClear: boolean;
  17378. /**
  17379. * Defines whether or not to autoclear the depth buffer.
  17380. */
  17381. depth: boolean;
  17382. /**
  17383. * Defines whether or not to autoclear the stencil buffer.
  17384. */
  17385. stencil: boolean;
  17386. }
  17387. /**
  17388. * This class is used by the onRenderingGroupObservable
  17389. */
  17390. export class RenderingGroupInfo {
  17391. /**
  17392. * The Scene that being rendered
  17393. */
  17394. scene: Scene;
  17395. /**
  17396. * The camera currently used for the rendering pass
  17397. */
  17398. camera: Nullable<Camera>;
  17399. /**
  17400. * The ID of the renderingGroup being processed
  17401. */
  17402. renderingGroupId: number;
  17403. }
  17404. /**
  17405. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17406. * It is enable to manage the different groups as well as the different necessary sort functions.
  17407. * This should not be used directly aside of the few static configurations
  17408. */
  17409. export class RenderingManager {
  17410. /**
  17411. * The max id used for rendering groups (not included)
  17412. */
  17413. static MAX_RENDERINGGROUPS: number;
  17414. /**
  17415. * The min id used for rendering groups (included)
  17416. */
  17417. static MIN_RENDERINGGROUPS: number;
  17418. /**
  17419. * Used to globally prevent autoclearing scenes.
  17420. */
  17421. static AUTOCLEAR: boolean;
  17422. /**
  17423. * @hidden
  17424. */
  17425. _useSceneAutoClearSetup: boolean;
  17426. private _scene;
  17427. private _renderingGroups;
  17428. private _depthStencilBufferAlreadyCleaned;
  17429. private _autoClearDepthStencil;
  17430. private _customOpaqueSortCompareFn;
  17431. private _customAlphaTestSortCompareFn;
  17432. private _customTransparentSortCompareFn;
  17433. private _renderingGroupInfo;
  17434. /**
  17435. * Instantiates a new rendering group for a particular scene
  17436. * @param scene Defines the scene the groups belongs to
  17437. */
  17438. constructor(scene: Scene);
  17439. private _clearDepthStencilBuffer;
  17440. /**
  17441. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17442. * @hidden
  17443. */
  17444. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17445. /**
  17446. * Resets the different information of the group to prepare a new frame
  17447. * @hidden
  17448. */
  17449. reset(): void;
  17450. /**
  17451. * Dispose and release the group and its associated resources.
  17452. * @hidden
  17453. */
  17454. dispose(): void;
  17455. /**
  17456. * Clear the info related to rendering groups preventing retention points during dispose.
  17457. */
  17458. freeRenderingGroups(): void;
  17459. private _prepareRenderingGroup;
  17460. /**
  17461. * Add a sprite manager to the rendering manager in order to render it this frame.
  17462. * @param spriteManager Define the sprite manager to render
  17463. */
  17464. dispatchSprites(spriteManager: ISpriteManager): void;
  17465. /**
  17466. * Add a particle system to the rendering manager in order to render it this frame.
  17467. * @param particleSystem Define the particle system to render
  17468. */
  17469. dispatchParticles(particleSystem: IParticleSystem): void;
  17470. /**
  17471. * Add a submesh to the manager in order to render it this frame
  17472. * @param subMesh The submesh to dispatch
  17473. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17474. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17475. */
  17476. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17477. /**
  17478. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17479. * This allowed control for front to back rendering or reversly depending of the special needs.
  17480. *
  17481. * @param renderingGroupId The rendering group id corresponding to its index
  17482. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17483. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17484. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17485. */
  17486. 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;
  17487. /**
  17488. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17489. *
  17490. * @param renderingGroupId The rendering group id corresponding to its index
  17491. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17492. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17493. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17494. */
  17495. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17496. /**
  17497. * Gets the current auto clear configuration for one rendering group of the rendering
  17498. * manager.
  17499. * @param index the rendering group index to get the information for
  17500. * @returns The auto clear setup for the requested rendering group
  17501. */
  17502. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17503. }
  17504. }
  17505. declare module BABYLON {
  17506. /**
  17507. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17508. */
  17509. export interface ICustomShaderOptions {
  17510. /**
  17511. * Gets or sets the custom shader name to use
  17512. */
  17513. shaderName: string;
  17514. /**
  17515. * The list of attribute names used in the shader
  17516. */
  17517. attributes?: string[];
  17518. /**
  17519. * The list of unifrom names used in the shader
  17520. */
  17521. uniforms?: string[];
  17522. /**
  17523. * The list of sampler names used in the shader
  17524. */
  17525. samplers?: string[];
  17526. /**
  17527. * The list of defines used in the shader
  17528. */
  17529. defines?: string[];
  17530. }
  17531. /**
  17532. * Interface to implement to create a shadow generator compatible with BJS.
  17533. */
  17534. export interface IShadowGenerator {
  17535. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17536. id: string;
  17537. /**
  17538. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17539. * @returns The render target texture if present otherwise, null
  17540. */
  17541. getShadowMap(): Nullable<RenderTargetTexture>;
  17542. /**
  17543. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17544. * @param subMesh The submesh we want to render in the shadow map
  17545. * @param useInstances Defines wether will draw in the map using instances
  17546. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17547. * @returns true if ready otherwise, false
  17548. */
  17549. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17550. /**
  17551. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17552. * @param defines Defines of the material we want to update
  17553. * @param lightIndex Index of the light in the enabled light list of the material
  17554. */
  17555. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17556. /**
  17557. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17558. * defined in the generator but impacting the effect).
  17559. * It implies the unifroms available on the materials are the standard BJS ones.
  17560. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17561. * @param effect The effect we are binfing the information for
  17562. */
  17563. bindShadowLight(lightIndex: string, effect: Effect): void;
  17564. /**
  17565. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17566. * (eq to shadow prjection matrix * light transform matrix)
  17567. * @returns The transform matrix used to create the shadow map
  17568. */
  17569. getTransformMatrix(): Matrix;
  17570. /**
  17571. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17572. * Cube and 2D textures for instance.
  17573. */
  17574. recreateShadowMap(): void;
  17575. /**
  17576. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17577. * @param onCompiled Callback triggered at the and of the effects compilation
  17578. * @param options Sets of optional options forcing the compilation with different modes
  17579. */
  17580. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17581. useInstances: boolean;
  17582. }>): void;
  17583. /**
  17584. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17585. * @param options Sets of optional options forcing the compilation with different modes
  17586. * @returns A promise that resolves when the compilation completes
  17587. */
  17588. forceCompilationAsync(options?: Partial<{
  17589. useInstances: boolean;
  17590. }>): Promise<void>;
  17591. /**
  17592. * Serializes the shadow generator setup to a json object.
  17593. * @returns The serialized JSON object
  17594. */
  17595. serialize(): any;
  17596. /**
  17597. * Disposes the Shadow map and related Textures and effects.
  17598. */
  17599. dispose(): void;
  17600. }
  17601. /**
  17602. * Default implementation IShadowGenerator.
  17603. * This is the main object responsible of generating shadows in the framework.
  17604. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17605. */
  17606. export class ShadowGenerator implements IShadowGenerator {
  17607. /**
  17608. * Name of the shadow generator class
  17609. */
  17610. static CLASSNAME: string;
  17611. /**
  17612. * Shadow generator mode None: no filtering applied.
  17613. */
  17614. static readonly FILTER_NONE: number;
  17615. /**
  17616. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17617. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17618. */
  17619. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17620. /**
  17621. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17622. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17623. */
  17624. static readonly FILTER_POISSONSAMPLING: number;
  17625. /**
  17626. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17627. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17628. */
  17629. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17630. /**
  17631. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17632. * edge artifacts on steep falloff.
  17633. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17634. */
  17635. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17636. /**
  17637. * Shadow generator mode ESM: Blurred 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_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17642. /**
  17643. * Shadow generator mode PCF: Percentage Closer Filtering
  17644. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17645. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17646. */
  17647. static readonly FILTER_PCF: number;
  17648. /**
  17649. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17650. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17651. * Contact Hardening
  17652. */
  17653. static readonly FILTER_PCSS: number;
  17654. /**
  17655. * Reserved for PCF and PCSS
  17656. * Highest Quality.
  17657. *
  17658. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17659. *
  17660. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17661. */
  17662. static readonly QUALITY_HIGH: number;
  17663. /**
  17664. * Reserved for PCF and PCSS
  17665. * Good tradeoff for quality/perf cross devices
  17666. *
  17667. * Execute PCF on a 3*3 kernel.
  17668. *
  17669. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17670. */
  17671. static readonly QUALITY_MEDIUM: number;
  17672. /**
  17673. * Reserved for PCF and PCSS
  17674. * The lowest quality but the fastest.
  17675. *
  17676. * Execute PCF on a 1*1 kernel.
  17677. *
  17678. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17679. */
  17680. static readonly QUALITY_LOW: number;
  17681. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17682. id: string;
  17683. /** Gets or sets the custom shader name to use */
  17684. customShaderOptions: ICustomShaderOptions;
  17685. /**
  17686. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17687. */
  17688. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17689. /**
  17690. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17691. */
  17692. onAfterShadowMapRenderObservable: Observable<Effect>;
  17693. /**
  17694. * Observable triggered before a mesh is rendered in the shadow map.
  17695. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17696. */
  17697. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17698. /**
  17699. * Observable triggered after a mesh is rendered in the shadow map.
  17700. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17701. */
  17702. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17703. protected _bias: number;
  17704. /**
  17705. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17706. */
  17707. get bias(): number;
  17708. /**
  17709. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17710. */
  17711. set bias(bias: number);
  17712. protected _normalBias: number;
  17713. /**
  17714. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17715. */
  17716. get normalBias(): number;
  17717. /**
  17718. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17719. */
  17720. set normalBias(normalBias: number);
  17721. protected _blurBoxOffset: number;
  17722. /**
  17723. * Gets the blur box offset: offset applied during the blur pass.
  17724. * Only useful if useKernelBlur = false
  17725. */
  17726. get blurBoxOffset(): number;
  17727. /**
  17728. * Sets the blur box offset: offset applied during the blur pass.
  17729. * Only useful if useKernelBlur = false
  17730. */
  17731. set blurBoxOffset(value: number);
  17732. protected _blurScale: number;
  17733. /**
  17734. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17735. * 2 means half of the size.
  17736. */
  17737. get blurScale(): number;
  17738. /**
  17739. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17740. * 2 means half of the size.
  17741. */
  17742. set blurScale(value: number);
  17743. protected _blurKernel: number;
  17744. /**
  17745. * Gets the blur kernel: kernel size of the blur pass.
  17746. * Only useful if useKernelBlur = true
  17747. */
  17748. get blurKernel(): number;
  17749. /**
  17750. * Sets the blur kernel: kernel size of the blur pass.
  17751. * Only useful if useKernelBlur = true
  17752. */
  17753. set blurKernel(value: number);
  17754. protected _useKernelBlur: boolean;
  17755. /**
  17756. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17757. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17758. */
  17759. get useKernelBlur(): boolean;
  17760. /**
  17761. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17762. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17763. */
  17764. set useKernelBlur(value: boolean);
  17765. protected _depthScale: number;
  17766. /**
  17767. * Gets the depth scale used in ESM mode.
  17768. */
  17769. get depthScale(): number;
  17770. /**
  17771. * Sets the depth scale used in ESM mode.
  17772. * This can override the scale stored on the light.
  17773. */
  17774. set depthScale(value: number);
  17775. protected _validateFilter(filter: number): number;
  17776. protected _filter: number;
  17777. /**
  17778. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17779. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17780. */
  17781. get filter(): number;
  17782. /**
  17783. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17784. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17785. */
  17786. set filter(value: number);
  17787. /**
  17788. * Gets if the current filter is set to Poisson Sampling.
  17789. */
  17790. get usePoissonSampling(): boolean;
  17791. /**
  17792. * Sets the current filter to Poisson Sampling.
  17793. */
  17794. set usePoissonSampling(value: boolean);
  17795. /**
  17796. * Gets if the current filter is set to ESM.
  17797. */
  17798. get useExponentialShadowMap(): boolean;
  17799. /**
  17800. * Sets the current filter is to ESM.
  17801. */
  17802. set useExponentialShadowMap(value: boolean);
  17803. /**
  17804. * Gets if the current filter is set to filtered ESM.
  17805. */
  17806. get useBlurExponentialShadowMap(): boolean;
  17807. /**
  17808. * Gets if the current filter is set to filtered ESM.
  17809. */
  17810. set useBlurExponentialShadowMap(value: boolean);
  17811. /**
  17812. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17813. * exponential to prevent steep falloff artifacts).
  17814. */
  17815. get useCloseExponentialShadowMap(): boolean;
  17816. /**
  17817. * Sets the current filter to "close ESM" (using the inverse of the
  17818. * exponential to prevent steep falloff artifacts).
  17819. */
  17820. set useCloseExponentialShadowMap(value: boolean);
  17821. /**
  17822. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17823. * exponential to prevent steep falloff artifacts).
  17824. */
  17825. get useBlurCloseExponentialShadowMap(): boolean;
  17826. /**
  17827. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17828. * exponential to prevent steep falloff artifacts).
  17829. */
  17830. set useBlurCloseExponentialShadowMap(value: boolean);
  17831. /**
  17832. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17833. */
  17834. get usePercentageCloserFiltering(): boolean;
  17835. /**
  17836. * Sets the current filter to "PCF" (percentage closer filtering).
  17837. */
  17838. set usePercentageCloserFiltering(value: boolean);
  17839. protected _filteringQuality: number;
  17840. /**
  17841. * Gets the PCF or PCSS Quality.
  17842. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17843. */
  17844. get filteringQuality(): number;
  17845. /**
  17846. * Sets the PCF or PCSS Quality.
  17847. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17848. */
  17849. set filteringQuality(filteringQuality: number);
  17850. /**
  17851. * Gets if the current filter is set to "PCSS" (contact hardening).
  17852. */
  17853. get useContactHardeningShadow(): boolean;
  17854. /**
  17855. * Sets the current filter to "PCSS" (contact hardening).
  17856. */
  17857. set useContactHardeningShadow(value: boolean);
  17858. protected _contactHardeningLightSizeUVRatio: number;
  17859. /**
  17860. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17861. * Using a ratio helps keeping shape stability independently of the map size.
  17862. *
  17863. * It does not account for the light projection as it was having too much
  17864. * instability during the light setup or during light position changes.
  17865. *
  17866. * Only valid if useContactHardeningShadow is true.
  17867. */
  17868. get contactHardeningLightSizeUVRatio(): number;
  17869. /**
  17870. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17871. * Using a ratio helps keeping shape stability independently of the map size.
  17872. *
  17873. * It does not account for the light projection as it was having too much
  17874. * instability during the light setup or during light position changes.
  17875. *
  17876. * Only valid if useContactHardeningShadow is true.
  17877. */
  17878. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17879. protected _darkness: number;
  17880. /** Gets or sets the actual darkness of a shadow */
  17881. get darkness(): number;
  17882. set darkness(value: number);
  17883. /**
  17884. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17885. * 0 means strongest and 1 would means no shadow.
  17886. * @returns the darkness.
  17887. */
  17888. getDarkness(): number;
  17889. /**
  17890. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17891. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17892. * @returns the shadow generator allowing fluent coding.
  17893. */
  17894. setDarkness(darkness: number): ShadowGenerator;
  17895. protected _transparencyShadow: boolean;
  17896. /** Gets or sets the ability to have transparent shadow */
  17897. get transparencyShadow(): boolean;
  17898. set transparencyShadow(value: boolean);
  17899. /**
  17900. * Sets the ability to have transparent shadow (boolean).
  17901. * @param transparent True if transparent else False
  17902. * @returns the shadow generator allowing fluent coding
  17903. */
  17904. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17905. /**
  17906. * Enables or disables shadows with varying strength based on the transparency
  17907. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17908. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17909. * mesh.visibility * alphaTexture.a
  17910. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17911. */
  17912. enableSoftTransparentShadow: boolean;
  17913. protected _shadowMap: Nullable<RenderTargetTexture>;
  17914. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17915. /**
  17916. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17917. * @returns The render target texture if present otherwise, null
  17918. */
  17919. getShadowMap(): Nullable<RenderTargetTexture>;
  17920. /**
  17921. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17922. * @returns The render target texture if the shadow map is present otherwise, null
  17923. */
  17924. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17925. /**
  17926. * Gets the class name of that object
  17927. * @returns "ShadowGenerator"
  17928. */
  17929. getClassName(): string;
  17930. /**
  17931. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17932. * @param mesh Mesh to add
  17933. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17934. * @returns the Shadow Generator itself
  17935. */
  17936. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17937. /**
  17938. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17939. * @param mesh Mesh to remove
  17940. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17941. * @returns the Shadow Generator itself
  17942. */
  17943. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17944. /**
  17945. * Controls the extent to which the shadows fade out at the edge of the frustum
  17946. */
  17947. frustumEdgeFalloff: number;
  17948. protected _light: IShadowLight;
  17949. /**
  17950. * Returns the associated light object.
  17951. * @returns the light generating the shadow
  17952. */
  17953. getLight(): IShadowLight;
  17954. /**
  17955. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17956. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17957. * It might on the other hand introduce peter panning.
  17958. */
  17959. forceBackFacesOnly: boolean;
  17960. protected _scene: Scene;
  17961. protected _lightDirection: Vector3;
  17962. protected _effect: Effect;
  17963. protected _viewMatrix: Matrix;
  17964. protected _projectionMatrix: Matrix;
  17965. protected _transformMatrix: Matrix;
  17966. protected _cachedPosition: Vector3;
  17967. protected _cachedDirection: Vector3;
  17968. protected _cachedDefines: string;
  17969. protected _currentRenderID: number;
  17970. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17971. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17972. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17973. protected _blurPostProcesses: PostProcess[];
  17974. protected _mapSize: number;
  17975. protected _currentFaceIndex: number;
  17976. protected _currentFaceIndexCache: number;
  17977. protected _textureType: number;
  17978. protected _defaultTextureMatrix: Matrix;
  17979. protected _storedUniqueId: Nullable<number>;
  17980. /** @hidden */
  17981. static _SceneComponentInitialization: (scene: Scene) => void;
  17982. /**
  17983. * Gets or sets the size of the texture what stores the shadows
  17984. */
  17985. get mapSize(): number;
  17986. set mapSize(size: number);
  17987. /**
  17988. * Creates a ShadowGenerator object.
  17989. * A ShadowGenerator is the required tool to use the shadows.
  17990. * Each light casting shadows needs to use its own ShadowGenerator.
  17991. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17992. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17993. * @param light The light object generating the shadows.
  17994. * @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.
  17995. */
  17996. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17997. protected _initializeGenerator(): void;
  17998. protected _createTargetRenderTexture(): void;
  17999. protected _initializeShadowMap(): void;
  18000. protected _initializeBlurRTTAndPostProcesses(): void;
  18001. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18002. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18003. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18004. protected _applyFilterValues(): void;
  18005. /**
  18006. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18007. * @param onCompiled Callback triggered at the and of the effects compilation
  18008. * @param options Sets of optional options forcing the compilation with different modes
  18009. */
  18010. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18011. useInstances: boolean;
  18012. }>): void;
  18013. /**
  18014. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18015. * @param options Sets of optional options forcing the compilation with different modes
  18016. * @returns A promise that resolves when the compilation completes
  18017. */
  18018. forceCompilationAsync(options?: Partial<{
  18019. useInstances: boolean;
  18020. }>): Promise<void>;
  18021. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18022. private _prepareShadowDefines;
  18023. /**
  18024. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18025. * @param subMesh The submesh we want to render in the shadow map
  18026. * @param useInstances Defines wether will draw in the map using instances
  18027. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18028. * @returns true if ready otherwise, false
  18029. */
  18030. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18031. /**
  18032. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18033. * @param defines Defines of the material we want to update
  18034. * @param lightIndex Index of the light in the enabled light list of the material
  18035. */
  18036. prepareDefines(defines: any, lightIndex: number): void;
  18037. /**
  18038. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18039. * defined in the generator but impacting the effect).
  18040. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18041. * @param effect The effect we are binfing the information for
  18042. */
  18043. bindShadowLight(lightIndex: string, effect: Effect): void;
  18044. /**
  18045. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18046. * (eq to shadow prjection matrix * light transform matrix)
  18047. * @returns The transform matrix used to create the shadow map
  18048. */
  18049. getTransformMatrix(): Matrix;
  18050. /**
  18051. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18052. * Cube and 2D textures for instance.
  18053. */
  18054. recreateShadowMap(): void;
  18055. protected _disposeBlurPostProcesses(): void;
  18056. protected _disposeRTTandPostProcesses(): void;
  18057. /**
  18058. * Disposes the ShadowGenerator.
  18059. * Returns nothing.
  18060. */
  18061. dispose(): void;
  18062. /**
  18063. * Serializes the shadow generator setup to a json object.
  18064. * @returns The serialized JSON object
  18065. */
  18066. serialize(): any;
  18067. /**
  18068. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18069. * @param parsedShadowGenerator The JSON object to parse
  18070. * @param scene The scene to create the shadow map for
  18071. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18072. * @returns The parsed shadow generator
  18073. */
  18074. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18075. }
  18076. }
  18077. declare module BABYLON {
  18078. /**
  18079. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18080. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18081. * 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.
  18082. */
  18083. export abstract class Light extends Node {
  18084. /**
  18085. * Falloff Default: light is falling off following the material specification:
  18086. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18087. */
  18088. static readonly FALLOFF_DEFAULT: number;
  18089. /**
  18090. * Falloff Physical: light is falling off following the inverse squared distance law.
  18091. */
  18092. static readonly FALLOFF_PHYSICAL: number;
  18093. /**
  18094. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18095. * to enhance interoperability with other engines.
  18096. */
  18097. static readonly FALLOFF_GLTF: number;
  18098. /**
  18099. * Falloff Standard: light is falling off like in the standard material
  18100. * to enhance interoperability with other materials.
  18101. */
  18102. static readonly FALLOFF_STANDARD: number;
  18103. /**
  18104. * If every light affecting the material is in this lightmapMode,
  18105. * material.lightmapTexture adds or multiplies
  18106. * (depends on material.useLightmapAsShadowmap)
  18107. * after every other light calculations.
  18108. */
  18109. static readonly LIGHTMAP_DEFAULT: number;
  18110. /**
  18111. * material.lightmapTexture as only diffuse lighting from this light
  18112. * adds only specular lighting from this light
  18113. * adds dynamic shadows
  18114. */
  18115. static readonly LIGHTMAP_SPECULAR: number;
  18116. /**
  18117. * material.lightmapTexture as only lighting
  18118. * no light calculation from this light
  18119. * only adds dynamic shadows from this light
  18120. */
  18121. static readonly LIGHTMAP_SHADOWSONLY: number;
  18122. /**
  18123. * Each light type uses the default quantity according to its type:
  18124. * point/spot lights use luminous intensity
  18125. * directional lights use illuminance
  18126. */
  18127. static readonly INTENSITYMODE_AUTOMATIC: number;
  18128. /**
  18129. * lumen (lm)
  18130. */
  18131. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18132. /**
  18133. * candela (lm/sr)
  18134. */
  18135. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18136. /**
  18137. * lux (lm/m^2)
  18138. */
  18139. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18140. /**
  18141. * nit (cd/m^2)
  18142. */
  18143. static readonly INTENSITYMODE_LUMINANCE: number;
  18144. /**
  18145. * Light type const id of the point light.
  18146. */
  18147. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18148. /**
  18149. * Light type const id of the directional light.
  18150. */
  18151. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18152. /**
  18153. * Light type const id of the spot light.
  18154. */
  18155. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18156. /**
  18157. * Light type const id of the hemispheric light.
  18158. */
  18159. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18160. /**
  18161. * Diffuse gives the basic color to an object.
  18162. */
  18163. diffuse: Color3;
  18164. /**
  18165. * Specular produces a highlight color on an object.
  18166. * Note: This is note affecting PBR materials.
  18167. */
  18168. specular: Color3;
  18169. /**
  18170. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18171. * falling off base on range or angle.
  18172. * This can be set to any values in Light.FALLOFF_x.
  18173. *
  18174. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18175. * other types of materials.
  18176. */
  18177. falloffType: number;
  18178. /**
  18179. * Strength of the light.
  18180. * Note: By default it is define in the framework own unit.
  18181. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18182. */
  18183. intensity: number;
  18184. private _range;
  18185. protected _inverseSquaredRange: number;
  18186. /**
  18187. * Defines how far from the source the light is impacting in scene units.
  18188. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18189. */
  18190. get range(): number;
  18191. /**
  18192. * Defines how far from the source the light is impacting in scene units.
  18193. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18194. */
  18195. set range(value: number);
  18196. /**
  18197. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18198. * of light.
  18199. */
  18200. private _photometricScale;
  18201. private _intensityMode;
  18202. /**
  18203. * Gets the photometric scale used to interpret the intensity.
  18204. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18205. */
  18206. get intensityMode(): number;
  18207. /**
  18208. * Sets the photometric scale used to interpret the intensity.
  18209. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18210. */
  18211. set intensityMode(value: number);
  18212. private _radius;
  18213. /**
  18214. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18215. */
  18216. get radius(): number;
  18217. /**
  18218. * sets the light radius used by PBR Materials to simulate soft area lights.
  18219. */
  18220. set radius(value: number);
  18221. private _renderPriority;
  18222. /**
  18223. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18224. * exceeding the number allowed of the materials.
  18225. */
  18226. renderPriority: number;
  18227. private _shadowEnabled;
  18228. /**
  18229. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18230. * the current shadow generator.
  18231. */
  18232. get shadowEnabled(): boolean;
  18233. /**
  18234. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18235. * the current shadow generator.
  18236. */
  18237. set shadowEnabled(value: boolean);
  18238. private _includedOnlyMeshes;
  18239. /**
  18240. * Gets the only meshes impacted by this light.
  18241. */
  18242. get includedOnlyMeshes(): AbstractMesh[];
  18243. /**
  18244. * Sets the only meshes impacted by this light.
  18245. */
  18246. set includedOnlyMeshes(value: AbstractMesh[]);
  18247. private _excludedMeshes;
  18248. /**
  18249. * Gets the meshes not impacted by this light.
  18250. */
  18251. get excludedMeshes(): AbstractMesh[];
  18252. /**
  18253. * Sets the meshes not impacted by this light.
  18254. */
  18255. set excludedMeshes(value: AbstractMesh[]);
  18256. private _excludeWithLayerMask;
  18257. /**
  18258. * Gets the layer id use to find what meshes are not impacted by the light.
  18259. * Inactive if 0
  18260. */
  18261. get excludeWithLayerMask(): number;
  18262. /**
  18263. * Sets the layer id use to find what meshes are not impacted by the light.
  18264. * Inactive if 0
  18265. */
  18266. set excludeWithLayerMask(value: number);
  18267. private _includeOnlyWithLayerMask;
  18268. /**
  18269. * Gets the layer id use to find what meshes are impacted by the light.
  18270. * Inactive if 0
  18271. */
  18272. get includeOnlyWithLayerMask(): number;
  18273. /**
  18274. * Sets the layer id use to find what meshes are impacted by the light.
  18275. * Inactive if 0
  18276. */
  18277. set includeOnlyWithLayerMask(value: number);
  18278. private _lightmapMode;
  18279. /**
  18280. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18281. */
  18282. get lightmapMode(): number;
  18283. /**
  18284. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18285. */
  18286. set lightmapMode(value: number);
  18287. /**
  18288. * Shadow generator associted to the light.
  18289. * @hidden Internal use only.
  18290. */
  18291. _shadowGenerator: Nullable<IShadowGenerator>;
  18292. /**
  18293. * @hidden Internal use only.
  18294. */
  18295. _excludedMeshesIds: string[];
  18296. /**
  18297. * @hidden Internal use only.
  18298. */
  18299. _includedOnlyMeshesIds: string[];
  18300. /**
  18301. * The current light unifom buffer.
  18302. * @hidden Internal use only.
  18303. */
  18304. _uniformBuffer: UniformBuffer;
  18305. /** @hidden */
  18306. _renderId: number;
  18307. /**
  18308. * Creates a Light object in the scene.
  18309. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18310. * @param name The firendly name of the light
  18311. * @param scene The scene the light belongs too
  18312. */
  18313. constructor(name: string, scene: Scene);
  18314. protected abstract _buildUniformLayout(): void;
  18315. /**
  18316. * Sets the passed Effect "effect" with the Light information.
  18317. * @param effect The effect to update
  18318. * @param lightIndex The index of the light in the effect to update
  18319. * @returns The light
  18320. */
  18321. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18322. /**
  18323. * Sets the passed Effect "effect" with the Light textures.
  18324. * @param effect The effect to update
  18325. * @param lightIndex The index of the light in the effect to update
  18326. * @returns The light
  18327. */
  18328. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18329. /**
  18330. * Binds the lights information from the scene to the effect for the given mesh.
  18331. * @param lightIndex Light index
  18332. * @param scene The scene where the light belongs to
  18333. * @param effect The effect we are binding the data to
  18334. * @param useSpecular Defines if specular is supported
  18335. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18336. */
  18337. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18338. /**
  18339. * Sets the passed Effect "effect" with the Light information.
  18340. * @param effect The effect to update
  18341. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18342. * @returns The light
  18343. */
  18344. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18345. /**
  18346. * Returns the string "Light".
  18347. * @returns the class name
  18348. */
  18349. getClassName(): string;
  18350. /** @hidden */
  18351. readonly _isLight: boolean;
  18352. /**
  18353. * Converts the light information to a readable string for debug purpose.
  18354. * @param fullDetails Supports for multiple levels of logging within scene loading
  18355. * @returns the human readable light info
  18356. */
  18357. toString(fullDetails?: boolean): string;
  18358. /** @hidden */
  18359. protected _syncParentEnabledState(): void;
  18360. /**
  18361. * Set the enabled state of this node.
  18362. * @param value - the new enabled state
  18363. */
  18364. setEnabled(value: boolean): void;
  18365. /**
  18366. * Returns the Light associated shadow generator if any.
  18367. * @return the associated shadow generator.
  18368. */
  18369. getShadowGenerator(): Nullable<IShadowGenerator>;
  18370. /**
  18371. * Returns a Vector3, the absolute light position in the World.
  18372. * @returns the world space position of the light
  18373. */
  18374. getAbsolutePosition(): Vector3;
  18375. /**
  18376. * Specifies if the light will affect the passed mesh.
  18377. * @param mesh The mesh to test against the light
  18378. * @return true the mesh is affected otherwise, false.
  18379. */
  18380. canAffectMesh(mesh: AbstractMesh): boolean;
  18381. /**
  18382. * Sort function to order lights for rendering.
  18383. * @param a First Light object to compare to second.
  18384. * @param b Second Light object to compare first.
  18385. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18386. */
  18387. static CompareLightsPriority(a: Light, b: Light): number;
  18388. /**
  18389. * Releases resources associated with this node.
  18390. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18391. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18392. */
  18393. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18394. /**
  18395. * Returns the light type ID (integer).
  18396. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18397. */
  18398. getTypeID(): number;
  18399. /**
  18400. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18401. * @returns the scaled intensity in intensity mode unit
  18402. */
  18403. getScaledIntensity(): number;
  18404. /**
  18405. * Returns a new Light object, named "name", from the current one.
  18406. * @param name The name of the cloned light
  18407. * @param newParent The parent of this light, if it has one
  18408. * @returns the new created light
  18409. */
  18410. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18411. /**
  18412. * Serializes the current light into a Serialization object.
  18413. * @returns the serialized object.
  18414. */
  18415. serialize(): any;
  18416. /**
  18417. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18418. * This new light is named "name" and added to the passed scene.
  18419. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18420. * @param name The friendly name of the light
  18421. * @param scene The scene the new light will belong to
  18422. * @returns the constructor function
  18423. */
  18424. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18425. /**
  18426. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18427. * @param parsedLight The JSON representation of the light
  18428. * @param scene The scene to create the parsed light in
  18429. * @returns the created light after parsing
  18430. */
  18431. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18432. private _hookArrayForExcluded;
  18433. private _hookArrayForIncludedOnly;
  18434. private _resyncMeshes;
  18435. /**
  18436. * Forces the meshes to update their light related information in their rendering used effects
  18437. * @hidden Internal Use Only
  18438. */
  18439. _markMeshesAsLightDirty(): void;
  18440. /**
  18441. * Recomputes the cached photometric scale if needed.
  18442. */
  18443. private _computePhotometricScale;
  18444. /**
  18445. * Returns the Photometric Scale according to the light type and intensity mode.
  18446. */
  18447. private _getPhotometricScale;
  18448. /**
  18449. * Reorder the light in the scene according to their defined priority.
  18450. * @hidden Internal Use Only
  18451. */
  18452. _reorderLightsInScene(): void;
  18453. /**
  18454. * Prepares the list of defines specific to the light type.
  18455. * @param defines the list of defines
  18456. * @param lightIndex defines the index of the light for the effect
  18457. */
  18458. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18459. }
  18460. }
  18461. declare module BABYLON {
  18462. /**
  18463. * Configuration needed for prepass-capable materials
  18464. */
  18465. export class PrePassConfiguration {
  18466. /**
  18467. * Previous world matrices of meshes carrying this material
  18468. * Used for computing velocity
  18469. */
  18470. previousWorldMatrices: {
  18471. [index: number]: Matrix;
  18472. };
  18473. /**
  18474. * Previous view project matrix
  18475. * Used for computing velocity
  18476. */
  18477. previousViewProjection: Matrix;
  18478. /**
  18479. * Previous bones of meshes carrying this material
  18480. * Used for computing velocity
  18481. */
  18482. previousBones: {
  18483. [index: number]: Float32Array;
  18484. };
  18485. /**
  18486. * Add the required uniforms to the current list.
  18487. * @param uniforms defines the current uniform list.
  18488. */
  18489. static AddUniforms(uniforms: string[]): void;
  18490. /**
  18491. * Add the required samplers to the current list.
  18492. * @param samplers defines the current sampler list.
  18493. */
  18494. static AddSamplers(samplers: string[]): void;
  18495. /**
  18496. * Binds the material data.
  18497. * @param effect defines the effect to update
  18498. * @param scene defines the scene the material belongs to.
  18499. * @param mesh The mesh
  18500. * @param world World matrix of this mesh
  18501. * @param isFrozen Is the material frozen
  18502. */
  18503. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18504. }
  18505. }
  18506. declare module BABYLON {
  18507. /**
  18508. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18509. * This is the base of the follow, arc rotate cameras and Free camera
  18510. * @see https://doc.babylonjs.com/features/cameras
  18511. */
  18512. export class TargetCamera extends Camera {
  18513. private static _RigCamTransformMatrix;
  18514. private static _TargetTransformMatrix;
  18515. private static _TargetFocalPoint;
  18516. private _tmpUpVector;
  18517. private _tmpTargetVector;
  18518. /**
  18519. * Define the current direction the camera is moving to
  18520. */
  18521. cameraDirection: Vector3;
  18522. /**
  18523. * Define the current rotation the camera is rotating to
  18524. */
  18525. cameraRotation: Vector2;
  18526. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18527. ignoreParentScaling: boolean;
  18528. /**
  18529. * When set, the up vector of the camera will be updated by the rotation of the camera
  18530. */
  18531. updateUpVectorFromRotation: boolean;
  18532. private _tmpQuaternion;
  18533. /**
  18534. * Define the current rotation of the camera
  18535. */
  18536. rotation: Vector3;
  18537. /**
  18538. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18539. */
  18540. rotationQuaternion: Quaternion;
  18541. /**
  18542. * Define the current speed of the camera
  18543. */
  18544. speed: number;
  18545. /**
  18546. * Add constraint to the camera to prevent it to move freely in all directions and
  18547. * around all axis.
  18548. */
  18549. noRotationConstraint: boolean;
  18550. /**
  18551. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18552. * panning
  18553. */
  18554. invertRotation: boolean;
  18555. /**
  18556. * Speed multiplier for inverse camera panning
  18557. */
  18558. inverseRotationSpeed: number;
  18559. /**
  18560. * Define the current target of the camera as an object or a position.
  18561. */
  18562. lockedTarget: any;
  18563. /** @hidden */
  18564. _currentTarget: Vector3;
  18565. /** @hidden */
  18566. _initialFocalDistance: number;
  18567. /** @hidden */
  18568. _viewMatrix: Matrix;
  18569. /** @hidden */
  18570. _camMatrix: Matrix;
  18571. /** @hidden */
  18572. _cameraTransformMatrix: Matrix;
  18573. /** @hidden */
  18574. _cameraRotationMatrix: Matrix;
  18575. /** @hidden */
  18576. _referencePoint: Vector3;
  18577. /** @hidden */
  18578. _transformedReferencePoint: Vector3;
  18579. /** @hidden */
  18580. _reset: () => void;
  18581. private _defaultUp;
  18582. /**
  18583. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18584. * This is the base of the follow, arc rotate cameras and Free camera
  18585. * @see https://doc.babylonjs.com/features/cameras
  18586. * @param name Defines the name of the camera in the scene
  18587. * @param position Defines the start position of the camera in the scene
  18588. * @param scene Defines the scene the camera belongs to
  18589. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18590. */
  18591. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18592. /**
  18593. * Gets the position in front of the camera at a given distance.
  18594. * @param distance The distance from the camera we want the position to be
  18595. * @returns the position
  18596. */
  18597. getFrontPosition(distance: number): Vector3;
  18598. /** @hidden */
  18599. _getLockedTargetPosition(): Nullable<Vector3>;
  18600. private _storedPosition;
  18601. private _storedRotation;
  18602. private _storedRotationQuaternion;
  18603. /**
  18604. * Store current camera state of the camera (fov, position, rotation, etc..)
  18605. * @returns the camera
  18606. */
  18607. storeState(): Camera;
  18608. /**
  18609. * Restored camera state. You must call storeState() first
  18610. * @returns whether it was successful or not
  18611. * @hidden
  18612. */
  18613. _restoreStateValues(): boolean;
  18614. /** @hidden */
  18615. _initCache(): void;
  18616. /** @hidden */
  18617. _updateCache(ignoreParentClass?: boolean): void;
  18618. /** @hidden */
  18619. _isSynchronizedViewMatrix(): boolean;
  18620. /** @hidden */
  18621. _computeLocalCameraSpeed(): number;
  18622. /**
  18623. * Defines the target the camera should look at.
  18624. * @param target Defines the new target as a Vector or a mesh
  18625. */
  18626. setTarget(target: Vector3): void;
  18627. /**
  18628. * Defines the target point of the camera.
  18629. * The camera looks towards it form the radius distance.
  18630. */
  18631. get target(): Vector3;
  18632. set target(value: Vector3);
  18633. /**
  18634. * Return the current target position of the camera. This value is expressed in local space.
  18635. * @returns the target position
  18636. */
  18637. getTarget(): Vector3;
  18638. /** @hidden */
  18639. _decideIfNeedsToMove(): boolean;
  18640. /** @hidden */
  18641. _updatePosition(): void;
  18642. /** @hidden */
  18643. _checkInputs(): void;
  18644. protected _updateCameraRotationMatrix(): void;
  18645. /**
  18646. * 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)
  18647. * @returns the current camera
  18648. */
  18649. private _rotateUpVectorWithCameraRotationMatrix;
  18650. private _cachedRotationZ;
  18651. private _cachedQuaternionRotationZ;
  18652. /** @hidden */
  18653. _getViewMatrix(): Matrix;
  18654. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18655. /**
  18656. * @hidden
  18657. */
  18658. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18659. /**
  18660. * @hidden
  18661. */
  18662. _updateRigCameras(): void;
  18663. private _getRigCamPositionAndTarget;
  18664. /**
  18665. * Gets the current object class name.
  18666. * @return the class name
  18667. */
  18668. getClassName(): string;
  18669. }
  18670. }
  18671. declare module BABYLON {
  18672. /**
  18673. * Gather the list of keyboard event types as constants.
  18674. */
  18675. export class KeyboardEventTypes {
  18676. /**
  18677. * The keydown event is fired when a key becomes active (pressed).
  18678. */
  18679. static readonly KEYDOWN: number;
  18680. /**
  18681. * The keyup event is fired when a key has been released.
  18682. */
  18683. static readonly KEYUP: number;
  18684. }
  18685. /**
  18686. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18687. */
  18688. export class KeyboardInfo {
  18689. /**
  18690. * Defines the type of event (KeyboardEventTypes)
  18691. */
  18692. type: number;
  18693. /**
  18694. * Defines the related dom event
  18695. */
  18696. event: KeyboardEvent;
  18697. /**
  18698. * Instantiates a new keyboard info.
  18699. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18700. * @param type Defines the type of event (KeyboardEventTypes)
  18701. * @param event Defines the related dom event
  18702. */
  18703. constructor(
  18704. /**
  18705. * Defines the type of event (KeyboardEventTypes)
  18706. */
  18707. type: number,
  18708. /**
  18709. * Defines the related dom event
  18710. */
  18711. event: KeyboardEvent);
  18712. }
  18713. /**
  18714. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18715. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18716. */
  18717. export class KeyboardInfoPre extends KeyboardInfo {
  18718. /**
  18719. * Defines the type of event (KeyboardEventTypes)
  18720. */
  18721. type: number;
  18722. /**
  18723. * Defines the related dom event
  18724. */
  18725. event: KeyboardEvent;
  18726. /**
  18727. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18728. */
  18729. skipOnPointerObservable: boolean;
  18730. /**
  18731. * Instantiates a new keyboard pre info.
  18732. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18733. * @param type Defines the type of event (KeyboardEventTypes)
  18734. * @param event Defines the related dom event
  18735. */
  18736. constructor(
  18737. /**
  18738. * Defines the type of event (KeyboardEventTypes)
  18739. */
  18740. type: number,
  18741. /**
  18742. * Defines the related dom event
  18743. */
  18744. event: KeyboardEvent);
  18745. }
  18746. }
  18747. declare module BABYLON {
  18748. /**
  18749. * Manage the keyboard inputs to control the movement of a free camera.
  18750. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18751. */
  18752. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18753. /**
  18754. * Defines the camera the input is attached to.
  18755. */
  18756. camera: FreeCamera;
  18757. /**
  18758. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18759. */
  18760. keysUp: number[];
  18761. /**
  18762. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18763. */
  18764. keysUpward: number[];
  18765. /**
  18766. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18767. */
  18768. keysDown: number[];
  18769. /**
  18770. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18771. */
  18772. keysDownward: number[];
  18773. /**
  18774. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18775. */
  18776. keysLeft: number[];
  18777. /**
  18778. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18779. */
  18780. keysRight: number[];
  18781. private _keys;
  18782. private _onCanvasBlurObserver;
  18783. private _onKeyboardObserver;
  18784. private _engine;
  18785. private _scene;
  18786. /**
  18787. * Attach the input controls to a specific dom element to get the input from.
  18788. * @param element Defines the element the controls should be listened from
  18789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18790. */
  18791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18792. /**
  18793. * Detach the current controls from the specified dom element.
  18794. * @param element Defines the element to stop listening the inputs from
  18795. */
  18796. detachControl(element: Nullable<HTMLElement>): void;
  18797. /**
  18798. * Update the current camera state depending on the inputs that have been used this frame.
  18799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18800. */
  18801. checkInputs(): void;
  18802. /**
  18803. * Gets the class name of the current intput.
  18804. * @returns the class name
  18805. */
  18806. getClassName(): string;
  18807. /** @hidden */
  18808. _onLostFocus(): void;
  18809. /**
  18810. * Get the friendly name associated with the input class.
  18811. * @returns the input friendly name
  18812. */
  18813. getSimpleName(): string;
  18814. }
  18815. }
  18816. declare module BABYLON {
  18817. /**
  18818. * Gather the list of pointer event types as constants.
  18819. */
  18820. export class PointerEventTypes {
  18821. /**
  18822. * 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.
  18823. */
  18824. static readonly POINTERDOWN: number;
  18825. /**
  18826. * The pointerup event is fired when a pointer is no longer active.
  18827. */
  18828. static readonly POINTERUP: number;
  18829. /**
  18830. * The pointermove event is fired when a pointer changes coordinates.
  18831. */
  18832. static readonly POINTERMOVE: number;
  18833. /**
  18834. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18835. */
  18836. static readonly POINTERWHEEL: number;
  18837. /**
  18838. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18839. */
  18840. static readonly POINTERPICK: number;
  18841. /**
  18842. * The pointertap event is fired when a the object has been touched and released without drag.
  18843. */
  18844. static readonly POINTERTAP: number;
  18845. /**
  18846. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18847. */
  18848. static readonly POINTERDOUBLETAP: number;
  18849. }
  18850. /**
  18851. * Base class of pointer info types.
  18852. */
  18853. export class PointerInfoBase {
  18854. /**
  18855. * Defines the type of event (PointerEventTypes)
  18856. */
  18857. type: number;
  18858. /**
  18859. * Defines the related dom event
  18860. */
  18861. event: PointerEvent | MouseWheelEvent;
  18862. /**
  18863. * Instantiates the base class of pointers info.
  18864. * @param type Defines the type of event (PointerEventTypes)
  18865. * @param event Defines the related dom event
  18866. */
  18867. constructor(
  18868. /**
  18869. * Defines the type of event (PointerEventTypes)
  18870. */
  18871. type: number,
  18872. /**
  18873. * Defines the related dom event
  18874. */
  18875. event: PointerEvent | MouseWheelEvent);
  18876. }
  18877. /**
  18878. * This class is used to store pointer related info for the onPrePointerObservable event.
  18879. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18880. */
  18881. export class PointerInfoPre extends PointerInfoBase {
  18882. /**
  18883. * Ray from a pointer if availible (eg. 6dof controller)
  18884. */
  18885. ray: Nullable<Ray>;
  18886. /**
  18887. * Defines the local position of the pointer on the canvas.
  18888. */
  18889. localPosition: Vector2;
  18890. /**
  18891. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18892. */
  18893. skipOnPointerObservable: boolean;
  18894. /**
  18895. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18896. * @param type Defines the type of event (PointerEventTypes)
  18897. * @param event Defines the related dom event
  18898. * @param localX Defines the local x coordinates of the pointer when the event occured
  18899. * @param localY Defines the local y coordinates of the pointer when the event occured
  18900. */
  18901. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18902. }
  18903. /**
  18904. * This type contains all the data related to a pointer event in Babylon.js.
  18905. * 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.
  18906. */
  18907. export class PointerInfo extends PointerInfoBase {
  18908. /**
  18909. * Defines the picking info associated to the info (if any)\
  18910. */
  18911. pickInfo: Nullable<PickingInfo>;
  18912. /**
  18913. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18914. * @param type Defines the type of event (PointerEventTypes)
  18915. * @param event Defines the related dom event
  18916. * @param pickInfo Defines the picking info associated to the info (if any)\
  18917. */
  18918. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18919. /**
  18920. * Defines the picking info associated to the info (if any)\
  18921. */
  18922. pickInfo: Nullable<PickingInfo>);
  18923. }
  18924. /**
  18925. * Data relating to a touch event on the screen.
  18926. */
  18927. export interface PointerTouch {
  18928. /**
  18929. * X coordinate of touch.
  18930. */
  18931. x: number;
  18932. /**
  18933. * Y coordinate of touch.
  18934. */
  18935. y: number;
  18936. /**
  18937. * Id of touch. Unique for each finger.
  18938. */
  18939. pointerId: number;
  18940. /**
  18941. * Event type passed from DOM.
  18942. */
  18943. type: any;
  18944. }
  18945. }
  18946. declare module BABYLON {
  18947. /**
  18948. * Manage the mouse inputs to control the movement of a free camera.
  18949. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18950. */
  18951. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18952. /**
  18953. * Define if touch is enabled in the mouse input
  18954. */
  18955. touchEnabled: boolean;
  18956. /**
  18957. * Defines the camera the input is attached to.
  18958. */
  18959. camera: FreeCamera;
  18960. /**
  18961. * Defines the buttons associated with the input to handle camera move.
  18962. */
  18963. buttons: number[];
  18964. /**
  18965. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18966. */
  18967. angularSensibility: number;
  18968. private _pointerInput;
  18969. private _onMouseMove;
  18970. private _observer;
  18971. private previousPosition;
  18972. /**
  18973. * Observable for when a pointer move event occurs containing the move offset
  18974. */
  18975. onPointerMovedObservable: Observable<{
  18976. offsetX: number;
  18977. offsetY: number;
  18978. }>;
  18979. /**
  18980. * @hidden
  18981. * If the camera should be rotated automatically based on pointer movement
  18982. */
  18983. _allowCameraRotation: boolean;
  18984. /**
  18985. * Manage the mouse inputs to control the movement of a free camera.
  18986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18987. * @param touchEnabled Defines if touch is enabled or not
  18988. */
  18989. constructor(
  18990. /**
  18991. * Define if touch is enabled in the mouse input
  18992. */
  18993. touchEnabled?: boolean);
  18994. /**
  18995. * Attach the input controls to a specific dom element to get the input from.
  18996. * @param element Defines the element the controls should be listened from
  18997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18998. */
  18999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19000. /**
  19001. * Called on JS contextmenu event.
  19002. * Override this method to provide functionality.
  19003. */
  19004. protected onContextMenu(evt: PointerEvent): void;
  19005. /**
  19006. * Detach the current controls from the specified dom element.
  19007. * @param element Defines the element to stop listening the inputs from
  19008. */
  19009. detachControl(element: Nullable<HTMLElement>): void;
  19010. /**
  19011. * Gets the class name of the current intput.
  19012. * @returns the class name
  19013. */
  19014. getClassName(): string;
  19015. /**
  19016. * Get the friendly name associated with the input class.
  19017. * @returns the input friendly name
  19018. */
  19019. getSimpleName(): string;
  19020. }
  19021. }
  19022. declare module BABYLON {
  19023. /**
  19024. * Manage the touch inputs to control the movement of a free camera.
  19025. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19026. */
  19027. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19028. /**
  19029. * Define if mouse events can be treated as touch events
  19030. */
  19031. allowMouse: boolean;
  19032. /**
  19033. * Defines the camera the input is attached to.
  19034. */
  19035. camera: FreeCamera;
  19036. /**
  19037. * Defines the touch sensibility for rotation.
  19038. * The higher the faster.
  19039. */
  19040. touchAngularSensibility: number;
  19041. /**
  19042. * Defines the touch sensibility for move.
  19043. * The higher the faster.
  19044. */
  19045. touchMoveSensibility: number;
  19046. private _offsetX;
  19047. private _offsetY;
  19048. private _pointerPressed;
  19049. private _pointerInput;
  19050. private _observer;
  19051. private _onLostFocus;
  19052. /**
  19053. * Manage the touch inputs to control the movement of a free camera.
  19054. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19055. * @param allowMouse Defines if mouse events can be treated as touch events
  19056. */
  19057. constructor(
  19058. /**
  19059. * Define if mouse events can be treated as touch events
  19060. */
  19061. allowMouse?: boolean);
  19062. /**
  19063. * Attach the input controls to a specific dom element to get the input from.
  19064. * @param element Defines the element the controls should be listened from
  19065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19066. */
  19067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19068. /**
  19069. * Detach the current controls from the specified dom element.
  19070. * @param element Defines the element to stop listening the inputs from
  19071. */
  19072. detachControl(element: Nullable<HTMLElement>): void;
  19073. /**
  19074. * Update the current camera state depending on the inputs that have been used this frame.
  19075. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19076. */
  19077. checkInputs(): void;
  19078. /**
  19079. * Gets the class name of the current intput.
  19080. * @returns the class name
  19081. */
  19082. getClassName(): string;
  19083. /**
  19084. * Get the friendly name associated with the input class.
  19085. * @returns the input friendly name
  19086. */
  19087. getSimpleName(): string;
  19088. }
  19089. }
  19090. declare module BABYLON {
  19091. /**
  19092. * Default Inputs manager for the FreeCamera.
  19093. * It groups all the default supported inputs for ease of use.
  19094. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19095. */
  19096. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19097. /**
  19098. * @hidden
  19099. */
  19100. _mouseInput: Nullable<FreeCameraMouseInput>;
  19101. /**
  19102. * Instantiates a new FreeCameraInputsManager.
  19103. * @param camera Defines the camera the inputs belong to
  19104. */
  19105. constructor(camera: FreeCamera);
  19106. /**
  19107. * Add keyboard input support to the input manager.
  19108. * @returns the current input manager
  19109. */
  19110. addKeyboard(): FreeCameraInputsManager;
  19111. /**
  19112. * Add mouse input support to the input manager.
  19113. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19114. * @returns the current input manager
  19115. */
  19116. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19117. /**
  19118. * Removes the mouse input support from the manager
  19119. * @returns the current input manager
  19120. */
  19121. removeMouse(): FreeCameraInputsManager;
  19122. /**
  19123. * Add touch input support to the input manager.
  19124. * @returns the current input manager
  19125. */
  19126. addTouch(): FreeCameraInputsManager;
  19127. /**
  19128. * Remove all attached input methods from a camera
  19129. */
  19130. clear(): void;
  19131. }
  19132. }
  19133. declare module BABYLON {
  19134. /**
  19135. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19136. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19137. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19138. */
  19139. export class FreeCamera extends TargetCamera {
  19140. /**
  19141. * Define the collision ellipsoid of the camera.
  19142. * This is helpful to simulate a camera body like the player body around the camera
  19143. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19144. */
  19145. ellipsoid: Vector3;
  19146. /**
  19147. * Define an offset for the position of the ellipsoid around the camera.
  19148. * This can be helpful to determine the center of the body near the gravity center of the body
  19149. * instead of its head.
  19150. */
  19151. ellipsoidOffset: Vector3;
  19152. /**
  19153. * Enable or disable collisions of the camera with the rest of the scene objects.
  19154. */
  19155. checkCollisions: boolean;
  19156. /**
  19157. * Enable or disable gravity on the camera.
  19158. */
  19159. applyGravity: boolean;
  19160. /**
  19161. * Define the input manager associated to the camera.
  19162. */
  19163. inputs: FreeCameraInputsManager;
  19164. /**
  19165. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19166. * Higher values reduce sensitivity.
  19167. */
  19168. get angularSensibility(): number;
  19169. /**
  19170. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19171. * Higher values reduce sensitivity.
  19172. */
  19173. set angularSensibility(value: number);
  19174. /**
  19175. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19176. */
  19177. get keysUp(): number[];
  19178. set keysUp(value: number[]);
  19179. /**
  19180. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19181. */
  19182. get keysUpward(): number[];
  19183. set keysUpward(value: number[]);
  19184. /**
  19185. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19186. */
  19187. get keysDown(): number[];
  19188. set keysDown(value: number[]);
  19189. /**
  19190. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19191. */
  19192. get keysDownward(): number[];
  19193. set keysDownward(value: number[]);
  19194. /**
  19195. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19196. */
  19197. get keysLeft(): number[];
  19198. set keysLeft(value: number[]);
  19199. /**
  19200. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19201. */
  19202. get keysRight(): number[];
  19203. set keysRight(value: number[]);
  19204. /**
  19205. * Event raised when the camera collide with a mesh in the scene.
  19206. */
  19207. onCollide: (collidedMesh: AbstractMesh) => void;
  19208. private _collider;
  19209. private _needMoveForGravity;
  19210. private _oldPosition;
  19211. private _diffPosition;
  19212. private _newPosition;
  19213. /** @hidden */
  19214. _localDirection: Vector3;
  19215. /** @hidden */
  19216. _transformedDirection: Vector3;
  19217. /**
  19218. * Instantiates a Free Camera.
  19219. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19220. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19221. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19222. * @param name Define the name of the camera in the scene
  19223. * @param position Define the start position of the camera in the scene
  19224. * @param scene Define the scene the camera belongs to
  19225. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19226. */
  19227. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19228. /**
  19229. * Attached controls to the current camera.
  19230. * @param element Defines the element the controls should be listened from
  19231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19232. */
  19233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19234. /**
  19235. * Detach the current controls from the camera.
  19236. * The camera will stop reacting to inputs.
  19237. * @param element Defines the element to stop listening the inputs from
  19238. */
  19239. detachControl(element: HTMLElement): void;
  19240. private _collisionMask;
  19241. /**
  19242. * Define a collision mask to limit the list of object the camera can collide with
  19243. */
  19244. get collisionMask(): number;
  19245. set collisionMask(mask: number);
  19246. /** @hidden */
  19247. _collideWithWorld(displacement: Vector3): void;
  19248. private _onCollisionPositionChange;
  19249. /** @hidden */
  19250. _checkInputs(): void;
  19251. /** @hidden */
  19252. _decideIfNeedsToMove(): boolean;
  19253. /** @hidden */
  19254. _updatePosition(): void;
  19255. /**
  19256. * Destroy the camera and release the current resources hold by it.
  19257. */
  19258. dispose(): void;
  19259. /**
  19260. * Gets the current object class name.
  19261. * @return the class name
  19262. */
  19263. getClassName(): string;
  19264. }
  19265. }
  19266. declare module BABYLON {
  19267. /**
  19268. * Represents a gamepad control stick position
  19269. */
  19270. export class StickValues {
  19271. /**
  19272. * The x component of the control stick
  19273. */
  19274. x: number;
  19275. /**
  19276. * The y component of the control stick
  19277. */
  19278. y: number;
  19279. /**
  19280. * Initializes the gamepad x and y control stick values
  19281. * @param x The x component of the gamepad control stick value
  19282. * @param y The y component of the gamepad control stick value
  19283. */
  19284. constructor(
  19285. /**
  19286. * The x component of the control stick
  19287. */
  19288. x: number,
  19289. /**
  19290. * The y component of the control stick
  19291. */
  19292. y: number);
  19293. }
  19294. /**
  19295. * An interface which manages callbacks for gamepad button changes
  19296. */
  19297. export interface GamepadButtonChanges {
  19298. /**
  19299. * Called when a gamepad has been changed
  19300. */
  19301. changed: boolean;
  19302. /**
  19303. * Called when a gamepad press event has been triggered
  19304. */
  19305. pressChanged: boolean;
  19306. /**
  19307. * Called when a touch event has been triggered
  19308. */
  19309. touchChanged: boolean;
  19310. /**
  19311. * Called when a value has changed
  19312. */
  19313. valueChanged: boolean;
  19314. }
  19315. /**
  19316. * Represents a gamepad
  19317. */
  19318. export class Gamepad {
  19319. /**
  19320. * The id of the gamepad
  19321. */
  19322. id: string;
  19323. /**
  19324. * The index of the gamepad
  19325. */
  19326. index: number;
  19327. /**
  19328. * The browser gamepad
  19329. */
  19330. browserGamepad: any;
  19331. /**
  19332. * Specifies what type of gamepad this represents
  19333. */
  19334. type: number;
  19335. private _leftStick;
  19336. private _rightStick;
  19337. /** @hidden */
  19338. _isConnected: boolean;
  19339. private _leftStickAxisX;
  19340. private _leftStickAxisY;
  19341. private _rightStickAxisX;
  19342. private _rightStickAxisY;
  19343. /**
  19344. * Triggered when the left control stick has been changed
  19345. */
  19346. private _onleftstickchanged;
  19347. /**
  19348. * Triggered when the right control stick has been changed
  19349. */
  19350. private _onrightstickchanged;
  19351. /**
  19352. * Represents a gamepad controller
  19353. */
  19354. static GAMEPAD: number;
  19355. /**
  19356. * Represents a generic controller
  19357. */
  19358. static GENERIC: number;
  19359. /**
  19360. * Represents an XBox controller
  19361. */
  19362. static XBOX: number;
  19363. /**
  19364. * Represents a pose-enabled controller
  19365. */
  19366. static POSE_ENABLED: number;
  19367. /**
  19368. * Represents an Dual Shock controller
  19369. */
  19370. static DUALSHOCK: number;
  19371. /**
  19372. * Specifies whether the left control stick should be Y-inverted
  19373. */
  19374. protected _invertLeftStickY: boolean;
  19375. /**
  19376. * Specifies if the gamepad has been connected
  19377. */
  19378. get isConnected(): boolean;
  19379. /**
  19380. * Initializes the gamepad
  19381. * @param id The id of the gamepad
  19382. * @param index The index of the gamepad
  19383. * @param browserGamepad The browser gamepad
  19384. * @param leftStickX The x component of the left joystick
  19385. * @param leftStickY The y component of the left joystick
  19386. * @param rightStickX The x component of the right joystick
  19387. * @param rightStickY The y component of the right joystick
  19388. */
  19389. constructor(
  19390. /**
  19391. * The id of the gamepad
  19392. */
  19393. id: string,
  19394. /**
  19395. * The index of the gamepad
  19396. */
  19397. index: number,
  19398. /**
  19399. * The browser gamepad
  19400. */
  19401. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19402. /**
  19403. * Callback triggered when the left joystick has changed
  19404. * @param callback
  19405. */
  19406. onleftstickchanged(callback: (values: StickValues) => void): void;
  19407. /**
  19408. * Callback triggered when the right joystick has changed
  19409. * @param callback
  19410. */
  19411. onrightstickchanged(callback: (values: StickValues) => void): void;
  19412. /**
  19413. * Gets the left joystick
  19414. */
  19415. get leftStick(): StickValues;
  19416. /**
  19417. * Sets the left joystick values
  19418. */
  19419. set leftStick(newValues: StickValues);
  19420. /**
  19421. * Gets the right joystick
  19422. */
  19423. get rightStick(): StickValues;
  19424. /**
  19425. * Sets the right joystick value
  19426. */
  19427. set rightStick(newValues: StickValues);
  19428. /**
  19429. * Updates the gamepad joystick positions
  19430. */
  19431. update(): void;
  19432. /**
  19433. * Disposes the gamepad
  19434. */
  19435. dispose(): void;
  19436. }
  19437. /**
  19438. * Represents a generic gamepad
  19439. */
  19440. export class GenericPad extends Gamepad {
  19441. private _buttons;
  19442. private _onbuttondown;
  19443. private _onbuttonup;
  19444. /**
  19445. * Observable triggered when a button has been pressed
  19446. */
  19447. onButtonDownObservable: Observable<number>;
  19448. /**
  19449. * Observable triggered when a button has been released
  19450. */
  19451. onButtonUpObservable: Observable<number>;
  19452. /**
  19453. * Callback triggered when a button has been pressed
  19454. * @param callback Called when a button has been pressed
  19455. */
  19456. onbuttondown(callback: (buttonPressed: number) => void): void;
  19457. /**
  19458. * Callback triggered when a button has been released
  19459. * @param callback Called when a button has been released
  19460. */
  19461. onbuttonup(callback: (buttonReleased: number) => void): void;
  19462. /**
  19463. * Initializes the generic gamepad
  19464. * @param id The id of the generic gamepad
  19465. * @param index The index of the generic gamepad
  19466. * @param browserGamepad The browser gamepad
  19467. */
  19468. constructor(id: string, index: number, browserGamepad: any);
  19469. private _setButtonValue;
  19470. /**
  19471. * Updates the generic gamepad
  19472. */
  19473. update(): void;
  19474. /**
  19475. * Disposes the generic gamepad
  19476. */
  19477. dispose(): void;
  19478. }
  19479. }
  19480. declare module BABYLON {
  19481. /**
  19482. * Defines the types of pose enabled controllers that are supported
  19483. */
  19484. export enum PoseEnabledControllerType {
  19485. /**
  19486. * HTC Vive
  19487. */
  19488. VIVE = 0,
  19489. /**
  19490. * Oculus Rift
  19491. */
  19492. OCULUS = 1,
  19493. /**
  19494. * Windows mixed reality
  19495. */
  19496. WINDOWS = 2,
  19497. /**
  19498. * Samsung gear VR
  19499. */
  19500. GEAR_VR = 3,
  19501. /**
  19502. * Google Daydream
  19503. */
  19504. DAYDREAM = 4,
  19505. /**
  19506. * Generic
  19507. */
  19508. GENERIC = 5
  19509. }
  19510. /**
  19511. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19512. */
  19513. export interface MutableGamepadButton {
  19514. /**
  19515. * Value of the button/trigger
  19516. */
  19517. value: number;
  19518. /**
  19519. * If the button/trigger is currently touched
  19520. */
  19521. touched: boolean;
  19522. /**
  19523. * If the button/trigger is currently pressed
  19524. */
  19525. pressed: boolean;
  19526. }
  19527. /**
  19528. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19529. * @hidden
  19530. */
  19531. export interface ExtendedGamepadButton extends GamepadButton {
  19532. /**
  19533. * If the button/trigger is currently pressed
  19534. */
  19535. readonly pressed: boolean;
  19536. /**
  19537. * If the button/trigger is currently touched
  19538. */
  19539. readonly touched: boolean;
  19540. /**
  19541. * Value of the button/trigger
  19542. */
  19543. readonly value: number;
  19544. }
  19545. /** @hidden */
  19546. export interface _GamePadFactory {
  19547. /**
  19548. * Returns whether or not the current gamepad can be created for this type of controller.
  19549. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19550. * @returns true if it can be created, otherwise false
  19551. */
  19552. canCreate(gamepadInfo: any): boolean;
  19553. /**
  19554. * Creates a new instance of the Gamepad.
  19555. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19556. * @returns the new gamepad instance
  19557. */
  19558. create(gamepadInfo: any): Gamepad;
  19559. }
  19560. /**
  19561. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19562. */
  19563. export class PoseEnabledControllerHelper {
  19564. /** @hidden */
  19565. static _ControllerFactories: _GamePadFactory[];
  19566. /** @hidden */
  19567. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19568. /**
  19569. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19570. * @param vrGamepad the gamepad to initialized
  19571. * @returns a vr controller of the type the gamepad identified as
  19572. */
  19573. static InitiateController(vrGamepad: any): Gamepad;
  19574. }
  19575. /**
  19576. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19577. */
  19578. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19579. /**
  19580. * If the controller is used in a webXR session
  19581. */
  19582. isXR: boolean;
  19583. private _deviceRoomPosition;
  19584. private _deviceRoomRotationQuaternion;
  19585. /**
  19586. * The device position in babylon space
  19587. */
  19588. devicePosition: Vector3;
  19589. /**
  19590. * The device rotation in babylon space
  19591. */
  19592. deviceRotationQuaternion: Quaternion;
  19593. /**
  19594. * The scale factor of the device in babylon space
  19595. */
  19596. deviceScaleFactor: number;
  19597. /**
  19598. * (Likely devicePosition should be used instead) The device position in its room space
  19599. */
  19600. position: Vector3;
  19601. /**
  19602. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19603. */
  19604. rotationQuaternion: Quaternion;
  19605. /**
  19606. * The type of controller (Eg. Windows mixed reality)
  19607. */
  19608. controllerType: PoseEnabledControllerType;
  19609. protected _calculatedPosition: Vector3;
  19610. private _calculatedRotation;
  19611. /**
  19612. * The raw pose from the device
  19613. */
  19614. rawPose: DevicePose;
  19615. private _trackPosition;
  19616. private _maxRotationDistFromHeadset;
  19617. private _draggedRoomRotation;
  19618. /**
  19619. * @hidden
  19620. */
  19621. _disableTrackPosition(fixedPosition: Vector3): void;
  19622. /**
  19623. * Internal, the mesh attached to the controller
  19624. * @hidden
  19625. */
  19626. _mesh: Nullable<AbstractMesh>;
  19627. private _poseControlledCamera;
  19628. private _leftHandSystemQuaternion;
  19629. /**
  19630. * Internal, matrix used to convert room space to babylon space
  19631. * @hidden
  19632. */
  19633. _deviceToWorld: Matrix;
  19634. /**
  19635. * Node to be used when casting a ray from the controller
  19636. * @hidden
  19637. */
  19638. _pointingPoseNode: Nullable<TransformNode>;
  19639. /**
  19640. * Name of the child mesh that can be used to cast a ray from the controller
  19641. */
  19642. static readonly POINTING_POSE: string;
  19643. /**
  19644. * Creates a new PoseEnabledController from a gamepad
  19645. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19646. */
  19647. constructor(browserGamepad: any);
  19648. private _workingMatrix;
  19649. /**
  19650. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19651. */
  19652. update(): void;
  19653. /**
  19654. * Updates only the pose device and mesh without doing any button event checking
  19655. */
  19656. protected _updatePoseAndMesh(): void;
  19657. /**
  19658. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19659. * @param poseData raw pose fromthe device
  19660. */
  19661. updateFromDevice(poseData: DevicePose): void;
  19662. /**
  19663. * @hidden
  19664. */
  19665. _meshAttachedObservable: Observable<AbstractMesh>;
  19666. /**
  19667. * Attaches a mesh to the controller
  19668. * @param mesh the mesh to be attached
  19669. */
  19670. attachToMesh(mesh: AbstractMesh): void;
  19671. /**
  19672. * Attaches the controllers mesh to a camera
  19673. * @param camera the camera the mesh should be attached to
  19674. */
  19675. attachToPoseControlledCamera(camera: TargetCamera): void;
  19676. /**
  19677. * Disposes of the controller
  19678. */
  19679. dispose(): void;
  19680. /**
  19681. * The mesh that is attached to the controller
  19682. */
  19683. get mesh(): Nullable<AbstractMesh>;
  19684. /**
  19685. * Gets the ray of the controller in the direction the controller is pointing
  19686. * @param length the length the resulting ray should be
  19687. * @returns a ray in the direction the controller is pointing
  19688. */
  19689. getForwardRay(length?: number): Ray;
  19690. }
  19691. }
  19692. declare module BABYLON {
  19693. /**
  19694. * Defines the WebVRController object that represents controllers tracked in 3D space
  19695. */
  19696. export abstract class WebVRController extends PoseEnabledController {
  19697. /**
  19698. * Internal, the default controller model for the controller
  19699. */
  19700. protected _defaultModel: Nullable<AbstractMesh>;
  19701. /**
  19702. * Fired when the trigger state has changed
  19703. */
  19704. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19705. /**
  19706. * Fired when the main button state has changed
  19707. */
  19708. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19709. /**
  19710. * Fired when the secondary button state has changed
  19711. */
  19712. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19713. /**
  19714. * Fired when the pad state has changed
  19715. */
  19716. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19717. /**
  19718. * Fired when controllers stick values have changed
  19719. */
  19720. onPadValuesChangedObservable: Observable<StickValues>;
  19721. /**
  19722. * Array of button availible on the controller
  19723. */
  19724. protected _buttons: Array<MutableGamepadButton>;
  19725. private _onButtonStateChange;
  19726. /**
  19727. * Fired when a controller button's state has changed
  19728. * @param callback the callback containing the button that was modified
  19729. */
  19730. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19731. /**
  19732. * X and Y axis corresponding to the controllers joystick
  19733. */
  19734. pad: StickValues;
  19735. /**
  19736. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19737. */
  19738. hand: string;
  19739. /**
  19740. * The default controller model for the controller
  19741. */
  19742. get defaultModel(): Nullable<AbstractMesh>;
  19743. /**
  19744. * Creates a new WebVRController from a gamepad
  19745. * @param vrGamepad the gamepad that the WebVRController should be created from
  19746. */
  19747. constructor(vrGamepad: any);
  19748. /**
  19749. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19750. */
  19751. update(): void;
  19752. /**
  19753. * Function to be called when a button is modified
  19754. */
  19755. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19756. /**
  19757. * Loads a mesh and attaches it to the controller
  19758. * @param scene the scene the mesh should be added to
  19759. * @param meshLoaded callback for when the mesh has been loaded
  19760. */
  19761. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19762. private _setButtonValue;
  19763. private _changes;
  19764. private _checkChanges;
  19765. /**
  19766. * Disposes of th webVRCOntroller
  19767. */
  19768. dispose(): void;
  19769. }
  19770. }
  19771. declare module BABYLON {
  19772. /**
  19773. * The HemisphericLight simulates the ambient environment light,
  19774. * so the passed direction is the light reflection direction, not the incoming direction.
  19775. */
  19776. export class HemisphericLight extends Light {
  19777. /**
  19778. * The groundColor is the light in the opposite direction to the one specified during creation.
  19779. * 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.
  19780. */
  19781. groundColor: Color3;
  19782. /**
  19783. * The light reflection direction, not the incoming direction.
  19784. */
  19785. direction: Vector3;
  19786. /**
  19787. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19788. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19789. * The HemisphericLight can't cast shadows.
  19790. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19791. * @param name The friendly name of the light
  19792. * @param direction The direction of the light reflection
  19793. * @param scene The scene the light belongs to
  19794. */
  19795. constructor(name: string, direction: Vector3, scene: Scene);
  19796. protected _buildUniformLayout(): void;
  19797. /**
  19798. * Returns the string "HemisphericLight".
  19799. * @return The class name
  19800. */
  19801. getClassName(): string;
  19802. /**
  19803. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19804. * Returns the updated direction.
  19805. * @param target The target the direction should point to
  19806. * @return The computed direction
  19807. */
  19808. setDirectionToTarget(target: Vector3): Vector3;
  19809. /**
  19810. * Returns the shadow generator associated to the light.
  19811. * @returns Always null for hemispheric lights because it does not support shadows.
  19812. */
  19813. getShadowGenerator(): Nullable<IShadowGenerator>;
  19814. /**
  19815. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19816. * @param effect The effect to update
  19817. * @param lightIndex The index of the light in the effect to update
  19818. * @returns The hemispheric light
  19819. */
  19820. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19821. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19822. /**
  19823. * Computes the world matrix of the node
  19824. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19825. * @param useWasUpdatedFlag defines a reserved property
  19826. * @returns the world matrix
  19827. */
  19828. computeWorldMatrix(): Matrix;
  19829. /**
  19830. * Returns the integer 3.
  19831. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19832. */
  19833. getTypeID(): number;
  19834. /**
  19835. * Prepares the list of defines specific to the light type.
  19836. * @param defines the list of defines
  19837. * @param lightIndex defines the index of the light for the effect
  19838. */
  19839. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19840. }
  19841. }
  19842. declare module BABYLON {
  19843. /** @hidden */
  19844. export var vrMultiviewToSingleviewPixelShader: {
  19845. name: string;
  19846. shader: string;
  19847. };
  19848. }
  19849. declare module BABYLON {
  19850. /**
  19851. * Renders to multiple views with a single draw call
  19852. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19853. */
  19854. export class MultiviewRenderTarget extends RenderTargetTexture {
  19855. /**
  19856. * Creates a multiview render target
  19857. * @param scene scene used with the render target
  19858. * @param size the size of the render target (used for each view)
  19859. */
  19860. constructor(scene: Scene, size?: number | {
  19861. width: number;
  19862. height: number;
  19863. } | {
  19864. ratio: number;
  19865. });
  19866. /**
  19867. * @hidden
  19868. * @param faceIndex the face index, if its a cube texture
  19869. */
  19870. _bindFrameBuffer(faceIndex?: number): void;
  19871. /**
  19872. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19873. * @returns the view count
  19874. */
  19875. getViewCount(): number;
  19876. }
  19877. }
  19878. declare module BABYLON {
  19879. interface Engine {
  19880. /**
  19881. * Creates a new multiview render target
  19882. * @param width defines the width of the texture
  19883. * @param height defines the height of the texture
  19884. * @returns the created multiview texture
  19885. */
  19886. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19887. /**
  19888. * Binds a multiview framebuffer to be drawn to
  19889. * @param multiviewTexture texture to bind
  19890. */
  19891. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19892. }
  19893. interface Camera {
  19894. /**
  19895. * @hidden
  19896. * 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)
  19897. */
  19898. _useMultiviewToSingleView: boolean;
  19899. /**
  19900. * @hidden
  19901. * 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)
  19902. */
  19903. _multiviewTexture: Nullable<RenderTargetTexture>;
  19904. /**
  19905. * @hidden
  19906. * ensures the multiview texture of the camera exists and has the specified width/height
  19907. * @param width height to set on the multiview texture
  19908. * @param height width to set on the multiview texture
  19909. */
  19910. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19911. }
  19912. interface Scene {
  19913. /** @hidden */
  19914. _transformMatrixR: Matrix;
  19915. /** @hidden */
  19916. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19917. /** @hidden */
  19918. _createMultiviewUbo(): void;
  19919. /** @hidden */
  19920. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19921. /** @hidden */
  19922. _renderMultiviewToSingleView(camera: Camera): void;
  19923. }
  19924. }
  19925. declare module BABYLON {
  19926. /**
  19927. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19928. * This will not be used for webXR as it supports displaying texture arrays directly
  19929. */
  19930. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19931. /**
  19932. * Gets a string identifying the name of the class
  19933. * @returns "VRMultiviewToSingleviewPostProcess" string
  19934. */
  19935. getClassName(): string;
  19936. /**
  19937. * Initializes a VRMultiviewToSingleview
  19938. * @param name name of the post process
  19939. * @param camera camera to be applied to
  19940. * @param scaleFactor scaling factor to the size of the output texture
  19941. */
  19942. constructor(name: string, camera: Camera, scaleFactor: number);
  19943. }
  19944. }
  19945. declare module BABYLON {
  19946. /**
  19947. * Interface used to define additional presentation attributes
  19948. */
  19949. export interface IVRPresentationAttributes {
  19950. /**
  19951. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19952. */
  19953. highRefreshRate: boolean;
  19954. /**
  19955. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19956. */
  19957. foveationLevel: number;
  19958. }
  19959. interface Engine {
  19960. /** @hidden */
  19961. _vrDisplay: any;
  19962. /** @hidden */
  19963. _vrSupported: boolean;
  19964. /** @hidden */
  19965. _oldSize: Size;
  19966. /** @hidden */
  19967. _oldHardwareScaleFactor: number;
  19968. /** @hidden */
  19969. _vrExclusivePointerMode: boolean;
  19970. /** @hidden */
  19971. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19972. /** @hidden */
  19973. _onVRDisplayPointerRestricted: () => void;
  19974. /** @hidden */
  19975. _onVRDisplayPointerUnrestricted: () => void;
  19976. /** @hidden */
  19977. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19978. /** @hidden */
  19979. _onVrDisplayDisconnect: Nullable<() => void>;
  19980. /** @hidden */
  19981. _onVrDisplayPresentChange: Nullable<() => void>;
  19982. /**
  19983. * Observable signaled when VR display mode changes
  19984. */
  19985. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19986. /**
  19987. * Observable signaled when VR request present is complete
  19988. */
  19989. onVRRequestPresentComplete: Observable<boolean>;
  19990. /**
  19991. * Observable signaled when VR request present starts
  19992. */
  19993. onVRRequestPresentStart: Observable<Engine>;
  19994. /**
  19995. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19996. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19997. */
  19998. isInVRExclusivePointerMode: boolean;
  19999. /**
  20000. * Gets a boolean indicating if a webVR device was detected
  20001. * @returns true if a webVR device was detected
  20002. */
  20003. isVRDevicePresent(): boolean;
  20004. /**
  20005. * Gets the current webVR device
  20006. * @returns the current webVR device (or null)
  20007. */
  20008. getVRDevice(): any;
  20009. /**
  20010. * Initializes a webVR display and starts listening to display change events
  20011. * The onVRDisplayChangedObservable will be notified upon these changes
  20012. * @returns A promise containing a VRDisplay and if vr is supported
  20013. */
  20014. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20015. /** @hidden */
  20016. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20017. /**
  20018. * Gets or sets the presentation attributes used to configure VR rendering
  20019. */
  20020. vrPresentationAttributes?: IVRPresentationAttributes;
  20021. /**
  20022. * Call this function to switch to webVR mode
  20023. * Will do nothing if webVR is not supported or if there is no webVR device
  20024. * @param options the webvr options provided to the camera. mainly used for multiview
  20025. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20026. */
  20027. enableVR(options: WebVROptions): void;
  20028. /** @hidden */
  20029. _onVRFullScreenTriggered(): void;
  20030. }
  20031. }
  20032. declare module BABYLON {
  20033. /**
  20034. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20035. * IMPORTANT!! The data is right-hand data.
  20036. * @export
  20037. * @interface DevicePose
  20038. */
  20039. export interface DevicePose {
  20040. /**
  20041. * The position of the device, values in array are [x,y,z].
  20042. */
  20043. readonly position: Nullable<Float32Array>;
  20044. /**
  20045. * The linearVelocity of the device, values in array are [x,y,z].
  20046. */
  20047. readonly linearVelocity: Nullable<Float32Array>;
  20048. /**
  20049. * The linearAcceleration of the device, values in array are [x,y,z].
  20050. */
  20051. readonly linearAcceleration: Nullable<Float32Array>;
  20052. /**
  20053. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20054. */
  20055. readonly orientation: Nullable<Float32Array>;
  20056. /**
  20057. * The angularVelocity of the device, values in array are [x,y,z].
  20058. */
  20059. readonly angularVelocity: Nullable<Float32Array>;
  20060. /**
  20061. * The angularAcceleration of the device, values in array are [x,y,z].
  20062. */
  20063. readonly angularAcceleration: Nullable<Float32Array>;
  20064. }
  20065. /**
  20066. * Interface representing a pose controlled object in Babylon.
  20067. * A pose controlled object has both regular pose values as well as pose values
  20068. * from an external device such as a VR head mounted display
  20069. */
  20070. export interface PoseControlled {
  20071. /**
  20072. * The position of the object in babylon space.
  20073. */
  20074. position: Vector3;
  20075. /**
  20076. * The rotation quaternion of the object in babylon space.
  20077. */
  20078. rotationQuaternion: Quaternion;
  20079. /**
  20080. * The position of the device in babylon space.
  20081. */
  20082. devicePosition?: Vector3;
  20083. /**
  20084. * The rotation quaternion of the device in babylon space.
  20085. */
  20086. deviceRotationQuaternion: Quaternion;
  20087. /**
  20088. * The raw pose coming from the device.
  20089. */
  20090. rawPose: Nullable<DevicePose>;
  20091. /**
  20092. * The scale of the device to be used when translating from device space to babylon space.
  20093. */
  20094. deviceScaleFactor: number;
  20095. /**
  20096. * Updates the poseControlled values based on the input device pose.
  20097. * @param poseData the pose data to update the object with
  20098. */
  20099. updateFromDevice(poseData: DevicePose): void;
  20100. }
  20101. /**
  20102. * Set of options to customize the webVRCamera
  20103. */
  20104. export interface WebVROptions {
  20105. /**
  20106. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20107. */
  20108. trackPosition?: boolean;
  20109. /**
  20110. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20111. */
  20112. positionScale?: number;
  20113. /**
  20114. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20115. */
  20116. displayName?: string;
  20117. /**
  20118. * Should the native controller meshes be initialized. (default: true)
  20119. */
  20120. controllerMeshes?: boolean;
  20121. /**
  20122. * Creating a default HemiLight only on controllers. (default: true)
  20123. */
  20124. defaultLightingOnControllers?: boolean;
  20125. /**
  20126. * If you don't want to use the default VR button of the helper. (default: false)
  20127. */
  20128. useCustomVRButton?: boolean;
  20129. /**
  20130. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20131. */
  20132. customVRButton?: HTMLButtonElement;
  20133. /**
  20134. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20135. */
  20136. rayLength?: number;
  20137. /**
  20138. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20139. */
  20140. defaultHeight?: number;
  20141. /**
  20142. * If multiview should be used if availible (default: false)
  20143. */
  20144. useMultiview?: boolean;
  20145. }
  20146. /**
  20147. * This represents a WebVR camera.
  20148. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20149. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20150. */
  20151. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20152. private webVROptions;
  20153. /**
  20154. * @hidden
  20155. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20156. */
  20157. _vrDevice: any;
  20158. /**
  20159. * The rawPose of the vrDevice.
  20160. */
  20161. rawPose: Nullable<DevicePose>;
  20162. private _onVREnabled;
  20163. private _specsVersion;
  20164. private _attached;
  20165. private _frameData;
  20166. protected _descendants: Array<Node>;
  20167. private _deviceRoomPosition;
  20168. /** @hidden */
  20169. _deviceRoomRotationQuaternion: Quaternion;
  20170. private _standingMatrix;
  20171. /**
  20172. * Represents device position in babylon space.
  20173. */
  20174. devicePosition: Vector3;
  20175. /**
  20176. * Represents device rotation in babylon space.
  20177. */
  20178. deviceRotationQuaternion: Quaternion;
  20179. /**
  20180. * The scale of the device to be used when translating from device space to babylon space.
  20181. */
  20182. deviceScaleFactor: number;
  20183. private _deviceToWorld;
  20184. private _worldToDevice;
  20185. /**
  20186. * References to the webVR controllers for the vrDevice.
  20187. */
  20188. controllers: Array<WebVRController>;
  20189. /**
  20190. * Emits an event when a controller is attached.
  20191. */
  20192. onControllersAttachedObservable: Observable<WebVRController[]>;
  20193. /**
  20194. * Emits an event when a controller's mesh has been loaded;
  20195. */
  20196. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20197. /**
  20198. * Emits an event when the HMD's pose has been updated.
  20199. */
  20200. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20201. private _poseSet;
  20202. /**
  20203. * If the rig cameras be used as parent instead of this camera.
  20204. */
  20205. rigParenting: boolean;
  20206. private _lightOnControllers;
  20207. private _defaultHeight?;
  20208. /**
  20209. * Instantiates a WebVRFreeCamera.
  20210. * @param name The name of the WebVRFreeCamera
  20211. * @param position The starting anchor position for the camera
  20212. * @param scene The scene the camera belongs to
  20213. * @param webVROptions a set of customizable options for the webVRCamera
  20214. */
  20215. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20216. /**
  20217. * Gets the device distance from the ground in meters.
  20218. * @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.
  20219. */
  20220. deviceDistanceToRoomGround(): number;
  20221. /**
  20222. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20223. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20224. */
  20225. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20226. /**
  20227. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20228. * @returns A promise with a boolean set to if the standing matrix is supported.
  20229. */
  20230. useStandingMatrixAsync(): Promise<boolean>;
  20231. /**
  20232. * Disposes the camera
  20233. */
  20234. dispose(): void;
  20235. /**
  20236. * Gets a vrController by name.
  20237. * @param name The name of the controller to retreive
  20238. * @returns the controller matching the name specified or null if not found
  20239. */
  20240. getControllerByName(name: string): Nullable<WebVRController>;
  20241. private _leftController;
  20242. /**
  20243. * The controller corresponding to the users left hand.
  20244. */
  20245. get leftController(): Nullable<WebVRController>;
  20246. private _rightController;
  20247. /**
  20248. * The controller corresponding to the users right hand.
  20249. */
  20250. get rightController(): Nullable<WebVRController>;
  20251. /**
  20252. * Casts a ray forward from the vrCamera's gaze.
  20253. * @param length Length of the ray (default: 100)
  20254. * @returns the ray corresponding to the gaze
  20255. */
  20256. getForwardRay(length?: number): Ray;
  20257. /**
  20258. * @hidden
  20259. * Updates the camera based on device's frame data
  20260. */
  20261. _checkInputs(): void;
  20262. /**
  20263. * Updates the poseControlled values based on the input device pose.
  20264. * @param poseData Pose coming from the device
  20265. */
  20266. updateFromDevice(poseData: DevicePose): void;
  20267. private _htmlElementAttached;
  20268. private _detachIfAttached;
  20269. /**
  20270. * WebVR's attach control will start broadcasting frames to the device.
  20271. * Note that in certain browsers (chrome for example) this function must be called
  20272. * within a user-interaction callback. Example:
  20273. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20274. *
  20275. * @param element html element to attach the vrDevice to
  20276. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20277. */
  20278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20279. /**
  20280. * Detaches the camera from the html element and disables VR
  20281. *
  20282. * @param element html element to detach from
  20283. */
  20284. detachControl(element: HTMLElement): void;
  20285. /**
  20286. * @returns the name of this class
  20287. */
  20288. getClassName(): string;
  20289. /**
  20290. * Calls resetPose on the vrDisplay
  20291. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20292. */
  20293. resetToCurrentRotation(): void;
  20294. /**
  20295. * @hidden
  20296. * Updates the rig cameras (left and right eye)
  20297. */
  20298. _updateRigCameras(): void;
  20299. private _workingVector;
  20300. private _oneVector;
  20301. private _workingMatrix;
  20302. private updateCacheCalled;
  20303. private _correctPositionIfNotTrackPosition;
  20304. /**
  20305. * @hidden
  20306. * Updates the cached values of the camera
  20307. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20308. */
  20309. _updateCache(ignoreParentClass?: boolean): void;
  20310. /**
  20311. * @hidden
  20312. * Get current device position in babylon world
  20313. */
  20314. _computeDevicePosition(): void;
  20315. /**
  20316. * Updates the current device position and rotation in the babylon world
  20317. */
  20318. update(): void;
  20319. /**
  20320. * @hidden
  20321. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20322. * @returns an identity matrix
  20323. */
  20324. _getViewMatrix(): Matrix;
  20325. private _tmpMatrix;
  20326. /**
  20327. * This function is called by the two RIG cameras.
  20328. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20329. * @hidden
  20330. */
  20331. _getWebVRViewMatrix(): Matrix;
  20332. /** @hidden */
  20333. _getWebVRProjectionMatrix(): Matrix;
  20334. private _onGamepadConnectedObserver;
  20335. private _onGamepadDisconnectedObserver;
  20336. private _updateCacheWhenTrackingDisabledObserver;
  20337. /**
  20338. * Initializes the controllers and their meshes
  20339. */
  20340. initControllers(): void;
  20341. }
  20342. }
  20343. declare module BABYLON {
  20344. /**
  20345. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20346. *
  20347. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20348. *
  20349. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20350. */
  20351. export class MaterialHelper {
  20352. /**
  20353. * Bind the current view position to an effect.
  20354. * @param effect The effect to be bound
  20355. * @param scene The scene the eyes position is used from
  20356. * @param variableName name of the shader variable that will hold the eye position
  20357. */
  20358. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20359. /**
  20360. * Helps preparing the defines values about the UVs in used in the effect.
  20361. * UVs are shared as much as we can accross channels in the shaders.
  20362. * @param texture The texture we are preparing the UVs for
  20363. * @param defines The defines to update
  20364. * @param key The channel key "diffuse", "specular"... used in the shader
  20365. */
  20366. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20367. /**
  20368. * Binds a texture matrix value to its corrsponding uniform
  20369. * @param texture The texture to bind the matrix for
  20370. * @param uniformBuffer The uniform buffer receivin the data
  20371. * @param key The channel key "diffuse", "specular"... used in the shader
  20372. */
  20373. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20374. /**
  20375. * Gets the current status of the fog (should it be enabled?)
  20376. * @param mesh defines the mesh to evaluate for fog support
  20377. * @param scene defines the hosting scene
  20378. * @returns true if fog must be enabled
  20379. */
  20380. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20381. /**
  20382. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20383. * @param mesh defines the current mesh
  20384. * @param scene defines the current scene
  20385. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20386. * @param pointsCloud defines if point cloud rendering has to be turned on
  20387. * @param fogEnabled defines if fog has to be turned on
  20388. * @param alphaTest defines if alpha testing has to be turned on
  20389. * @param defines defines the current list of defines
  20390. */
  20391. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20392. /**
  20393. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20394. * @param scene defines the current scene
  20395. * @param engine defines the current engine
  20396. * @param defines specifies the list of active defines
  20397. * @param useInstances defines if instances have to be turned on
  20398. * @param useClipPlane defines if clip plane have to be turned on
  20399. * @param useInstances defines if instances have to be turned on
  20400. * @param useThinInstances defines if thin instances have to be turned on
  20401. */
  20402. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20403. /**
  20404. * Prepares the defines for bones
  20405. * @param mesh The mesh containing the geometry data we will draw
  20406. * @param defines The defines to update
  20407. */
  20408. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20409. /**
  20410. * Prepares the defines for morph targets
  20411. * @param mesh The mesh containing the geometry data we will draw
  20412. * @param defines The defines to update
  20413. */
  20414. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20415. /**
  20416. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20417. * @param mesh The mesh containing the geometry data we will draw
  20418. * @param defines The defines to update
  20419. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20420. * @param useBones Precise whether bones should be used or not (override mesh info)
  20421. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20422. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20423. * @returns false if defines are considered not dirty and have not been checked
  20424. */
  20425. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20426. /**
  20427. * Prepares the defines related to multiview
  20428. * @param scene The scene we are intending to draw
  20429. * @param defines The defines to update
  20430. */
  20431. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20432. /**
  20433. * Prepares the defines related to the prepass
  20434. * @param scene The scene we are intending to draw
  20435. * @param defines The defines to update
  20436. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20437. */
  20438. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20439. /**
  20440. * Prepares the defines related to the light information passed in parameter
  20441. * @param scene The scene we are intending to draw
  20442. * @param mesh The mesh the effect is compiling for
  20443. * @param light The light the effect is compiling for
  20444. * @param lightIndex The index of the light
  20445. * @param defines The defines to update
  20446. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20447. * @param state Defines the current state regarding what is needed (normals, etc...)
  20448. */
  20449. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20450. needNormals: boolean;
  20451. needRebuild: boolean;
  20452. shadowEnabled: boolean;
  20453. specularEnabled: boolean;
  20454. lightmapMode: boolean;
  20455. }): void;
  20456. /**
  20457. * Prepares the defines related to the light information passed in parameter
  20458. * @param scene The scene we are intending to draw
  20459. * @param mesh The mesh the effect is compiling for
  20460. * @param defines The defines to update
  20461. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20462. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20463. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20464. * @returns true if normals will be required for the rest of the effect
  20465. */
  20466. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20467. /**
  20468. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20469. * @param lightIndex defines the light index
  20470. * @param uniformsList The uniform list
  20471. * @param samplersList The sampler list
  20472. * @param projectedLightTexture defines if projected texture must be used
  20473. * @param uniformBuffersList defines an optional list of uniform buffers
  20474. */
  20475. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20476. /**
  20477. * Prepares the uniforms and samplers list to be used in the effect
  20478. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20479. * @param samplersList The sampler list
  20480. * @param defines The defines helping in the list generation
  20481. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20482. */
  20483. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20484. /**
  20485. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20486. * @param defines The defines to update while falling back
  20487. * @param fallbacks The authorized effect fallbacks
  20488. * @param maxSimultaneousLights The maximum number of lights allowed
  20489. * @param rank the current rank of the Effect
  20490. * @returns The newly affected rank
  20491. */
  20492. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20493. private static _TmpMorphInfluencers;
  20494. /**
  20495. * Prepares the list of attributes required for morph targets according to the effect defines.
  20496. * @param attribs The current list of supported attribs
  20497. * @param mesh The mesh to prepare the morph targets attributes for
  20498. * @param influencers The number of influencers
  20499. */
  20500. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20501. /**
  20502. * Prepares the list of attributes required for morph targets according to the effect defines.
  20503. * @param attribs The current list of supported attribs
  20504. * @param mesh The mesh to prepare the morph targets attributes for
  20505. * @param defines The current Defines of the effect
  20506. */
  20507. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20508. /**
  20509. * Prepares the list of attributes required for bones according to the effect defines.
  20510. * @param attribs The current list of supported attribs
  20511. * @param mesh The mesh to prepare the bones attributes for
  20512. * @param defines The current Defines of the effect
  20513. * @param fallbacks The current efffect fallback strategy
  20514. */
  20515. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20516. /**
  20517. * Check and prepare the list of attributes required for instances according to the effect defines.
  20518. * @param attribs The current list of supported attribs
  20519. * @param defines The current MaterialDefines of the effect
  20520. */
  20521. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20522. /**
  20523. * Add the list of attributes required for instances to the attribs array.
  20524. * @param attribs The current list of supported attribs
  20525. */
  20526. static PushAttributesForInstances(attribs: string[]): void;
  20527. /**
  20528. * Binds the light information to the effect.
  20529. * @param light The light containing the generator
  20530. * @param effect The effect we are binding the data to
  20531. * @param lightIndex The light index in the effect used to render
  20532. */
  20533. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20534. /**
  20535. * Binds the lights information from the scene to the effect for the given mesh.
  20536. * @param light Light to bind
  20537. * @param lightIndex Light index
  20538. * @param scene The scene where the light belongs to
  20539. * @param effect The effect we are binding the data to
  20540. * @param useSpecular Defines if specular is supported
  20541. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20542. */
  20543. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20544. /**
  20545. * Binds the lights information from the scene to the effect for the given mesh.
  20546. * @param scene The scene the lights belongs to
  20547. * @param mesh The mesh we are binding the information to render
  20548. * @param effect The effect we are binding the data to
  20549. * @param defines The generated defines for the effect
  20550. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20551. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20552. */
  20553. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20554. private static _tempFogColor;
  20555. /**
  20556. * Binds the fog information from the scene to the effect for the given mesh.
  20557. * @param scene The scene the lights belongs to
  20558. * @param mesh The mesh we are binding the information to render
  20559. * @param effect The effect we are binding the data to
  20560. * @param linearSpace Defines if the fog effect is applied in linear space
  20561. */
  20562. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20563. /**
  20564. * Binds the bones information from the mesh to the effect.
  20565. * @param mesh The mesh we are binding the information to render
  20566. * @param effect The effect we are binding the data to
  20567. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20568. */
  20569. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20570. private static _CopyBonesTransformationMatrices;
  20571. /**
  20572. * Binds the morph targets information from the mesh to the effect.
  20573. * @param abstractMesh The mesh we are binding the information to render
  20574. * @param effect The effect we are binding the data to
  20575. */
  20576. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20577. /**
  20578. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20579. * @param defines The generated defines used in the effect
  20580. * @param effect The effect we are binding the data to
  20581. * @param scene The scene we are willing to render with logarithmic scale for
  20582. */
  20583. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20584. /**
  20585. * Binds the clip plane information from the scene to the effect.
  20586. * @param scene The scene the clip plane information are extracted from
  20587. * @param effect The effect we are binding the data to
  20588. */
  20589. static BindClipPlane(effect: Effect, scene: Scene): void;
  20590. }
  20591. }
  20592. declare module BABYLON {
  20593. /**
  20594. * Block used to expose an input value
  20595. */
  20596. export class InputBlock extends NodeMaterialBlock {
  20597. private _mode;
  20598. private _associatedVariableName;
  20599. private _storedValue;
  20600. private _valueCallback;
  20601. private _type;
  20602. private _animationType;
  20603. /** Gets or set a value used to limit the range of float values */
  20604. min: number;
  20605. /** Gets or set a value used to limit the range of float values */
  20606. max: number;
  20607. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20608. isBoolean: boolean;
  20609. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20610. matrixMode: number;
  20611. /** @hidden */
  20612. _systemValue: Nullable<NodeMaterialSystemValues>;
  20613. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20614. isConstant: boolean;
  20615. /** Gets or sets the group to use to display this block in the Inspector */
  20616. groupInInspector: string;
  20617. /** Gets an observable raised when the value is changed */
  20618. onValueChangedObservable: Observable<InputBlock>;
  20619. /**
  20620. * Gets or sets the connection point type (default is float)
  20621. */
  20622. get type(): NodeMaterialBlockConnectionPointTypes;
  20623. /**
  20624. * Creates a new InputBlock
  20625. * @param name defines the block name
  20626. * @param target defines the target of that block (Vertex by default)
  20627. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20628. */
  20629. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20630. /**
  20631. * Validates if a name is a reserve word.
  20632. * @param newName the new name to be given to the node.
  20633. * @returns false if the name is a reserve word, else true.
  20634. */
  20635. validateBlockName(newName: string): boolean;
  20636. /**
  20637. * Gets the output component
  20638. */
  20639. get output(): NodeMaterialConnectionPoint;
  20640. /**
  20641. * Set the source of this connection point to a vertex attribute
  20642. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20643. * @returns the current connection point
  20644. */
  20645. setAsAttribute(attributeName?: string): InputBlock;
  20646. /**
  20647. * Set the source of this connection point to a system value
  20648. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20649. * @returns the current connection point
  20650. */
  20651. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20652. /**
  20653. * Gets or sets the value of that point.
  20654. * Please note that this value will be ignored if valueCallback is defined
  20655. */
  20656. get value(): any;
  20657. set value(value: any);
  20658. /**
  20659. * Gets or sets a callback used to get the value of that point.
  20660. * Please note that setting this value will force the connection point to ignore the value property
  20661. */
  20662. get valueCallback(): () => any;
  20663. set valueCallback(value: () => any);
  20664. /**
  20665. * Gets or sets the associated variable name in the shader
  20666. */
  20667. get associatedVariableName(): string;
  20668. set associatedVariableName(value: string);
  20669. /** Gets or sets the type of animation applied to the input */
  20670. get animationType(): AnimatedInputBlockTypes;
  20671. set animationType(value: AnimatedInputBlockTypes);
  20672. /**
  20673. * Gets a boolean indicating that this connection point not defined yet
  20674. */
  20675. get isUndefined(): boolean;
  20676. /**
  20677. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20678. * In this case the connection point name must be the name of the uniform to use.
  20679. * Can only be set on inputs
  20680. */
  20681. get isUniform(): boolean;
  20682. set isUniform(value: boolean);
  20683. /**
  20684. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20685. * In this case the connection point name must be the name of the attribute to use
  20686. * Can only be set on inputs
  20687. */
  20688. get isAttribute(): boolean;
  20689. set isAttribute(value: boolean);
  20690. /**
  20691. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20692. * Can only be set on exit points
  20693. */
  20694. get isVarying(): boolean;
  20695. set isVarying(value: boolean);
  20696. /**
  20697. * Gets a boolean indicating that the current connection point is a system value
  20698. */
  20699. get isSystemValue(): boolean;
  20700. /**
  20701. * Gets or sets the current well known value or null if not defined as a system value
  20702. */
  20703. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20704. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20705. /**
  20706. * Gets the current class name
  20707. * @returns the class name
  20708. */
  20709. getClassName(): string;
  20710. /**
  20711. * Animate the input if animationType !== None
  20712. * @param scene defines the rendering scene
  20713. */
  20714. animate(scene: Scene): void;
  20715. private _emitDefine;
  20716. initialize(state: NodeMaterialBuildState): void;
  20717. /**
  20718. * Set the input block to its default value (based on its type)
  20719. */
  20720. setDefaultValue(): void;
  20721. private _emitConstant;
  20722. /** @hidden */
  20723. get _noContextSwitch(): boolean;
  20724. private _emit;
  20725. /** @hidden */
  20726. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20727. /** @hidden */
  20728. _transmit(effect: Effect, scene: Scene): void;
  20729. protected _buildBlock(state: NodeMaterialBuildState): void;
  20730. protected _dumpPropertiesCode(): string;
  20731. dispose(): void;
  20732. serialize(): any;
  20733. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20734. }
  20735. }
  20736. declare module BABYLON {
  20737. /**
  20738. * Enum used to define the compatibility state between two connection points
  20739. */
  20740. export enum NodeMaterialConnectionPointCompatibilityStates {
  20741. /** Points are compatibles */
  20742. Compatible = 0,
  20743. /** Points are incompatible because of their types */
  20744. TypeIncompatible = 1,
  20745. /** Points are incompatible because of their targets (vertex vs fragment) */
  20746. TargetIncompatible = 2
  20747. }
  20748. /**
  20749. * Defines the direction of a connection point
  20750. */
  20751. export enum NodeMaterialConnectionPointDirection {
  20752. /** Input */
  20753. Input = 0,
  20754. /** Output */
  20755. Output = 1
  20756. }
  20757. /**
  20758. * Defines a connection point for a block
  20759. */
  20760. export class NodeMaterialConnectionPoint {
  20761. /** @hidden */
  20762. _ownerBlock: NodeMaterialBlock;
  20763. /** @hidden */
  20764. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20765. private _endpoints;
  20766. private _associatedVariableName;
  20767. private _direction;
  20768. /** @hidden */
  20769. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20770. /** @hidden */
  20771. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20772. private _type;
  20773. /** @hidden */
  20774. _enforceAssociatedVariableName: boolean;
  20775. /** Gets the direction of the point */
  20776. get direction(): NodeMaterialConnectionPointDirection;
  20777. /** Indicates that this connection point needs dual validation before being connected to another point */
  20778. needDualDirectionValidation: boolean;
  20779. /**
  20780. * Gets or sets the additional types supported by this connection point
  20781. */
  20782. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20783. /**
  20784. * Gets or sets the additional types excluded by this connection point
  20785. */
  20786. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20787. /**
  20788. * Observable triggered when this point is connected
  20789. */
  20790. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20791. /**
  20792. * Gets or sets the associated variable name in the shader
  20793. */
  20794. get associatedVariableName(): string;
  20795. set associatedVariableName(value: string);
  20796. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20797. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20798. /**
  20799. * Gets or sets the connection point type (default is float)
  20800. */
  20801. get type(): NodeMaterialBlockConnectionPointTypes;
  20802. set type(value: NodeMaterialBlockConnectionPointTypes);
  20803. /**
  20804. * Gets or sets the connection point name
  20805. */
  20806. name: string;
  20807. /**
  20808. * Gets or sets the connection point name
  20809. */
  20810. displayName: string;
  20811. /**
  20812. * Gets or sets a boolean indicating that this connection point can be omitted
  20813. */
  20814. isOptional: boolean;
  20815. /**
  20816. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20817. */
  20818. isExposedOnFrame: boolean;
  20819. /**
  20820. * Gets or sets number indicating the position that the port is exposed to on a frame
  20821. */
  20822. exposedPortPosition: number;
  20823. /**
  20824. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20825. */
  20826. define: string;
  20827. /** @hidden */
  20828. _prioritizeVertex: boolean;
  20829. private _target;
  20830. /** Gets or sets the target of that connection point */
  20831. get target(): NodeMaterialBlockTargets;
  20832. set target(value: NodeMaterialBlockTargets);
  20833. /**
  20834. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20835. */
  20836. get isConnected(): boolean;
  20837. /**
  20838. * Gets a boolean indicating that the current point is connected to an input block
  20839. */
  20840. get isConnectedToInputBlock(): boolean;
  20841. /**
  20842. * Gets a the connected input block (if any)
  20843. */
  20844. get connectInputBlock(): Nullable<InputBlock>;
  20845. /** Get the other side of the connection (if any) */
  20846. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20847. /** Get the block that owns this connection point */
  20848. get ownerBlock(): NodeMaterialBlock;
  20849. /** Get the block connected on the other side of this connection (if any) */
  20850. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20851. /** Get the block connected on the endpoints of this connection (if any) */
  20852. get connectedBlocks(): Array<NodeMaterialBlock>;
  20853. /** Gets the list of connected endpoints */
  20854. get endpoints(): NodeMaterialConnectionPoint[];
  20855. /** Gets a boolean indicating if that output point is connected to at least one input */
  20856. get hasEndpoints(): boolean;
  20857. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20858. get isConnectedInVertexShader(): boolean;
  20859. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20860. get isConnectedInFragmentShader(): boolean;
  20861. /**
  20862. * Creates a block suitable to be used as an input for this input point.
  20863. * If null is returned, a block based on the point type will be created.
  20864. * @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
  20865. */
  20866. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20867. /**
  20868. * Creates a new connection point
  20869. * @param name defines the connection point name
  20870. * @param ownerBlock defines the block hosting this connection point
  20871. * @param direction defines the direction of the connection point
  20872. */
  20873. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20874. /**
  20875. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20876. * @returns the class name
  20877. */
  20878. getClassName(): string;
  20879. /**
  20880. * Gets a boolean indicating if the current point can be connected to another point
  20881. * @param connectionPoint defines the other connection point
  20882. * @returns a boolean
  20883. */
  20884. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20885. /**
  20886. * Gets a number indicating if the current point can be connected to another point
  20887. * @param connectionPoint defines the other connection point
  20888. * @returns a number defining the compatibility state
  20889. */
  20890. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20891. /**
  20892. * Connect this point to another connection point
  20893. * @param connectionPoint defines the other connection point
  20894. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20895. * @returns the current connection point
  20896. */
  20897. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20898. /**
  20899. * Disconnect this point from one of his endpoint
  20900. * @param endpoint defines the other connection point
  20901. * @returns the current connection point
  20902. */
  20903. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20904. /**
  20905. * Serializes this point in a JSON representation
  20906. * @param isInput defines if the connection point is an input (default is true)
  20907. * @returns the serialized point object
  20908. */
  20909. serialize(isInput?: boolean): any;
  20910. /**
  20911. * Release resources
  20912. */
  20913. dispose(): void;
  20914. }
  20915. }
  20916. declare module BABYLON {
  20917. /**
  20918. * Enum used to define the material modes
  20919. */
  20920. export enum NodeMaterialModes {
  20921. /** Regular material */
  20922. Material = 0,
  20923. /** For post process */
  20924. PostProcess = 1,
  20925. /** For particle system */
  20926. Particle = 2,
  20927. /** For procedural texture */
  20928. ProceduralTexture = 3
  20929. }
  20930. }
  20931. declare module BABYLON {
  20932. /**
  20933. * Block used to read a texture from a sampler
  20934. */
  20935. export class TextureBlock extends NodeMaterialBlock {
  20936. private _defineName;
  20937. private _linearDefineName;
  20938. private _gammaDefineName;
  20939. private _tempTextureRead;
  20940. private _samplerName;
  20941. private _transformedUVName;
  20942. private _textureTransformName;
  20943. private _textureInfoName;
  20944. private _mainUVName;
  20945. private _mainUVDefineName;
  20946. private _fragmentOnly;
  20947. /**
  20948. * Gets or sets the texture associated with the node
  20949. */
  20950. texture: Nullable<Texture>;
  20951. /**
  20952. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20953. */
  20954. convertToGammaSpace: boolean;
  20955. /**
  20956. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20957. */
  20958. convertToLinearSpace: boolean;
  20959. /**
  20960. * Create a new TextureBlock
  20961. * @param name defines the block name
  20962. */
  20963. constructor(name: string, fragmentOnly?: boolean);
  20964. /**
  20965. * Gets the current class name
  20966. * @returns the class name
  20967. */
  20968. getClassName(): string;
  20969. /**
  20970. * Gets the uv input component
  20971. */
  20972. get uv(): NodeMaterialConnectionPoint;
  20973. /**
  20974. * Gets the rgba output component
  20975. */
  20976. get rgba(): NodeMaterialConnectionPoint;
  20977. /**
  20978. * Gets the rgb output component
  20979. */
  20980. get rgb(): NodeMaterialConnectionPoint;
  20981. /**
  20982. * Gets the r output component
  20983. */
  20984. get r(): NodeMaterialConnectionPoint;
  20985. /**
  20986. * Gets the g output component
  20987. */
  20988. get g(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the b output component
  20991. */
  20992. get b(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Gets the a output component
  20995. */
  20996. get a(): NodeMaterialConnectionPoint;
  20997. get target(): NodeMaterialBlockTargets;
  20998. autoConfigure(material: NodeMaterial): void;
  20999. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21001. isReady(): boolean;
  21002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21003. private get _isMixed();
  21004. private _injectVertexCode;
  21005. private _writeTextureRead;
  21006. private _writeOutput;
  21007. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21008. protected _dumpPropertiesCode(): string;
  21009. serialize(): any;
  21010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21011. }
  21012. }
  21013. declare module BABYLON {
  21014. /** @hidden */
  21015. export var reflectionFunction: {
  21016. name: string;
  21017. shader: string;
  21018. };
  21019. }
  21020. declare module BABYLON {
  21021. /**
  21022. * Base block used to read a reflection texture from a sampler
  21023. */
  21024. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21025. /** @hidden */
  21026. _define3DName: string;
  21027. /** @hidden */
  21028. _defineCubicName: string;
  21029. /** @hidden */
  21030. _defineExplicitName: string;
  21031. /** @hidden */
  21032. _defineProjectionName: string;
  21033. /** @hidden */
  21034. _defineLocalCubicName: string;
  21035. /** @hidden */
  21036. _defineSphericalName: string;
  21037. /** @hidden */
  21038. _definePlanarName: string;
  21039. /** @hidden */
  21040. _defineEquirectangularName: string;
  21041. /** @hidden */
  21042. _defineMirroredEquirectangularFixedName: string;
  21043. /** @hidden */
  21044. _defineEquirectangularFixedName: string;
  21045. /** @hidden */
  21046. _defineSkyboxName: string;
  21047. /** @hidden */
  21048. _defineOppositeZ: string;
  21049. /** @hidden */
  21050. _cubeSamplerName: string;
  21051. /** @hidden */
  21052. _2DSamplerName: string;
  21053. protected _positionUVWName: string;
  21054. protected _directionWName: string;
  21055. protected _reflectionVectorName: string;
  21056. /** @hidden */
  21057. _reflectionCoordsName: string;
  21058. /** @hidden */
  21059. _reflectionMatrixName: string;
  21060. protected _reflectionColorName: string;
  21061. /**
  21062. * Gets or sets the texture associated with the node
  21063. */
  21064. texture: Nullable<BaseTexture>;
  21065. /**
  21066. * Create a new ReflectionTextureBaseBlock
  21067. * @param name defines the block name
  21068. */
  21069. constructor(name: string);
  21070. /**
  21071. * Gets the current class name
  21072. * @returns the class name
  21073. */
  21074. getClassName(): string;
  21075. /**
  21076. * Gets the world position input component
  21077. */
  21078. abstract get position(): NodeMaterialConnectionPoint;
  21079. /**
  21080. * Gets the world position input component
  21081. */
  21082. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21083. /**
  21084. * Gets the world normal input component
  21085. */
  21086. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21087. /**
  21088. * Gets the world input component
  21089. */
  21090. abstract get world(): NodeMaterialConnectionPoint;
  21091. /**
  21092. * Gets the camera (or eye) position component
  21093. */
  21094. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21095. /**
  21096. * Gets the view input component
  21097. */
  21098. abstract get view(): NodeMaterialConnectionPoint;
  21099. protected _getTexture(): Nullable<BaseTexture>;
  21100. autoConfigure(material: NodeMaterial): void;
  21101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21102. isReady(): boolean;
  21103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21104. /**
  21105. * Gets the code to inject in the vertex shader
  21106. * @param state current state of the node material building
  21107. * @returns the shader code
  21108. */
  21109. handleVertexSide(state: NodeMaterialBuildState): string;
  21110. /**
  21111. * Handles the inits for the fragment code path
  21112. * @param state node material build state
  21113. */
  21114. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21115. /**
  21116. * Generates the reflection coords code for the fragment code path
  21117. * @param worldNormalVarName name of the world normal variable
  21118. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21119. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21120. * @returns the shader code
  21121. */
  21122. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21123. /**
  21124. * Generates the reflection color code for the fragment code path
  21125. * @param lodVarName name of the lod variable
  21126. * @param swizzleLookupTexture swizzle to use for the final color variable
  21127. * @returns the shader code
  21128. */
  21129. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21130. /**
  21131. * Generates the code corresponding to the connected output points
  21132. * @param state node material build state
  21133. * @param varName name of the variable to output
  21134. * @returns the shader code
  21135. */
  21136. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21137. protected _buildBlock(state: NodeMaterialBuildState): this;
  21138. protected _dumpPropertiesCode(): string;
  21139. serialize(): any;
  21140. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21141. }
  21142. }
  21143. declare module BABYLON {
  21144. /**
  21145. * Defines a connection point to be used for points with a custom object type
  21146. */
  21147. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21148. private _blockType;
  21149. private _blockName;
  21150. private _nameForCheking?;
  21151. /**
  21152. * Creates a new connection point
  21153. * @param name defines the connection point name
  21154. * @param ownerBlock defines the block hosting this connection point
  21155. * @param direction defines the direction of the connection point
  21156. */
  21157. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21158. /**
  21159. * Gets a number indicating if the current point can be connected to another point
  21160. * @param connectionPoint defines the other connection point
  21161. * @returns a number defining the compatibility state
  21162. */
  21163. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21164. /**
  21165. * Creates a block suitable to be used as an input for this input point.
  21166. * If null is returned, a block based on the point type will be created.
  21167. * @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
  21168. */
  21169. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21170. }
  21171. }
  21172. declare module BABYLON {
  21173. /**
  21174. * Enum defining the type of properties that can be edited in the property pages in the NME
  21175. */
  21176. export enum PropertyTypeForEdition {
  21177. /** property is a boolean */
  21178. Boolean = 0,
  21179. /** property is a float */
  21180. Float = 1,
  21181. /** property is a Vector2 */
  21182. Vector2 = 2,
  21183. /** property is a list of values */
  21184. List = 3
  21185. }
  21186. /**
  21187. * Interface that defines an option in a variable of type list
  21188. */
  21189. export interface IEditablePropertyListOption {
  21190. /** label of the option */
  21191. "label": string;
  21192. /** value of the option */
  21193. "value": number;
  21194. }
  21195. /**
  21196. * Interface that defines the options available for an editable property
  21197. */
  21198. export interface IEditablePropertyOption {
  21199. /** min value */
  21200. "min"?: number;
  21201. /** max value */
  21202. "max"?: number;
  21203. /** notifiers: indicates which actions to take when the property is changed */
  21204. "notifiers"?: {
  21205. /** the material should be rebuilt */
  21206. "rebuild"?: boolean;
  21207. /** the preview should be updated */
  21208. "update"?: boolean;
  21209. };
  21210. /** list of the options for a variable of type list */
  21211. "options"?: IEditablePropertyListOption[];
  21212. }
  21213. /**
  21214. * Interface that describes an editable property
  21215. */
  21216. export interface IPropertyDescriptionForEdition {
  21217. /** name of the property */
  21218. "propertyName": string;
  21219. /** display name of the property */
  21220. "displayName": string;
  21221. /** type of the property */
  21222. "type": PropertyTypeForEdition;
  21223. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21224. "groupName": string;
  21225. /** options for the property */
  21226. "options": IEditablePropertyOption;
  21227. }
  21228. /**
  21229. * Decorator that flags a property in a node material block as being editable
  21230. */
  21231. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21232. }
  21233. declare module BABYLON {
  21234. /**
  21235. * Block used to implement the refraction part of the sub surface module of the PBR material
  21236. */
  21237. export class RefractionBlock extends NodeMaterialBlock {
  21238. /** @hidden */
  21239. _define3DName: string;
  21240. /** @hidden */
  21241. _refractionMatrixName: string;
  21242. /** @hidden */
  21243. _defineLODRefractionAlpha: string;
  21244. /** @hidden */
  21245. _defineLinearSpecularRefraction: string;
  21246. /** @hidden */
  21247. _defineOppositeZ: string;
  21248. /** @hidden */
  21249. _cubeSamplerName: string;
  21250. /** @hidden */
  21251. _2DSamplerName: string;
  21252. /** @hidden */
  21253. _vRefractionMicrosurfaceInfosName: string;
  21254. /** @hidden */
  21255. _vRefractionInfosName: string;
  21256. private _scene;
  21257. /**
  21258. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21259. * Materials half opaque for instance using refraction could benefit from this control.
  21260. */
  21261. linkRefractionWithTransparency: boolean;
  21262. /**
  21263. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21264. */
  21265. invertRefractionY: boolean;
  21266. /**
  21267. * Gets or sets the texture associated with the node
  21268. */
  21269. texture: Nullable<BaseTexture>;
  21270. /**
  21271. * Create a new RefractionBlock
  21272. * @param name defines the block name
  21273. */
  21274. constructor(name: string);
  21275. /**
  21276. * Gets the current class name
  21277. * @returns the class name
  21278. */
  21279. getClassName(): string;
  21280. /**
  21281. * Gets the intensity input component
  21282. */
  21283. get intensity(): NodeMaterialConnectionPoint;
  21284. /**
  21285. * Gets the index of refraction input component
  21286. */
  21287. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21288. /**
  21289. * Gets the tint at distance input component
  21290. */
  21291. get tintAtDistance(): NodeMaterialConnectionPoint;
  21292. /**
  21293. * Gets the view input component
  21294. */
  21295. get view(): NodeMaterialConnectionPoint;
  21296. /**
  21297. * Gets the refraction object output component
  21298. */
  21299. get refraction(): NodeMaterialConnectionPoint;
  21300. /**
  21301. * Returns true if the block has a texture
  21302. */
  21303. get hasTexture(): boolean;
  21304. protected _getTexture(): Nullable<BaseTexture>;
  21305. autoConfigure(material: NodeMaterial): void;
  21306. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21307. isReady(): boolean;
  21308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21309. /**
  21310. * Gets the main code of the block (fragment side)
  21311. * @param state current state of the node material building
  21312. * @returns the shader code
  21313. */
  21314. getCode(state: NodeMaterialBuildState): string;
  21315. protected _buildBlock(state: NodeMaterialBuildState): this;
  21316. protected _dumpPropertiesCode(): string;
  21317. serialize(): any;
  21318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21319. }
  21320. }
  21321. declare module BABYLON {
  21322. /**
  21323. * Base block used as input for post process
  21324. */
  21325. export class CurrentScreenBlock extends NodeMaterialBlock {
  21326. private _samplerName;
  21327. private _linearDefineName;
  21328. private _gammaDefineName;
  21329. private _mainUVName;
  21330. private _tempTextureRead;
  21331. /**
  21332. * Gets or sets the texture associated with the node
  21333. */
  21334. texture: Nullable<BaseTexture>;
  21335. /**
  21336. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21337. */
  21338. convertToGammaSpace: boolean;
  21339. /**
  21340. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21341. */
  21342. convertToLinearSpace: boolean;
  21343. /**
  21344. * Create a new CurrentScreenBlock
  21345. * @param name defines the block name
  21346. */
  21347. constructor(name: string);
  21348. /**
  21349. * Gets the current class name
  21350. * @returns the class name
  21351. */
  21352. getClassName(): string;
  21353. /**
  21354. * Gets the uv input component
  21355. */
  21356. get uv(): NodeMaterialConnectionPoint;
  21357. /**
  21358. * Gets the rgba output component
  21359. */
  21360. get rgba(): NodeMaterialConnectionPoint;
  21361. /**
  21362. * Gets the rgb output component
  21363. */
  21364. get rgb(): NodeMaterialConnectionPoint;
  21365. /**
  21366. * Gets the r output component
  21367. */
  21368. get r(): NodeMaterialConnectionPoint;
  21369. /**
  21370. * Gets the g output component
  21371. */
  21372. get g(): NodeMaterialConnectionPoint;
  21373. /**
  21374. * Gets the b output component
  21375. */
  21376. get b(): NodeMaterialConnectionPoint;
  21377. /**
  21378. * Gets the a output component
  21379. */
  21380. get a(): NodeMaterialConnectionPoint;
  21381. /**
  21382. * Initialize the block and prepare the context for build
  21383. * @param state defines the state that will be used for the build
  21384. */
  21385. initialize(state: NodeMaterialBuildState): void;
  21386. get target(): NodeMaterialBlockTargets;
  21387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21388. isReady(): boolean;
  21389. private _injectVertexCode;
  21390. private _writeTextureRead;
  21391. private _writeOutput;
  21392. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21393. serialize(): any;
  21394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21395. }
  21396. }
  21397. declare module BABYLON {
  21398. /**
  21399. * Base block used for the particle texture
  21400. */
  21401. export class ParticleTextureBlock extends NodeMaterialBlock {
  21402. private _samplerName;
  21403. private _linearDefineName;
  21404. private _gammaDefineName;
  21405. private _tempTextureRead;
  21406. /**
  21407. * Gets or sets the texture associated with the node
  21408. */
  21409. texture: Nullable<BaseTexture>;
  21410. /**
  21411. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21412. */
  21413. convertToGammaSpace: boolean;
  21414. /**
  21415. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21416. */
  21417. convertToLinearSpace: boolean;
  21418. /**
  21419. * Create a new ParticleTextureBlock
  21420. * @param name defines the block name
  21421. */
  21422. constructor(name: string);
  21423. /**
  21424. * Gets the current class name
  21425. * @returns the class name
  21426. */
  21427. getClassName(): string;
  21428. /**
  21429. * Gets the uv input component
  21430. */
  21431. get uv(): NodeMaterialConnectionPoint;
  21432. /**
  21433. * Gets the rgba output component
  21434. */
  21435. get rgba(): NodeMaterialConnectionPoint;
  21436. /**
  21437. * Gets the rgb output component
  21438. */
  21439. get rgb(): NodeMaterialConnectionPoint;
  21440. /**
  21441. * Gets the r output component
  21442. */
  21443. get r(): NodeMaterialConnectionPoint;
  21444. /**
  21445. * Gets the g output component
  21446. */
  21447. get g(): NodeMaterialConnectionPoint;
  21448. /**
  21449. * Gets the b output component
  21450. */
  21451. get b(): NodeMaterialConnectionPoint;
  21452. /**
  21453. * Gets the a output component
  21454. */
  21455. get a(): NodeMaterialConnectionPoint;
  21456. /**
  21457. * Initialize the block and prepare the context for build
  21458. * @param state defines the state that will be used for the build
  21459. */
  21460. initialize(state: NodeMaterialBuildState): void;
  21461. autoConfigure(material: NodeMaterial): void;
  21462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21463. isReady(): boolean;
  21464. private _writeOutput;
  21465. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21466. serialize(): any;
  21467. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21468. }
  21469. }
  21470. declare module BABYLON {
  21471. /**
  21472. * Class used to store shared data between 2 NodeMaterialBuildState
  21473. */
  21474. export class NodeMaterialBuildStateSharedData {
  21475. /**
  21476. * Gets the list of emitted varyings
  21477. */
  21478. temps: string[];
  21479. /**
  21480. * Gets the list of emitted varyings
  21481. */
  21482. varyings: string[];
  21483. /**
  21484. * Gets the varying declaration string
  21485. */
  21486. varyingDeclaration: string;
  21487. /**
  21488. * Input blocks
  21489. */
  21490. inputBlocks: InputBlock[];
  21491. /**
  21492. * Input blocks
  21493. */
  21494. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21495. /**
  21496. * Bindable blocks (Blocks that need to set data to the effect)
  21497. */
  21498. bindableBlocks: NodeMaterialBlock[];
  21499. /**
  21500. * List of blocks that can provide a compilation fallback
  21501. */
  21502. blocksWithFallbacks: NodeMaterialBlock[];
  21503. /**
  21504. * List of blocks that can provide a define update
  21505. */
  21506. blocksWithDefines: NodeMaterialBlock[];
  21507. /**
  21508. * List of blocks that can provide a repeatable content
  21509. */
  21510. repeatableContentBlocks: NodeMaterialBlock[];
  21511. /**
  21512. * List of blocks that can provide a dynamic list of uniforms
  21513. */
  21514. dynamicUniformBlocks: NodeMaterialBlock[];
  21515. /**
  21516. * List of blocks that can block the isReady function for the material
  21517. */
  21518. blockingBlocks: NodeMaterialBlock[];
  21519. /**
  21520. * Gets the list of animated inputs
  21521. */
  21522. animatedInputs: InputBlock[];
  21523. /**
  21524. * Build Id used to avoid multiple recompilations
  21525. */
  21526. buildId: number;
  21527. /** List of emitted variables */
  21528. variableNames: {
  21529. [key: string]: number;
  21530. };
  21531. /** List of emitted defines */
  21532. defineNames: {
  21533. [key: string]: number;
  21534. };
  21535. /** Should emit comments? */
  21536. emitComments: boolean;
  21537. /** Emit build activity */
  21538. verbose: boolean;
  21539. /** Gets or sets the hosting scene */
  21540. scene: Scene;
  21541. /**
  21542. * Gets the compilation hints emitted at compilation time
  21543. */
  21544. hints: {
  21545. needWorldViewMatrix: boolean;
  21546. needWorldViewProjectionMatrix: boolean;
  21547. needAlphaBlending: boolean;
  21548. needAlphaTesting: boolean;
  21549. };
  21550. /**
  21551. * List of compilation checks
  21552. */
  21553. checks: {
  21554. emitVertex: boolean;
  21555. emitFragment: boolean;
  21556. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21557. };
  21558. /**
  21559. * Is vertex program allowed to be empty?
  21560. */
  21561. allowEmptyVertexProgram: boolean;
  21562. /** Creates a new shared data */
  21563. constructor();
  21564. /**
  21565. * Emits console errors and exceptions if there is a failing check
  21566. */
  21567. emitErrors(): void;
  21568. }
  21569. }
  21570. declare module BABYLON {
  21571. /**
  21572. * Class used to store node based material build state
  21573. */
  21574. export class NodeMaterialBuildState {
  21575. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21576. supportUniformBuffers: boolean;
  21577. /**
  21578. * Gets the list of emitted attributes
  21579. */
  21580. attributes: string[];
  21581. /**
  21582. * Gets the list of emitted uniforms
  21583. */
  21584. uniforms: string[];
  21585. /**
  21586. * Gets the list of emitted constants
  21587. */
  21588. constants: string[];
  21589. /**
  21590. * Gets the list of emitted samplers
  21591. */
  21592. samplers: string[];
  21593. /**
  21594. * Gets the list of emitted functions
  21595. */
  21596. functions: {
  21597. [key: string]: string;
  21598. };
  21599. /**
  21600. * Gets the list of emitted extensions
  21601. */
  21602. extensions: {
  21603. [key: string]: string;
  21604. };
  21605. /**
  21606. * Gets the target of the compilation state
  21607. */
  21608. target: NodeMaterialBlockTargets;
  21609. /**
  21610. * Gets the list of emitted counters
  21611. */
  21612. counters: {
  21613. [key: string]: number;
  21614. };
  21615. /**
  21616. * Shared data between multiple NodeMaterialBuildState instances
  21617. */
  21618. sharedData: NodeMaterialBuildStateSharedData;
  21619. /** @hidden */
  21620. _vertexState: NodeMaterialBuildState;
  21621. /** @hidden */
  21622. _attributeDeclaration: string;
  21623. /** @hidden */
  21624. _uniformDeclaration: string;
  21625. /** @hidden */
  21626. _constantDeclaration: string;
  21627. /** @hidden */
  21628. _samplerDeclaration: string;
  21629. /** @hidden */
  21630. _varyingTransfer: string;
  21631. /** @hidden */
  21632. _injectAtEnd: string;
  21633. private _repeatableContentAnchorIndex;
  21634. /** @hidden */
  21635. _builtCompilationString: string;
  21636. /**
  21637. * Gets the emitted compilation strings
  21638. */
  21639. compilationString: string;
  21640. /**
  21641. * Finalize the compilation strings
  21642. * @param state defines the current compilation state
  21643. */
  21644. finalize(state: NodeMaterialBuildState): void;
  21645. /** @hidden */
  21646. get _repeatableContentAnchor(): string;
  21647. /** @hidden */
  21648. _getFreeVariableName(prefix: string): string;
  21649. /** @hidden */
  21650. _getFreeDefineName(prefix: string): string;
  21651. /** @hidden */
  21652. _excludeVariableName(name: string): void;
  21653. /** @hidden */
  21654. _emit2DSampler(name: string): void;
  21655. /** @hidden */
  21656. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21657. /** @hidden */
  21658. _emitExtension(name: string, extension: string, define?: string): void;
  21659. /** @hidden */
  21660. _emitFunction(name: string, code: string, comments: string): void;
  21661. /** @hidden */
  21662. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21663. replaceStrings?: {
  21664. search: RegExp;
  21665. replace: string;
  21666. }[];
  21667. repeatKey?: string;
  21668. }): string;
  21669. /** @hidden */
  21670. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21671. repeatKey?: string;
  21672. removeAttributes?: boolean;
  21673. removeUniforms?: boolean;
  21674. removeVaryings?: boolean;
  21675. removeIfDef?: boolean;
  21676. replaceStrings?: {
  21677. search: RegExp;
  21678. replace: string;
  21679. }[];
  21680. }, storeKey?: string): void;
  21681. /** @hidden */
  21682. _registerTempVariable(name: string): boolean;
  21683. /** @hidden */
  21684. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21685. /** @hidden */
  21686. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21687. /** @hidden */
  21688. _emitFloat(value: number): string;
  21689. }
  21690. }
  21691. declare module BABYLON {
  21692. /**
  21693. * Helper class used to generate session unique ID
  21694. */
  21695. export class UniqueIdGenerator {
  21696. private static _UniqueIdCounter;
  21697. /**
  21698. * Gets an unique (relatively to the current scene) Id
  21699. */
  21700. static get UniqueId(): number;
  21701. }
  21702. }
  21703. declare module BABYLON {
  21704. /**
  21705. * Defines a block that can be used inside a node based material
  21706. */
  21707. export class NodeMaterialBlock {
  21708. private _buildId;
  21709. private _buildTarget;
  21710. private _target;
  21711. private _isFinalMerger;
  21712. private _isInput;
  21713. private _name;
  21714. protected _isUnique: boolean;
  21715. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21716. inputsAreExclusive: boolean;
  21717. /** @hidden */
  21718. _codeVariableName: string;
  21719. /** @hidden */
  21720. _inputs: NodeMaterialConnectionPoint[];
  21721. /** @hidden */
  21722. _outputs: NodeMaterialConnectionPoint[];
  21723. /** @hidden */
  21724. _preparationId: number;
  21725. /**
  21726. * Gets the name of the block
  21727. */
  21728. get name(): string;
  21729. /**
  21730. * Sets the name of the block. Will check if the name is valid.
  21731. */
  21732. set name(newName: string);
  21733. /**
  21734. * Gets or sets the unique id of the node
  21735. */
  21736. uniqueId: number;
  21737. /**
  21738. * Gets or sets the comments associated with this block
  21739. */
  21740. comments: string;
  21741. /**
  21742. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21743. */
  21744. get isUnique(): boolean;
  21745. /**
  21746. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21747. */
  21748. get isFinalMerger(): boolean;
  21749. /**
  21750. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21751. */
  21752. get isInput(): boolean;
  21753. /**
  21754. * Gets or sets the build Id
  21755. */
  21756. get buildId(): number;
  21757. set buildId(value: number);
  21758. /**
  21759. * Gets or sets the target of the block
  21760. */
  21761. get target(): NodeMaterialBlockTargets;
  21762. set target(value: NodeMaterialBlockTargets);
  21763. /**
  21764. * Gets the list of input points
  21765. */
  21766. get inputs(): NodeMaterialConnectionPoint[];
  21767. /** Gets the list of output points */
  21768. get outputs(): NodeMaterialConnectionPoint[];
  21769. /**
  21770. * Find an input by its name
  21771. * @param name defines the name of the input to look for
  21772. * @returns the input or null if not found
  21773. */
  21774. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21775. /**
  21776. * Find an output by its name
  21777. * @param name defines the name of the outputto look for
  21778. * @returns the output or null if not found
  21779. */
  21780. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21781. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21782. visibleInInspector: boolean;
  21783. /**
  21784. * Creates a new NodeMaterialBlock
  21785. * @param name defines the block name
  21786. * @param target defines the target of that block (Vertex by default)
  21787. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21788. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21789. */
  21790. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21791. /**
  21792. * Initialize the block and prepare the context for build
  21793. * @param state defines the state that will be used for the build
  21794. */
  21795. initialize(state: NodeMaterialBuildState): void;
  21796. /**
  21797. * Bind data to effect. Will only be called for blocks with isBindable === true
  21798. * @param effect defines the effect to bind data to
  21799. * @param nodeMaterial defines the hosting NodeMaterial
  21800. * @param mesh defines the mesh that will be rendered
  21801. * @param subMesh defines the submesh that will be rendered
  21802. */
  21803. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21804. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21805. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21806. protected _writeFloat(value: number): string;
  21807. /**
  21808. * Gets the current class name e.g. "NodeMaterialBlock"
  21809. * @returns the class name
  21810. */
  21811. getClassName(): string;
  21812. /**
  21813. * Register a new input. Must be called inside a block constructor
  21814. * @param name defines the connection point name
  21815. * @param type defines the connection point type
  21816. * @param isOptional defines a boolean indicating that this input can be omitted
  21817. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21818. * @param point an already created connection point. If not provided, create a new one
  21819. * @returns the current block
  21820. */
  21821. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21822. /**
  21823. * Register a new output. Must be called inside a block constructor
  21824. * @param name defines the connection point name
  21825. * @param type defines the connection point type
  21826. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21827. * @param point an already created connection point. If not provided, create a new one
  21828. * @returns the current block
  21829. */
  21830. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21831. /**
  21832. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21833. * @param forOutput defines an optional connection point to check compatibility with
  21834. * @returns the first available input or null
  21835. */
  21836. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21837. /**
  21838. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21839. * @param forBlock defines an optional block to check compatibility with
  21840. * @returns the first available input or null
  21841. */
  21842. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21843. /**
  21844. * Gets the sibling of the given output
  21845. * @param current defines the current output
  21846. * @returns the next output in the list or null
  21847. */
  21848. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21849. /**
  21850. * Connect current block with another block
  21851. * @param other defines the block to connect with
  21852. * @param options define the various options to help pick the right connections
  21853. * @returns the current block
  21854. */
  21855. connectTo(other: NodeMaterialBlock, options?: {
  21856. input?: string;
  21857. output?: string;
  21858. outputSwizzle?: string;
  21859. }): this | undefined;
  21860. protected _buildBlock(state: NodeMaterialBuildState): void;
  21861. /**
  21862. * Add uniforms, samplers and uniform buffers at compilation time
  21863. * @param state defines the state to update
  21864. * @param nodeMaterial defines the node material requesting the update
  21865. * @param defines defines the material defines to update
  21866. * @param uniformBuffers defines the list of uniform buffer names
  21867. */
  21868. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21869. /**
  21870. * Add potential fallbacks if shader compilation fails
  21871. * @param mesh defines the mesh to be rendered
  21872. * @param fallbacks defines the current prioritized list of fallbacks
  21873. */
  21874. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21875. /**
  21876. * Initialize defines for shader compilation
  21877. * @param mesh defines the mesh to be rendered
  21878. * @param nodeMaterial defines the node material requesting the update
  21879. * @param defines defines the material defines to update
  21880. * @param useInstances specifies that instances should be used
  21881. */
  21882. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21883. /**
  21884. * Update defines for shader compilation
  21885. * @param mesh defines the mesh to be rendered
  21886. * @param nodeMaterial defines the node material requesting the update
  21887. * @param defines defines the material defines to update
  21888. * @param useInstances specifies that instances should be used
  21889. * @param subMesh defines which submesh to render
  21890. */
  21891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21892. /**
  21893. * Lets the block try to connect some inputs automatically
  21894. * @param material defines the hosting NodeMaterial
  21895. */
  21896. autoConfigure(material: NodeMaterial): void;
  21897. /**
  21898. * Function called when a block is declared as repeatable content generator
  21899. * @param vertexShaderState defines the current compilation state for the vertex shader
  21900. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21901. * @param mesh defines the mesh to be rendered
  21902. * @param defines defines the material defines to update
  21903. */
  21904. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21905. /**
  21906. * Checks if the block is ready
  21907. * @param mesh defines the mesh to be rendered
  21908. * @param nodeMaterial defines the node material requesting the update
  21909. * @param defines defines the material defines to update
  21910. * @param useInstances specifies that instances should be used
  21911. * @returns true if the block is ready
  21912. */
  21913. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21914. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21915. private _processBuild;
  21916. /**
  21917. * Validates the new name for the block node.
  21918. * @param newName the new name to be given to the node.
  21919. * @returns false if the name is a reserve word, else true.
  21920. */
  21921. validateBlockName(newName: string): boolean;
  21922. /**
  21923. * Compile the current node and generate the shader code
  21924. * @param state defines the current compilation state (uniforms, samplers, current string)
  21925. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21926. * @returns true if already built
  21927. */
  21928. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21929. protected _inputRename(name: string): string;
  21930. protected _outputRename(name: string): string;
  21931. protected _dumpPropertiesCode(): string;
  21932. /** @hidden */
  21933. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21934. /** @hidden */
  21935. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21936. /**
  21937. * Clone the current block to a new identical block
  21938. * @param scene defines the hosting scene
  21939. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21940. * @returns a copy of the current block
  21941. */
  21942. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21943. /**
  21944. * Serializes this block in a JSON representation
  21945. * @returns the serialized block object
  21946. */
  21947. serialize(): any;
  21948. /** @hidden */
  21949. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21950. private _deserializePortDisplayNamesAndExposedOnFrame;
  21951. /**
  21952. * Release resources
  21953. */
  21954. dispose(): void;
  21955. }
  21956. }
  21957. declare module BABYLON {
  21958. /**
  21959. * Base class of materials working in push mode in babylon JS
  21960. * @hidden
  21961. */
  21962. export class PushMaterial extends Material {
  21963. protected _activeEffect: Effect;
  21964. protected _normalMatrix: Matrix;
  21965. constructor(name: string, scene: Scene);
  21966. getEffect(): Effect;
  21967. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21968. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21969. /**
  21970. * Binds the given world matrix to the active effect
  21971. *
  21972. * @param world the matrix to bind
  21973. */
  21974. bindOnlyWorldMatrix(world: Matrix): void;
  21975. /**
  21976. * Binds the given normal matrix to the active effect
  21977. *
  21978. * @param normalMatrix the matrix to bind
  21979. */
  21980. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21981. bind(world: Matrix, mesh?: Mesh): void;
  21982. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21983. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21984. }
  21985. }
  21986. declare module BABYLON {
  21987. /**
  21988. * Root class for all node material optimizers
  21989. */
  21990. export class NodeMaterialOptimizer {
  21991. /**
  21992. * Function used to optimize a NodeMaterial graph
  21993. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21994. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21995. */
  21996. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21997. }
  21998. }
  21999. declare module BABYLON {
  22000. /**
  22001. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22002. */
  22003. export class TransformBlock extends NodeMaterialBlock {
  22004. /**
  22005. * Defines the value to use to complement W value to transform it to a Vector4
  22006. */
  22007. complementW: number;
  22008. /**
  22009. * Defines the value to use to complement z value to transform it to a Vector4
  22010. */
  22011. complementZ: number;
  22012. /**
  22013. * Creates a new TransformBlock
  22014. * @param name defines the block name
  22015. */
  22016. constructor(name: string);
  22017. /**
  22018. * Gets the current class name
  22019. * @returns the class name
  22020. */
  22021. getClassName(): string;
  22022. /**
  22023. * Gets the vector input
  22024. */
  22025. get vector(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Gets the output component
  22028. */
  22029. get output(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the xyz output component
  22032. */
  22033. get xyz(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Gets the matrix transform input
  22036. */
  22037. get transform(): NodeMaterialConnectionPoint;
  22038. protected _buildBlock(state: NodeMaterialBuildState): this;
  22039. /**
  22040. * Update defines for shader compilation
  22041. * @param mesh defines the mesh to be rendered
  22042. * @param nodeMaterial defines the node material requesting the update
  22043. * @param defines defines the material defines to update
  22044. * @param useInstances specifies that instances should be used
  22045. * @param subMesh defines which submesh to render
  22046. */
  22047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22048. serialize(): any;
  22049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22050. protected _dumpPropertiesCode(): string;
  22051. }
  22052. }
  22053. declare module BABYLON {
  22054. /**
  22055. * Block used to output the vertex position
  22056. */
  22057. export class VertexOutputBlock extends NodeMaterialBlock {
  22058. /**
  22059. * Creates a new VertexOutputBlock
  22060. * @param name defines the block name
  22061. */
  22062. constructor(name: string);
  22063. /**
  22064. * Gets the current class name
  22065. * @returns the class name
  22066. */
  22067. getClassName(): string;
  22068. /**
  22069. * Gets the vector input component
  22070. */
  22071. get vector(): NodeMaterialConnectionPoint;
  22072. protected _buildBlock(state: NodeMaterialBuildState): this;
  22073. }
  22074. }
  22075. declare module BABYLON {
  22076. /**
  22077. * Block used to output the final color
  22078. */
  22079. export class FragmentOutputBlock extends NodeMaterialBlock {
  22080. /**
  22081. * Create a new FragmentOutputBlock
  22082. * @param name defines the block name
  22083. */
  22084. constructor(name: string);
  22085. /**
  22086. * Gets the current class name
  22087. * @returns the class name
  22088. */
  22089. getClassName(): string;
  22090. /**
  22091. * Gets the rgba input component
  22092. */
  22093. get rgba(): NodeMaterialConnectionPoint;
  22094. /**
  22095. * Gets the rgb input component
  22096. */
  22097. get rgb(): NodeMaterialConnectionPoint;
  22098. /**
  22099. * Gets the a input component
  22100. */
  22101. get a(): NodeMaterialConnectionPoint;
  22102. protected _buildBlock(state: NodeMaterialBuildState): this;
  22103. }
  22104. }
  22105. declare module BABYLON {
  22106. /**
  22107. * Block used for the particle ramp gradient section
  22108. */
  22109. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22110. /**
  22111. * Create a new ParticleRampGradientBlock
  22112. * @param name defines the block name
  22113. */
  22114. constructor(name: string);
  22115. /**
  22116. * Gets the current class name
  22117. * @returns the class name
  22118. */
  22119. getClassName(): string;
  22120. /**
  22121. * Gets the color input component
  22122. */
  22123. get color(): NodeMaterialConnectionPoint;
  22124. /**
  22125. * Gets the rampColor output component
  22126. */
  22127. get rampColor(): NodeMaterialConnectionPoint;
  22128. /**
  22129. * Initialize the block and prepare the context for build
  22130. * @param state defines the state that will be used for the build
  22131. */
  22132. initialize(state: NodeMaterialBuildState): void;
  22133. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22134. }
  22135. }
  22136. declare module BABYLON {
  22137. /**
  22138. * Block used for the particle blend multiply section
  22139. */
  22140. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22141. /**
  22142. * Create a new ParticleBlendMultiplyBlock
  22143. * @param name defines the block name
  22144. */
  22145. constructor(name: string);
  22146. /**
  22147. * Gets the current class name
  22148. * @returns the class name
  22149. */
  22150. getClassName(): string;
  22151. /**
  22152. * Gets the color input component
  22153. */
  22154. get color(): NodeMaterialConnectionPoint;
  22155. /**
  22156. * Gets the alphaTexture input component
  22157. */
  22158. get alphaTexture(): NodeMaterialConnectionPoint;
  22159. /**
  22160. * Gets the alphaColor input component
  22161. */
  22162. get alphaColor(): NodeMaterialConnectionPoint;
  22163. /**
  22164. * Gets the blendColor output component
  22165. */
  22166. get blendColor(): NodeMaterialConnectionPoint;
  22167. /**
  22168. * Initialize the block and prepare the context for build
  22169. * @param state defines the state that will be used for the build
  22170. */
  22171. initialize(state: NodeMaterialBuildState): void;
  22172. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22173. }
  22174. }
  22175. declare module BABYLON {
  22176. /**
  22177. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22178. */
  22179. export class VectorMergerBlock extends NodeMaterialBlock {
  22180. /**
  22181. * Create a new VectorMergerBlock
  22182. * @param name defines the block name
  22183. */
  22184. constructor(name: string);
  22185. /**
  22186. * Gets the current class name
  22187. * @returns the class name
  22188. */
  22189. getClassName(): string;
  22190. /**
  22191. * Gets the xyz component (input)
  22192. */
  22193. get xyzIn(): NodeMaterialConnectionPoint;
  22194. /**
  22195. * Gets the xy component (input)
  22196. */
  22197. get xyIn(): NodeMaterialConnectionPoint;
  22198. /**
  22199. * Gets the x component (input)
  22200. */
  22201. get x(): NodeMaterialConnectionPoint;
  22202. /**
  22203. * Gets the y component (input)
  22204. */
  22205. get y(): NodeMaterialConnectionPoint;
  22206. /**
  22207. * Gets the z component (input)
  22208. */
  22209. get z(): NodeMaterialConnectionPoint;
  22210. /**
  22211. * Gets the w component (input)
  22212. */
  22213. get w(): NodeMaterialConnectionPoint;
  22214. /**
  22215. * Gets the xyzw component (output)
  22216. */
  22217. get xyzw(): NodeMaterialConnectionPoint;
  22218. /**
  22219. * Gets the xyz component (output)
  22220. */
  22221. get xyzOut(): NodeMaterialConnectionPoint;
  22222. /**
  22223. * Gets the xy component (output)
  22224. */
  22225. get xyOut(): NodeMaterialConnectionPoint;
  22226. /**
  22227. * Gets the xy component (output)
  22228. * @deprecated Please use xyOut instead.
  22229. */
  22230. get xy(): NodeMaterialConnectionPoint;
  22231. /**
  22232. * Gets the xyz component (output)
  22233. * @deprecated Please use xyzOut instead.
  22234. */
  22235. get xyz(): NodeMaterialConnectionPoint;
  22236. protected _buildBlock(state: NodeMaterialBuildState): this;
  22237. }
  22238. }
  22239. declare module BABYLON {
  22240. /**
  22241. * Block used to remap a float from a range to a new one
  22242. */
  22243. export class RemapBlock extends NodeMaterialBlock {
  22244. /**
  22245. * Gets or sets the source range
  22246. */
  22247. sourceRange: Vector2;
  22248. /**
  22249. * Gets or sets the target range
  22250. */
  22251. targetRange: Vector2;
  22252. /**
  22253. * Creates a new RemapBlock
  22254. * @param name defines the block name
  22255. */
  22256. constructor(name: string);
  22257. /**
  22258. * Gets the current class name
  22259. * @returns the class name
  22260. */
  22261. getClassName(): string;
  22262. /**
  22263. * Gets the input component
  22264. */
  22265. get input(): NodeMaterialConnectionPoint;
  22266. /**
  22267. * Gets the source min input component
  22268. */
  22269. get sourceMin(): NodeMaterialConnectionPoint;
  22270. /**
  22271. * Gets the source max input component
  22272. */
  22273. get sourceMax(): NodeMaterialConnectionPoint;
  22274. /**
  22275. * Gets the target min input component
  22276. */
  22277. get targetMin(): NodeMaterialConnectionPoint;
  22278. /**
  22279. * Gets the target max input component
  22280. */
  22281. get targetMax(): NodeMaterialConnectionPoint;
  22282. /**
  22283. * Gets the output component
  22284. */
  22285. get output(): NodeMaterialConnectionPoint;
  22286. protected _buildBlock(state: NodeMaterialBuildState): this;
  22287. protected _dumpPropertiesCode(): string;
  22288. serialize(): any;
  22289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22290. }
  22291. }
  22292. declare module BABYLON {
  22293. /**
  22294. * Block used to multiply 2 values
  22295. */
  22296. export class MultiplyBlock extends NodeMaterialBlock {
  22297. /**
  22298. * Creates a new MultiplyBlock
  22299. * @param name defines the block name
  22300. */
  22301. constructor(name: string);
  22302. /**
  22303. * Gets the current class name
  22304. * @returns the class name
  22305. */
  22306. getClassName(): string;
  22307. /**
  22308. * Gets the left operand input component
  22309. */
  22310. get left(): NodeMaterialConnectionPoint;
  22311. /**
  22312. * Gets the right operand input component
  22313. */
  22314. get right(): NodeMaterialConnectionPoint;
  22315. /**
  22316. * Gets the output component
  22317. */
  22318. get output(): NodeMaterialConnectionPoint;
  22319. protected _buildBlock(state: NodeMaterialBuildState): this;
  22320. }
  22321. }
  22322. declare module BABYLON {
  22323. /**
  22324. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22325. */
  22326. export class ColorSplitterBlock extends NodeMaterialBlock {
  22327. /**
  22328. * Create a new ColorSplitterBlock
  22329. * @param name defines the block name
  22330. */
  22331. constructor(name: string);
  22332. /**
  22333. * Gets the current class name
  22334. * @returns the class name
  22335. */
  22336. getClassName(): string;
  22337. /**
  22338. * Gets the rgba component (input)
  22339. */
  22340. get rgba(): NodeMaterialConnectionPoint;
  22341. /**
  22342. * Gets the rgb component (input)
  22343. */
  22344. get rgbIn(): NodeMaterialConnectionPoint;
  22345. /**
  22346. * Gets the rgb component (output)
  22347. */
  22348. get rgbOut(): NodeMaterialConnectionPoint;
  22349. /**
  22350. * Gets the r component (output)
  22351. */
  22352. get r(): NodeMaterialConnectionPoint;
  22353. /**
  22354. * Gets the g component (output)
  22355. */
  22356. get g(): NodeMaterialConnectionPoint;
  22357. /**
  22358. * Gets the b component (output)
  22359. */
  22360. get b(): NodeMaterialConnectionPoint;
  22361. /**
  22362. * Gets the a component (output)
  22363. */
  22364. get a(): NodeMaterialConnectionPoint;
  22365. protected _inputRename(name: string): string;
  22366. protected _outputRename(name: string): string;
  22367. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22368. }
  22369. }
  22370. declare module BABYLON {
  22371. /**
  22372. * Operations supported by the Trigonometry block
  22373. */
  22374. export enum TrigonometryBlockOperations {
  22375. /** Cos */
  22376. Cos = 0,
  22377. /** Sin */
  22378. Sin = 1,
  22379. /** Abs */
  22380. Abs = 2,
  22381. /** Exp */
  22382. Exp = 3,
  22383. /** Exp2 */
  22384. Exp2 = 4,
  22385. /** Round */
  22386. Round = 5,
  22387. /** Floor */
  22388. Floor = 6,
  22389. /** Ceiling */
  22390. Ceiling = 7,
  22391. /** Square root */
  22392. Sqrt = 8,
  22393. /** Log */
  22394. Log = 9,
  22395. /** Tangent */
  22396. Tan = 10,
  22397. /** Arc tangent */
  22398. ArcTan = 11,
  22399. /** Arc cosinus */
  22400. ArcCos = 12,
  22401. /** Arc sinus */
  22402. ArcSin = 13,
  22403. /** Fraction */
  22404. Fract = 14,
  22405. /** Sign */
  22406. Sign = 15,
  22407. /** To radians (from degrees) */
  22408. Radians = 16,
  22409. /** To degrees (from radians) */
  22410. Degrees = 17
  22411. }
  22412. /**
  22413. * Block used to apply trigonometry operation to floats
  22414. */
  22415. export class TrigonometryBlock extends NodeMaterialBlock {
  22416. /**
  22417. * Gets or sets the operation applied by the block
  22418. */
  22419. operation: TrigonometryBlockOperations;
  22420. /**
  22421. * Creates a new TrigonometryBlock
  22422. * @param name defines the block name
  22423. */
  22424. constructor(name: string);
  22425. /**
  22426. * Gets the current class name
  22427. * @returns the class name
  22428. */
  22429. getClassName(): string;
  22430. /**
  22431. * Gets the input component
  22432. */
  22433. get input(): NodeMaterialConnectionPoint;
  22434. /**
  22435. * Gets the output component
  22436. */
  22437. get output(): NodeMaterialConnectionPoint;
  22438. protected _buildBlock(state: NodeMaterialBuildState): this;
  22439. serialize(): any;
  22440. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22441. protected _dumpPropertiesCode(): string;
  22442. }
  22443. }
  22444. declare module BABYLON {
  22445. /**
  22446. * Interface used to configure the node material editor
  22447. */
  22448. export interface INodeMaterialEditorOptions {
  22449. /** Define the URl to load node editor script */
  22450. editorURL?: string;
  22451. }
  22452. /** @hidden */
  22453. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22454. NORMAL: boolean;
  22455. TANGENT: boolean;
  22456. UV1: boolean;
  22457. /** BONES */
  22458. NUM_BONE_INFLUENCERS: number;
  22459. BonesPerMesh: number;
  22460. BONETEXTURE: boolean;
  22461. /** MORPH TARGETS */
  22462. MORPHTARGETS: boolean;
  22463. MORPHTARGETS_NORMAL: boolean;
  22464. MORPHTARGETS_TANGENT: boolean;
  22465. MORPHTARGETS_UV: boolean;
  22466. NUM_MORPH_INFLUENCERS: number;
  22467. /** IMAGE PROCESSING */
  22468. IMAGEPROCESSING: boolean;
  22469. VIGNETTE: boolean;
  22470. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22471. VIGNETTEBLENDMODEOPAQUE: boolean;
  22472. TONEMAPPING: boolean;
  22473. TONEMAPPING_ACES: boolean;
  22474. CONTRAST: boolean;
  22475. EXPOSURE: boolean;
  22476. COLORCURVES: boolean;
  22477. COLORGRADING: boolean;
  22478. COLORGRADING3D: boolean;
  22479. SAMPLER3DGREENDEPTH: boolean;
  22480. SAMPLER3DBGRMAP: boolean;
  22481. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22482. /** MISC. */
  22483. BUMPDIRECTUV: number;
  22484. constructor();
  22485. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22486. }
  22487. /**
  22488. * Class used to configure NodeMaterial
  22489. */
  22490. export interface INodeMaterialOptions {
  22491. /**
  22492. * Defines if blocks should emit comments
  22493. */
  22494. emitComments: boolean;
  22495. }
  22496. /**
  22497. * Class used to create a node based material built by assembling shader blocks
  22498. */
  22499. export class NodeMaterial extends PushMaterial {
  22500. private static _BuildIdGenerator;
  22501. private _options;
  22502. private _vertexCompilationState;
  22503. private _fragmentCompilationState;
  22504. private _sharedData;
  22505. private _buildId;
  22506. private _buildWasSuccessful;
  22507. private _cachedWorldViewMatrix;
  22508. private _cachedWorldViewProjectionMatrix;
  22509. private _optimizers;
  22510. private _animationFrame;
  22511. /** Define the Url to load node editor script */
  22512. static EditorURL: string;
  22513. /** Define the Url to load snippets */
  22514. static SnippetUrl: string;
  22515. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22516. static IgnoreTexturesAtLoadTime: boolean;
  22517. private BJSNODEMATERIALEDITOR;
  22518. /** Get the inspector from bundle or global */
  22519. private _getGlobalNodeMaterialEditor;
  22520. /**
  22521. * Snippet ID if the material was created from the snippet server
  22522. */
  22523. snippetId: string;
  22524. /**
  22525. * Gets or sets data used by visual editor
  22526. * @see https://nme.babylonjs.com
  22527. */
  22528. editorData: any;
  22529. /**
  22530. * 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)
  22531. */
  22532. ignoreAlpha: boolean;
  22533. /**
  22534. * Defines the maximum number of lights that can be used in the material
  22535. */
  22536. maxSimultaneousLights: number;
  22537. /**
  22538. * Observable raised when the material is built
  22539. */
  22540. onBuildObservable: Observable<NodeMaterial>;
  22541. /**
  22542. * Gets or sets the root nodes of the material vertex shader
  22543. */
  22544. _vertexOutputNodes: NodeMaterialBlock[];
  22545. /**
  22546. * Gets or sets the root nodes of the material fragment (pixel) shader
  22547. */
  22548. _fragmentOutputNodes: NodeMaterialBlock[];
  22549. /** Gets or sets options to control the node material overall behavior */
  22550. get options(): INodeMaterialOptions;
  22551. set options(options: INodeMaterialOptions);
  22552. /**
  22553. * Default configuration related to image processing available in the standard Material.
  22554. */
  22555. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22556. /**
  22557. * Gets the image processing configuration used either in this material.
  22558. */
  22559. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22560. /**
  22561. * Sets the Default image processing configuration used either in the this material.
  22562. *
  22563. * If sets to null, the scene one is in use.
  22564. */
  22565. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22566. /**
  22567. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22568. */
  22569. attachedBlocks: NodeMaterialBlock[];
  22570. /**
  22571. * Specifies the mode of the node material
  22572. * @hidden
  22573. */
  22574. _mode: NodeMaterialModes;
  22575. /**
  22576. * Gets the mode property
  22577. */
  22578. get mode(): NodeMaterialModes;
  22579. /**
  22580. * Create a new node based material
  22581. * @param name defines the material name
  22582. * @param scene defines the hosting scene
  22583. * @param options defines creation option
  22584. */
  22585. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22586. /**
  22587. * Gets the current class name of the material e.g. "NodeMaterial"
  22588. * @returns the class name
  22589. */
  22590. getClassName(): string;
  22591. /**
  22592. * Keep track of the image processing observer to allow dispose and replace.
  22593. */
  22594. private _imageProcessingObserver;
  22595. /**
  22596. * Attaches a new image processing configuration to the Standard Material.
  22597. * @param configuration
  22598. */
  22599. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22600. /**
  22601. * Get a block by its name
  22602. * @param name defines the name of the block to retrieve
  22603. * @returns the required block or null if not found
  22604. */
  22605. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22606. /**
  22607. * Get a block by its name
  22608. * @param predicate defines the predicate used to find the good candidate
  22609. * @returns the required block or null if not found
  22610. */
  22611. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22612. /**
  22613. * Get an input block by its name
  22614. * @param predicate defines the predicate used to find the good candidate
  22615. * @returns the required input block or null if not found
  22616. */
  22617. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22618. /**
  22619. * Gets the list of input blocks attached to this material
  22620. * @returns an array of InputBlocks
  22621. */
  22622. getInputBlocks(): InputBlock[];
  22623. /**
  22624. * Adds a new optimizer to the list of optimizers
  22625. * @param optimizer defines the optimizers to add
  22626. * @returns the current material
  22627. */
  22628. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22629. /**
  22630. * Remove an optimizer from the list of optimizers
  22631. * @param optimizer defines the optimizers to remove
  22632. * @returns the current material
  22633. */
  22634. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22635. /**
  22636. * Add a new block to the list of output nodes
  22637. * @param node defines the node to add
  22638. * @returns the current material
  22639. */
  22640. addOutputNode(node: NodeMaterialBlock): this;
  22641. /**
  22642. * Remove a block from the list of root nodes
  22643. * @param node defines the node to remove
  22644. * @returns the current material
  22645. */
  22646. removeOutputNode(node: NodeMaterialBlock): this;
  22647. private _addVertexOutputNode;
  22648. private _removeVertexOutputNode;
  22649. private _addFragmentOutputNode;
  22650. private _removeFragmentOutputNode;
  22651. /**
  22652. * Specifies if the material will require alpha blending
  22653. * @returns a boolean specifying if alpha blending is needed
  22654. */
  22655. needAlphaBlending(): boolean;
  22656. /**
  22657. * Specifies if this material should be rendered in alpha test mode
  22658. * @returns a boolean specifying if an alpha test is needed.
  22659. */
  22660. needAlphaTesting(): boolean;
  22661. private _initializeBlock;
  22662. private _resetDualBlocks;
  22663. /**
  22664. * Remove a block from the current node material
  22665. * @param block defines the block to remove
  22666. */
  22667. removeBlock(block: NodeMaterialBlock): void;
  22668. /**
  22669. * Build the material and generates the inner effect
  22670. * @param verbose defines if the build should log activity
  22671. */
  22672. build(verbose?: boolean): void;
  22673. /**
  22674. * Runs an otpimization phase to try to improve the shader code
  22675. */
  22676. optimize(): void;
  22677. private _prepareDefinesForAttributes;
  22678. /**
  22679. * Create a post process from the material
  22680. * @param camera The camera to apply the render pass to.
  22681. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22683. * @param engine The engine which the post process will be applied. (default: current engine)
  22684. * @param reusable If the post process can be reused on the same frame. (default: false)
  22685. * @param textureType Type of textures used when performing the post process. (default: 0)
  22686. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22687. * @returns the post process created
  22688. */
  22689. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22690. /**
  22691. * Create the post process effect from the material
  22692. * @param postProcess The post process to create the effect for
  22693. */
  22694. createEffectForPostProcess(postProcess: PostProcess): void;
  22695. private _createEffectForPostProcess;
  22696. /**
  22697. * Create a new procedural texture based on this node material
  22698. * @param size defines the size of the texture
  22699. * @param scene defines the hosting scene
  22700. * @returns the new procedural texture attached to this node material
  22701. */
  22702. createProceduralTexture(size: number | {
  22703. width: number;
  22704. height: number;
  22705. layers?: number;
  22706. }, scene: Scene): Nullable<ProceduralTexture>;
  22707. private _createEffectForParticles;
  22708. private _checkInternals;
  22709. /**
  22710. * Create the effect to be used as the custom effect for a particle system
  22711. * @param particleSystem Particle system to create the effect for
  22712. * @param onCompiled defines a function to call when the effect creation is successful
  22713. * @param onError defines a function to call when the effect creation has failed
  22714. */
  22715. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22716. private _processDefines;
  22717. /**
  22718. * Get if the submesh is ready to be used and all its information available.
  22719. * Child classes can use it to update shaders
  22720. * @param mesh defines the mesh to check
  22721. * @param subMesh defines which submesh to check
  22722. * @param useInstances specifies that instances should be used
  22723. * @returns a boolean indicating that the submesh is ready or not
  22724. */
  22725. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22726. /**
  22727. * Get a string representing the shaders built by the current node graph
  22728. */
  22729. get compiledShaders(): string;
  22730. /**
  22731. * Binds the world matrix to the material
  22732. * @param world defines the world transformation matrix
  22733. */
  22734. bindOnlyWorldMatrix(world: Matrix): void;
  22735. /**
  22736. * Binds the submesh to this material by preparing the effect and shader to draw
  22737. * @param world defines the world transformation matrix
  22738. * @param mesh defines the mesh containing the submesh
  22739. * @param subMesh defines the submesh to bind the material to
  22740. */
  22741. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22742. /**
  22743. * Gets the active textures from the material
  22744. * @returns an array of textures
  22745. */
  22746. getActiveTextures(): BaseTexture[];
  22747. /**
  22748. * Gets the list of texture blocks
  22749. * @returns an array of texture blocks
  22750. */
  22751. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22752. /**
  22753. * Specifies if the material uses a texture
  22754. * @param texture defines the texture to check against the material
  22755. * @returns a boolean specifying if the material uses the texture
  22756. */
  22757. hasTexture(texture: BaseTexture): boolean;
  22758. /**
  22759. * Disposes the material
  22760. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22761. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22762. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22763. */
  22764. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22765. /** Creates the node editor window. */
  22766. private _createNodeEditor;
  22767. /**
  22768. * Launch the node material editor
  22769. * @param config Define the configuration of the editor
  22770. * @return a promise fulfilled when the node editor is visible
  22771. */
  22772. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22773. /**
  22774. * Clear the current material
  22775. */
  22776. clear(): void;
  22777. /**
  22778. * Clear the current material and set it to a default state
  22779. */
  22780. setToDefault(): void;
  22781. /**
  22782. * Clear the current material and set it to a default state for post process
  22783. */
  22784. setToDefaultPostProcess(): void;
  22785. /**
  22786. * Clear the current material and set it to a default state for procedural texture
  22787. */
  22788. setToDefaultProceduralTexture(): void;
  22789. /**
  22790. * Clear the current material and set it to a default state for particle
  22791. */
  22792. setToDefaultParticle(): void;
  22793. /**
  22794. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22795. * @param url defines the url to load from
  22796. * @returns a promise that will fullfil when the material is fully loaded
  22797. */
  22798. loadAsync(url: string): Promise<void>;
  22799. private _gatherBlocks;
  22800. /**
  22801. * Generate a string containing the code declaration required to create an equivalent of this material
  22802. * @returns a string
  22803. */
  22804. generateCode(): string;
  22805. /**
  22806. * Serializes this material in a JSON representation
  22807. * @returns the serialized material object
  22808. */
  22809. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22810. private _restoreConnections;
  22811. /**
  22812. * Clear the current graph and load a new one from a serialization object
  22813. * @param source defines the JSON representation of the material
  22814. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22815. * @param merge defines whether or not the source must be merged or replace the current content
  22816. */
  22817. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22818. /**
  22819. * Makes a duplicate of the current material.
  22820. * @param name - name to use for the new material.
  22821. */
  22822. clone(name: string): NodeMaterial;
  22823. /**
  22824. * Creates a node material from parsed material data
  22825. * @param source defines the JSON representation of the material
  22826. * @param scene defines the hosting scene
  22827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22828. * @returns a new node material
  22829. */
  22830. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22831. /**
  22832. * Creates a node material from a snippet saved in a remote file
  22833. * @param name defines the name of the material to create
  22834. * @param url defines the url to load from
  22835. * @param scene defines the hosting scene
  22836. * @returns a promise that will resolve to the new node material
  22837. */
  22838. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22839. /**
  22840. * Creates a node material from a snippet saved by the node material editor
  22841. * @param snippetId defines the snippet to load
  22842. * @param scene defines the hosting scene
  22843. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22844. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22845. * @returns a promise that will resolve to the new node material
  22846. */
  22847. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22848. /**
  22849. * Creates a new node material set to default basic configuration
  22850. * @param name defines the name of the material
  22851. * @param scene defines the hosting scene
  22852. * @returns a new NodeMaterial
  22853. */
  22854. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22855. }
  22856. }
  22857. declare module BABYLON {
  22858. interface ThinEngine {
  22859. /**
  22860. * Unbind a list of render target textures from the webGL context
  22861. * This is used only when drawBuffer extension or webGL2 are active
  22862. * @param textures defines the render target textures to unbind
  22863. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  22864. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  22865. */
  22866. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  22867. /**
  22868. * Create a multi render target texture
  22869. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  22870. * @param size defines the size of the texture
  22871. * @param options defines the creation options
  22872. * @returns the cube texture as an InternalTexture
  22873. */
  22874. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  22875. /**
  22876. * Update the sample count for a given multiple render target texture
  22877. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  22878. * @param textures defines the textures to update
  22879. * @param samples defines the sample count to set
  22880. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  22881. */
  22882. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  22883. /**
  22884. * Select a subsets of attachments to draw to.
  22885. * @param attachments gl attachments
  22886. */
  22887. bindAttachments(attachments: number[]): void;
  22888. /**
  22889. * Creates a layout object to draw/clear on specific textures in a MRT
  22890. * @param textureStatus textureStatus[i] indicates if the i-th is active
  22891. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  22892. */
  22893. buildTextureLayout(textureStatus: boolean[]): number[];
  22894. /**
  22895. * Restores the webgl state to only draw on the main color attachment
  22896. */
  22897. restoreSingleAttachment(): void;
  22898. }
  22899. }
  22900. declare module BABYLON {
  22901. /**
  22902. * Creation options of the multi render target texture.
  22903. */
  22904. export interface IMultiRenderTargetOptions {
  22905. /**
  22906. * Define if the texture needs to create mip maps after render.
  22907. */
  22908. generateMipMaps?: boolean;
  22909. /**
  22910. * Define the types of all the draw buffers we want to create
  22911. */
  22912. types?: number[];
  22913. /**
  22914. * Define the sampling modes of all the draw buffers we want to create
  22915. */
  22916. samplingModes?: number[];
  22917. /**
  22918. * Define if a depth buffer is required
  22919. */
  22920. generateDepthBuffer?: boolean;
  22921. /**
  22922. * Define if a stencil buffer is required
  22923. */
  22924. generateStencilBuffer?: boolean;
  22925. /**
  22926. * Define if a depth texture is required instead of a depth buffer
  22927. */
  22928. generateDepthTexture?: boolean;
  22929. /**
  22930. * Define the number of desired draw buffers
  22931. */
  22932. textureCount?: number;
  22933. /**
  22934. * Define if aspect ratio should be adapted to the texture or stay the scene one
  22935. */
  22936. doNotChangeAspectRatio?: boolean;
  22937. /**
  22938. * Define the default type of the buffers we are creating
  22939. */
  22940. defaultType?: number;
  22941. }
  22942. /**
  22943. * A multi render target, like a render target provides the ability to render to a texture.
  22944. * Unlike the render target, it can render to several draw buffers in one draw.
  22945. * This is specially interesting in deferred rendering or for any effects requiring more than
  22946. * just one color from a single pass.
  22947. */
  22948. export class MultiRenderTarget extends RenderTargetTexture {
  22949. private _internalTextures;
  22950. private _textures;
  22951. private _multiRenderTargetOptions;
  22952. private _count;
  22953. /**
  22954. * Get if draw buffers are currently supported by the used hardware and browser.
  22955. */
  22956. get isSupported(): boolean;
  22957. /**
  22958. * Get the list of textures generated by the multi render target.
  22959. */
  22960. get textures(): Texture[];
  22961. /**
  22962. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  22963. */
  22964. get count(): number;
  22965. /**
  22966. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  22967. */
  22968. get depthTexture(): Texture;
  22969. /**
  22970. * Set the wrapping mode on U of all the textures we are rendering to.
  22971. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22972. */
  22973. set wrapU(wrap: number);
  22974. /**
  22975. * Set the wrapping mode on V of all the textures we are rendering to.
  22976. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22977. */
  22978. set wrapV(wrap: number);
  22979. /**
  22980. * Instantiate a new multi render target texture.
  22981. * A multi render target, like a render target provides the ability to render to a texture.
  22982. * Unlike the render target, it can render to several draw buffers in one draw.
  22983. * This is specially interesting in deferred rendering or for any effects requiring more than
  22984. * just one color from a single pass.
  22985. * @param name Define the name of the texture
  22986. * @param size Define the size of the buffers to render to
  22987. * @param count Define the number of target we are rendering into
  22988. * @param scene Define the scene the texture belongs to
  22989. * @param options Define the options used to create the multi render target
  22990. */
  22991. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  22992. private _initTypes;
  22993. /** @hidden */
  22994. _rebuild(forceFullRebuild?: boolean): void;
  22995. private _createInternalTextures;
  22996. private _createTextures;
  22997. /**
  22998. * Replaces a texture within the MRT.
  22999. * @param texture The new texture to insert in the MRT
  23000. * @param index The index of the texture to replace
  23001. */
  23002. replaceTexture(texture: Texture, index: number): void;
  23003. /**
  23004. * Define the number of samples used if MSAA is enabled.
  23005. */
  23006. get samples(): number;
  23007. set samples(value: number);
  23008. /**
  23009. * Resize all the textures in the multi render target.
  23010. * Be careful as it will recreate all the data in the new texture.
  23011. * @param size Define the new size
  23012. */
  23013. resize(size: any): void;
  23014. /**
  23015. * Changes the number of render targets in this MRT
  23016. * Be careful as it will recreate all the data in the new texture.
  23017. * @param count new texture count
  23018. * @param options Specifies texture types and sampling modes for new textures
  23019. */
  23020. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23021. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23022. /**
  23023. * Dispose the render targets and their associated resources
  23024. */
  23025. dispose(): void;
  23026. /**
  23027. * Release all the underlying texture used as draw buffers.
  23028. */
  23029. releaseInternalTextures(): void;
  23030. }
  23031. }
  23032. declare module BABYLON {
  23033. /** @hidden */
  23034. export var imageProcessingPixelShader: {
  23035. name: string;
  23036. shader: string;
  23037. };
  23038. }
  23039. declare module BABYLON {
  23040. /**
  23041. * ImageProcessingPostProcess
  23042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23043. */
  23044. export class ImageProcessingPostProcess extends PostProcess {
  23045. /**
  23046. * Default configuration related to image processing available in the PBR Material.
  23047. */
  23048. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23049. /**
  23050. * Gets the image processing configuration used either in this material.
  23051. */
  23052. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23053. /**
  23054. * Sets the Default image processing configuration used either in the this material.
  23055. *
  23056. * If sets to null, the scene one is in use.
  23057. */
  23058. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23059. /**
  23060. * Keep track of the image processing observer to allow dispose and replace.
  23061. */
  23062. private _imageProcessingObserver;
  23063. /**
  23064. * Attaches a new image processing configuration to the PBR Material.
  23065. * @param configuration
  23066. */
  23067. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23068. /**
  23069. * If the post process is supported.
  23070. */
  23071. get isSupported(): boolean;
  23072. /**
  23073. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23074. */
  23075. get colorCurves(): Nullable<ColorCurves>;
  23076. /**
  23077. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23078. */
  23079. set colorCurves(value: Nullable<ColorCurves>);
  23080. /**
  23081. * Gets wether the color curves effect is enabled.
  23082. */
  23083. get colorCurvesEnabled(): boolean;
  23084. /**
  23085. * Sets wether the color curves effect is enabled.
  23086. */
  23087. set colorCurvesEnabled(value: boolean);
  23088. /**
  23089. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23090. */
  23091. get colorGradingTexture(): Nullable<BaseTexture>;
  23092. /**
  23093. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23094. */
  23095. set colorGradingTexture(value: Nullable<BaseTexture>);
  23096. /**
  23097. * Gets wether the color grading effect is enabled.
  23098. */
  23099. get colorGradingEnabled(): boolean;
  23100. /**
  23101. * Gets wether the color grading effect is enabled.
  23102. */
  23103. set colorGradingEnabled(value: boolean);
  23104. /**
  23105. * Gets exposure used in the effect.
  23106. */
  23107. get exposure(): number;
  23108. /**
  23109. * Sets exposure used in the effect.
  23110. */
  23111. set exposure(value: number);
  23112. /**
  23113. * Gets wether tonemapping is enabled or not.
  23114. */
  23115. get toneMappingEnabled(): boolean;
  23116. /**
  23117. * Sets wether tonemapping is enabled or not
  23118. */
  23119. set toneMappingEnabled(value: boolean);
  23120. /**
  23121. * Gets the type of tone mapping effect.
  23122. */
  23123. get toneMappingType(): number;
  23124. /**
  23125. * Sets the type of tone mapping effect.
  23126. */
  23127. set toneMappingType(value: number);
  23128. /**
  23129. * Gets contrast used in the effect.
  23130. */
  23131. get contrast(): number;
  23132. /**
  23133. * Sets contrast used in the effect.
  23134. */
  23135. set contrast(value: number);
  23136. /**
  23137. * Gets Vignette stretch size.
  23138. */
  23139. get vignetteStretch(): number;
  23140. /**
  23141. * Sets Vignette stretch size.
  23142. */
  23143. set vignetteStretch(value: number);
  23144. /**
  23145. * Gets Vignette centre X Offset.
  23146. */
  23147. get vignetteCentreX(): number;
  23148. /**
  23149. * Sets Vignette centre X Offset.
  23150. */
  23151. set vignetteCentreX(value: number);
  23152. /**
  23153. * Gets Vignette centre Y Offset.
  23154. */
  23155. get vignetteCentreY(): number;
  23156. /**
  23157. * Sets Vignette centre Y Offset.
  23158. */
  23159. set vignetteCentreY(value: number);
  23160. /**
  23161. * Gets Vignette weight or intensity of the vignette effect.
  23162. */
  23163. get vignetteWeight(): number;
  23164. /**
  23165. * Sets Vignette weight or intensity of the vignette effect.
  23166. */
  23167. set vignetteWeight(value: number);
  23168. /**
  23169. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23170. * if vignetteEnabled is set to true.
  23171. */
  23172. get vignetteColor(): Color4;
  23173. /**
  23174. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23175. * if vignetteEnabled is set to true.
  23176. */
  23177. set vignetteColor(value: Color4);
  23178. /**
  23179. * Gets Camera field of view used by the Vignette effect.
  23180. */
  23181. get vignetteCameraFov(): number;
  23182. /**
  23183. * Sets Camera field of view used by the Vignette effect.
  23184. */
  23185. set vignetteCameraFov(value: number);
  23186. /**
  23187. * Gets the vignette blend mode allowing different kind of effect.
  23188. */
  23189. get vignetteBlendMode(): number;
  23190. /**
  23191. * Sets the vignette blend mode allowing different kind of effect.
  23192. */
  23193. set vignetteBlendMode(value: number);
  23194. /**
  23195. * Gets wether the vignette effect is enabled.
  23196. */
  23197. get vignetteEnabled(): boolean;
  23198. /**
  23199. * Sets wether the vignette effect is enabled.
  23200. */
  23201. set vignetteEnabled(value: boolean);
  23202. private _fromLinearSpace;
  23203. /**
  23204. * Gets wether the input of the processing is in Gamma or Linear Space.
  23205. */
  23206. get fromLinearSpace(): boolean;
  23207. /**
  23208. * Sets wether the input of the processing is in Gamma or Linear Space.
  23209. */
  23210. set fromLinearSpace(value: boolean);
  23211. /**
  23212. * Defines cache preventing GC.
  23213. */
  23214. private _defines;
  23215. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23216. /**
  23217. * "ImageProcessingPostProcess"
  23218. * @returns "ImageProcessingPostProcess"
  23219. */
  23220. getClassName(): string;
  23221. /**
  23222. * @hidden
  23223. */
  23224. _updateParameters(): void;
  23225. dispose(camera?: Camera): void;
  23226. }
  23227. }
  23228. declare module BABYLON {
  23229. /**
  23230. * Interface for defining prepass effects in the prepass post-process pipeline
  23231. */
  23232. export interface PrePassEffectConfiguration {
  23233. /**
  23234. * Name of the effect
  23235. */
  23236. name: string;
  23237. /**
  23238. * Post process to attach for this effect
  23239. */
  23240. postProcess?: PostProcess;
  23241. /**
  23242. * Textures required in the MRT
  23243. */
  23244. texturesRequired: number[];
  23245. /**
  23246. * Is the effect enabled
  23247. */
  23248. enabled: boolean;
  23249. /**
  23250. * Disposes the effect configuration
  23251. */
  23252. dispose?: () => void;
  23253. /**
  23254. * Creates the associated post process
  23255. */
  23256. createPostProcess?: () => PostProcess;
  23257. }
  23258. }
  23259. declare module BABYLON {
  23260. /**
  23261. * Options to be used when creating a FresnelParameters.
  23262. */
  23263. export type IFresnelParametersCreationOptions = {
  23264. /**
  23265. * Define the color used on edges (grazing angle)
  23266. */
  23267. leftColor?: Color3;
  23268. /**
  23269. * Define the color used on center
  23270. */
  23271. rightColor?: Color3;
  23272. /**
  23273. * Define bias applied to computed fresnel term
  23274. */
  23275. bias?: number;
  23276. /**
  23277. * Defined the power exponent applied to fresnel term
  23278. */
  23279. power?: number;
  23280. /**
  23281. * Define if the fresnel effect is enable or not.
  23282. */
  23283. isEnabled?: boolean;
  23284. };
  23285. /**
  23286. * Serialized format for FresnelParameters.
  23287. */
  23288. export type IFresnelParametersSerialized = {
  23289. /**
  23290. * Define the color used on edges (grazing angle) [as an array]
  23291. */
  23292. leftColor: number[];
  23293. /**
  23294. * Define the color used on center [as an array]
  23295. */
  23296. rightColor: number[];
  23297. /**
  23298. * Define bias applied to computed fresnel term
  23299. */
  23300. bias: number;
  23301. /**
  23302. * Defined the power exponent applied to fresnel term
  23303. */
  23304. power?: number;
  23305. /**
  23306. * Define if the fresnel effect is enable or not.
  23307. */
  23308. isEnabled: boolean;
  23309. };
  23310. /**
  23311. * This represents all the required information to add a fresnel effect on a material:
  23312. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23313. */
  23314. export class FresnelParameters {
  23315. private _isEnabled;
  23316. /**
  23317. * Define if the fresnel effect is enable or not.
  23318. */
  23319. get isEnabled(): boolean;
  23320. set isEnabled(value: boolean);
  23321. /**
  23322. * Define the color used on edges (grazing angle)
  23323. */
  23324. leftColor: Color3;
  23325. /**
  23326. * Define the color used on center
  23327. */
  23328. rightColor: Color3;
  23329. /**
  23330. * Define bias applied to computed fresnel term
  23331. */
  23332. bias: number;
  23333. /**
  23334. * Defined the power exponent applied to fresnel term
  23335. */
  23336. power: number;
  23337. /**
  23338. * Creates a new FresnelParameters object.
  23339. *
  23340. * @param options provide your own settings to optionally to override defaults
  23341. */
  23342. constructor(options?: IFresnelParametersCreationOptions);
  23343. /**
  23344. * Clones the current fresnel and its valuues
  23345. * @returns a clone fresnel configuration
  23346. */
  23347. clone(): FresnelParameters;
  23348. /**
  23349. * Determines equality between FresnelParameters objects
  23350. * @param otherFresnelParameters defines the second operand
  23351. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23352. */
  23353. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23354. /**
  23355. * Serializes the current fresnel parameters to a JSON representation.
  23356. * @return the JSON serialization
  23357. */
  23358. serialize(): IFresnelParametersSerialized;
  23359. /**
  23360. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23361. * @param parsedFresnelParameters Define the JSON representation
  23362. * @returns the parsed parameters
  23363. */
  23364. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23365. }
  23366. }
  23367. declare module BABYLON {
  23368. /**
  23369. * This groups all the flags used to control the materials channel.
  23370. */
  23371. export class MaterialFlags {
  23372. private static _DiffuseTextureEnabled;
  23373. /**
  23374. * Are diffuse textures enabled in the application.
  23375. */
  23376. static get DiffuseTextureEnabled(): boolean;
  23377. static set DiffuseTextureEnabled(value: boolean);
  23378. private static _DetailTextureEnabled;
  23379. /**
  23380. * Are detail textures enabled in the application.
  23381. */
  23382. static get DetailTextureEnabled(): boolean;
  23383. static set DetailTextureEnabled(value: boolean);
  23384. private static _AmbientTextureEnabled;
  23385. /**
  23386. * Are ambient textures enabled in the application.
  23387. */
  23388. static get AmbientTextureEnabled(): boolean;
  23389. static set AmbientTextureEnabled(value: boolean);
  23390. private static _OpacityTextureEnabled;
  23391. /**
  23392. * Are opacity textures enabled in the application.
  23393. */
  23394. static get OpacityTextureEnabled(): boolean;
  23395. static set OpacityTextureEnabled(value: boolean);
  23396. private static _ReflectionTextureEnabled;
  23397. /**
  23398. * Are reflection textures enabled in the application.
  23399. */
  23400. static get ReflectionTextureEnabled(): boolean;
  23401. static set ReflectionTextureEnabled(value: boolean);
  23402. private static _EmissiveTextureEnabled;
  23403. /**
  23404. * Are emissive textures enabled in the application.
  23405. */
  23406. static get EmissiveTextureEnabled(): boolean;
  23407. static set EmissiveTextureEnabled(value: boolean);
  23408. private static _SpecularTextureEnabled;
  23409. /**
  23410. * Are specular textures enabled in the application.
  23411. */
  23412. static get SpecularTextureEnabled(): boolean;
  23413. static set SpecularTextureEnabled(value: boolean);
  23414. private static _BumpTextureEnabled;
  23415. /**
  23416. * Are bump textures enabled in the application.
  23417. */
  23418. static get BumpTextureEnabled(): boolean;
  23419. static set BumpTextureEnabled(value: boolean);
  23420. private static _LightmapTextureEnabled;
  23421. /**
  23422. * Are lightmap textures enabled in the application.
  23423. */
  23424. static get LightmapTextureEnabled(): boolean;
  23425. static set LightmapTextureEnabled(value: boolean);
  23426. private static _RefractionTextureEnabled;
  23427. /**
  23428. * Are refraction textures enabled in the application.
  23429. */
  23430. static get RefractionTextureEnabled(): boolean;
  23431. static set RefractionTextureEnabled(value: boolean);
  23432. private static _ColorGradingTextureEnabled;
  23433. /**
  23434. * Are color grading textures enabled in the application.
  23435. */
  23436. static get ColorGradingTextureEnabled(): boolean;
  23437. static set ColorGradingTextureEnabled(value: boolean);
  23438. private static _FresnelEnabled;
  23439. /**
  23440. * Are fresnels enabled in the application.
  23441. */
  23442. static get FresnelEnabled(): boolean;
  23443. static set FresnelEnabled(value: boolean);
  23444. private static _ClearCoatTextureEnabled;
  23445. /**
  23446. * Are clear coat textures enabled in the application.
  23447. */
  23448. static get ClearCoatTextureEnabled(): boolean;
  23449. static set ClearCoatTextureEnabled(value: boolean);
  23450. private static _ClearCoatBumpTextureEnabled;
  23451. /**
  23452. * Are clear coat bump textures enabled in the application.
  23453. */
  23454. static get ClearCoatBumpTextureEnabled(): boolean;
  23455. static set ClearCoatBumpTextureEnabled(value: boolean);
  23456. private static _ClearCoatTintTextureEnabled;
  23457. /**
  23458. * Are clear coat tint textures enabled in the application.
  23459. */
  23460. static get ClearCoatTintTextureEnabled(): boolean;
  23461. static set ClearCoatTintTextureEnabled(value: boolean);
  23462. private static _SheenTextureEnabled;
  23463. /**
  23464. * Are sheen textures enabled in the application.
  23465. */
  23466. static get SheenTextureEnabled(): boolean;
  23467. static set SheenTextureEnabled(value: boolean);
  23468. private static _AnisotropicTextureEnabled;
  23469. /**
  23470. * Are anisotropic textures enabled in the application.
  23471. */
  23472. static get AnisotropicTextureEnabled(): boolean;
  23473. static set AnisotropicTextureEnabled(value: boolean);
  23474. private static _ThicknessTextureEnabled;
  23475. /**
  23476. * Are thickness textures enabled in the application.
  23477. */
  23478. static get ThicknessTextureEnabled(): boolean;
  23479. static set ThicknessTextureEnabled(value: boolean);
  23480. }
  23481. }
  23482. declare module BABYLON {
  23483. /** @hidden */
  23484. export var defaultFragmentDeclaration: {
  23485. name: string;
  23486. shader: string;
  23487. };
  23488. }
  23489. declare module BABYLON {
  23490. /** @hidden */
  23491. export var defaultUboDeclaration: {
  23492. name: string;
  23493. shader: string;
  23494. };
  23495. }
  23496. declare module BABYLON {
  23497. /** @hidden */
  23498. export var prePassDeclaration: {
  23499. name: string;
  23500. shader: string;
  23501. };
  23502. }
  23503. declare module BABYLON {
  23504. /** @hidden */
  23505. export var lightFragmentDeclaration: {
  23506. name: string;
  23507. shader: string;
  23508. };
  23509. }
  23510. declare module BABYLON {
  23511. /** @hidden */
  23512. export var lightUboDeclaration: {
  23513. name: string;
  23514. shader: string;
  23515. };
  23516. }
  23517. declare module BABYLON {
  23518. /** @hidden */
  23519. export var lightsFragmentFunctions: {
  23520. name: string;
  23521. shader: string;
  23522. };
  23523. }
  23524. declare module BABYLON {
  23525. /** @hidden */
  23526. export var shadowsFragmentFunctions: {
  23527. name: string;
  23528. shader: string;
  23529. };
  23530. }
  23531. declare module BABYLON {
  23532. /** @hidden */
  23533. export var fresnelFunction: {
  23534. name: string;
  23535. shader: string;
  23536. };
  23537. }
  23538. declare module BABYLON {
  23539. /** @hidden */
  23540. export var bumpFragmentMainFunctions: {
  23541. name: string;
  23542. shader: string;
  23543. };
  23544. }
  23545. declare module BABYLON {
  23546. /** @hidden */
  23547. export var bumpFragmentFunctions: {
  23548. name: string;
  23549. shader: string;
  23550. };
  23551. }
  23552. declare module BABYLON {
  23553. /** @hidden */
  23554. export var logDepthDeclaration: {
  23555. name: string;
  23556. shader: string;
  23557. };
  23558. }
  23559. declare module BABYLON {
  23560. /** @hidden */
  23561. export var bumpFragment: {
  23562. name: string;
  23563. shader: string;
  23564. };
  23565. }
  23566. declare module BABYLON {
  23567. /** @hidden */
  23568. export var depthPrePass: {
  23569. name: string;
  23570. shader: string;
  23571. };
  23572. }
  23573. declare module BABYLON {
  23574. /** @hidden */
  23575. export var lightFragment: {
  23576. name: string;
  23577. shader: string;
  23578. };
  23579. }
  23580. declare module BABYLON {
  23581. /** @hidden */
  23582. export var logDepthFragment: {
  23583. name: string;
  23584. shader: string;
  23585. };
  23586. }
  23587. declare module BABYLON {
  23588. /** @hidden */
  23589. export var defaultPixelShader: {
  23590. name: string;
  23591. shader: string;
  23592. };
  23593. }
  23594. declare module BABYLON {
  23595. /** @hidden */
  23596. export var defaultVertexDeclaration: {
  23597. name: string;
  23598. shader: string;
  23599. };
  23600. }
  23601. declare module BABYLON {
  23602. /** @hidden */
  23603. export var prePassVertexDeclaration: {
  23604. name: string;
  23605. shader: string;
  23606. };
  23607. }
  23608. declare module BABYLON {
  23609. /** @hidden */
  23610. export var bumpVertexDeclaration: {
  23611. name: string;
  23612. shader: string;
  23613. };
  23614. }
  23615. declare module BABYLON {
  23616. /** @hidden */
  23617. export var prePassVertex: {
  23618. name: string;
  23619. shader: string;
  23620. };
  23621. }
  23622. declare module BABYLON {
  23623. /** @hidden */
  23624. export var bumpVertex: {
  23625. name: string;
  23626. shader: string;
  23627. };
  23628. }
  23629. declare module BABYLON {
  23630. /** @hidden */
  23631. export var fogVertex: {
  23632. name: string;
  23633. shader: string;
  23634. };
  23635. }
  23636. declare module BABYLON {
  23637. /** @hidden */
  23638. export var shadowsVertex: {
  23639. name: string;
  23640. shader: string;
  23641. };
  23642. }
  23643. declare module BABYLON {
  23644. /** @hidden */
  23645. export var pointCloudVertex: {
  23646. name: string;
  23647. shader: string;
  23648. };
  23649. }
  23650. declare module BABYLON {
  23651. /** @hidden */
  23652. export var logDepthVertex: {
  23653. name: string;
  23654. shader: string;
  23655. };
  23656. }
  23657. declare module BABYLON {
  23658. /** @hidden */
  23659. export var defaultVertexShader: {
  23660. name: string;
  23661. shader: string;
  23662. };
  23663. }
  23664. declare module BABYLON {
  23665. /**
  23666. * @hidden
  23667. */
  23668. export interface IMaterialDetailMapDefines {
  23669. DETAIL: boolean;
  23670. DETAILDIRECTUV: number;
  23671. DETAIL_NORMALBLENDMETHOD: number;
  23672. /** @hidden */
  23673. _areTexturesDirty: boolean;
  23674. }
  23675. /**
  23676. * Define the code related to the detail map parameters of a material
  23677. *
  23678. * Inspired from:
  23679. * 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
  23680. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23681. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23682. */
  23683. export class DetailMapConfiguration {
  23684. private _texture;
  23685. /**
  23686. * The detail texture of the material.
  23687. */
  23688. texture: Nullable<BaseTexture>;
  23689. /**
  23690. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23691. * Bigger values mean stronger blending
  23692. */
  23693. diffuseBlendLevel: number;
  23694. /**
  23695. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23696. * Bigger values mean stronger blending. Only used with PBR materials
  23697. */
  23698. roughnessBlendLevel: number;
  23699. /**
  23700. * Defines how strong the bump effect from the detail map is
  23701. * Bigger values mean stronger effect
  23702. */
  23703. bumpLevel: number;
  23704. private _normalBlendMethod;
  23705. /**
  23706. * The method used to blend the bump and detail normals together
  23707. */
  23708. normalBlendMethod: number;
  23709. private _isEnabled;
  23710. /**
  23711. * Enable or disable the detail map on this material
  23712. */
  23713. isEnabled: boolean;
  23714. /** @hidden */
  23715. private _internalMarkAllSubMeshesAsTexturesDirty;
  23716. /** @hidden */
  23717. _markAllSubMeshesAsTexturesDirty(): void;
  23718. /**
  23719. * Instantiate a new detail map
  23720. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23721. */
  23722. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23723. /**
  23724. * Gets whether the submesh is ready to be used or not.
  23725. * @param defines the list of "defines" to update.
  23726. * @param scene defines the scene the material belongs to.
  23727. * @returns - boolean indicating that the submesh is ready or not.
  23728. */
  23729. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23730. /**
  23731. * Update the defines for detail map usage
  23732. * @param defines the list of "defines" to update.
  23733. * @param scene defines the scene the material belongs to.
  23734. */
  23735. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23736. /**
  23737. * Binds the material data.
  23738. * @param uniformBuffer defines the Uniform buffer to fill in.
  23739. * @param scene defines the scene the material belongs to.
  23740. * @param isFrozen defines whether the material is frozen or not.
  23741. */
  23742. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  23743. /**
  23744. * Checks to see if a texture is used in the material.
  23745. * @param texture - Base texture to use.
  23746. * @returns - Boolean specifying if a texture is used in the material.
  23747. */
  23748. hasTexture(texture: BaseTexture): boolean;
  23749. /**
  23750. * Returns an array of the actively used textures.
  23751. * @param activeTextures Array of BaseTextures
  23752. */
  23753. getActiveTextures(activeTextures: BaseTexture[]): void;
  23754. /**
  23755. * Returns the animatable textures.
  23756. * @param animatables Array of animatable textures.
  23757. */
  23758. getAnimatables(animatables: IAnimatable[]): void;
  23759. /**
  23760. * Disposes the resources of the material.
  23761. * @param forceDisposeTextures - Forces the disposal of all textures.
  23762. */
  23763. dispose(forceDisposeTextures?: boolean): void;
  23764. /**
  23765. * Get the current class name useful for serialization or dynamic coding.
  23766. * @returns "DetailMap"
  23767. */
  23768. getClassName(): string;
  23769. /**
  23770. * Add the required uniforms to the current list.
  23771. * @param uniforms defines the current uniform list.
  23772. */
  23773. static AddUniforms(uniforms: string[]): void;
  23774. /**
  23775. * Add the required samplers to the current list.
  23776. * @param samplers defines the current sampler list.
  23777. */
  23778. static AddSamplers(samplers: string[]): void;
  23779. /**
  23780. * Add the required uniforms to the current buffer.
  23781. * @param uniformBuffer defines the current uniform buffer.
  23782. */
  23783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  23784. /**
  23785. * Makes a duplicate of the current instance into another one.
  23786. * @param detailMap define the instance where to copy the info
  23787. */
  23788. copyTo(detailMap: DetailMapConfiguration): void;
  23789. /**
  23790. * Serializes this detail map instance
  23791. * @returns - An object with the serialized instance.
  23792. */
  23793. serialize(): any;
  23794. /**
  23795. * Parses a detail map setting from a serialized object.
  23796. * @param source - Serialized object.
  23797. * @param scene Defines the scene we are parsing for
  23798. * @param rootUrl Defines the rootUrl to load from
  23799. */
  23800. parse(source: any, scene: Scene, rootUrl: string): void;
  23801. }
  23802. }
  23803. declare module BABYLON {
  23804. /** @hidden */
  23805. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  23806. MAINUV1: boolean;
  23807. MAINUV2: boolean;
  23808. DIFFUSE: boolean;
  23809. DIFFUSEDIRECTUV: number;
  23810. DETAIL: boolean;
  23811. DETAILDIRECTUV: number;
  23812. DETAIL_NORMALBLENDMETHOD: number;
  23813. AMBIENT: boolean;
  23814. AMBIENTDIRECTUV: number;
  23815. OPACITY: boolean;
  23816. OPACITYDIRECTUV: number;
  23817. OPACITYRGB: boolean;
  23818. REFLECTION: boolean;
  23819. EMISSIVE: boolean;
  23820. EMISSIVEDIRECTUV: number;
  23821. SPECULAR: boolean;
  23822. SPECULARDIRECTUV: number;
  23823. BUMP: boolean;
  23824. BUMPDIRECTUV: number;
  23825. PARALLAX: boolean;
  23826. PARALLAXOCCLUSION: boolean;
  23827. SPECULAROVERALPHA: boolean;
  23828. CLIPPLANE: boolean;
  23829. CLIPPLANE2: boolean;
  23830. CLIPPLANE3: boolean;
  23831. CLIPPLANE4: boolean;
  23832. CLIPPLANE5: boolean;
  23833. CLIPPLANE6: boolean;
  23834. ALPHATEST: boolean;
  23835. DEPTHPREPASS: boolean;
  23836. ALPHAFROMDIFFUSE: boolean;
  23837. POINTSIZE: boolean;
  23838. FOG: boolean;
  23839. SPECULARTERM: boolean;
  23840. DIFFUSEFRESNEL: boolean;
  23841. OPACITYFRESNEL: boolean;
  23842. REFLECTIONFRESNEL: boolean;
  23843. REFRACTIONFRESNEL: boolean;
  23844. EMISSIVEFRESNEL: boolean;
  23845. FRESNEL: boolean;
  23846. NORMAL: boolean;
  23847. UV1: boolean;
  23848. UV2: boolean;
  23849. VERTEXCOLOR: boolean;
  23850. VERTEXALPHA: boolean;
  23851. NUM_BONE_INFLUENCERS: number;
  23852. BonesPerMesh: number;
  23853. BONETEXTURE: boolean;
  23854. BONES_VELOCITY_ENABLED: boolean;
  23855. INSTANCES: boolean;
  23856. THIN_INSTANCES: boolean;
  23857. GLOSSINESS: boolean;
  23858. ROUGHNESS: boolean;
  23859. EMISSIVEASILLUMINATION: boolean;
  23860. LINKEMISSIVEWITHDIFFUSE: boolean;
  23861. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23862. LIGHTMAP: boolean;
  23863. LIGHTMAPDIRECTUV: number;
  23864. OBJECTSPACE_NORMALMAP: boolean;
  23865. USELIGHTMAPASSHADOWMAP: boolean;
  23866. REFLECTIONMAP_3D: boolean;
  23867. REFLECTIONMAP_SPHERICAL: boolean;
  23868. REFLECTIONMAP_PLANAR: boolean;
  23869. REFLECTIONMAP_CUBIC: boolean;
  23870. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23871. REFLECTIONMAP_PROJECTION: boolean;
  23872. REFLECTIONMAP_SKYBOX: boolean;
  23873. REFLECTIONMAP_EXPLICIT: boolean;
  23874. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23875. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23876. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23877. INVERTCUBICMAP: boolean;
  23878. LOGARITHMICDEPTH: boolean;
  23879. REFRACTION: boolean;
  23880. REFRACTIONMAP_3D: boolean;
  23881. REFLECTIONOVERALPHA: boolean;
  23882. TWOSIDEDLIGHTING: boolean;
  23883. SHADOWFLOAT: boolean;
  23884. MORPHTARGETS: boolean;
  23885. MORPHTARGETS_NORMAL: boolean;
  23886. MORPHTARGETS_TANGENT: boolean;
  23887. MORPHTARGETS_UV: boolean;
  23888. NUM_MORPH_INFLUENCERS: number;
  23889. NONUNIFORMSCALING: boolean;
  23890. PREMULTIPLYALPHA: boolean;
  23891. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  23892. ALPHABLEND: boolean;
  23893. PREPASS: boolean;
  23894. PREPASS_IRRADIANCE: boolean;
  23895. PREPASS_IRRADIANCE_INDEX: number;
  23896. PREPASS_ALBEDO: boolean;
  23897. PREPASS_ALBEDO_INDEX: number;
  23898. PREPASS_DEPTHNORMAL: boolean;
  23899. PREPASS_DEPTHNORMAL_INDEX: number;
  23900. PREPASS_POSITION: boolean;
  23901. PREPASS_POSITION_INDEX: number;
  23902. PREPASS_VELOCITY: boolean;
  23903. PREPASS_VELOCITY_INDEX: number;
  23904. PREPASS_REFLECTIVITY: boolean;
  23905. PREPASS_REFLECTIVITY_INDEX: number;
  23906. SCENE_MRT_COUNT: number;
  23907. RGBDLIGHTMAP: boolean;
  23908. RGBDREFLECTION: boolean;
  23909. RGBDREFRACTION: boolean;
  23910. IMAGEPROCESSING: boolean;
  23911. VIGNETTE: boolean;
  23912. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23913. VIGNETTEBLENDMODEOPAQUE: boolean;
  23914. TONEMAPPING: boolean;
  23915. TONEMAPPING_ACES: boolean;
  23916. CONTRAST: boolean;
  23917. COLORCURVES: boolean;
  23918. COLORGRADING: boolean;
  23919. COLORGRADING3D: boolean;
  23920. SAMPLER3DGREENDEPTH: boolean;
  23921. SAMPLER3DBGRMAP: boolean;
  23922. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23923. MULTIVIEW: boolean;
  23924. /**
  23925. * If the reflection texture on this material is in linear color space
  23926. * @hidden
  23927. */
  23928. IS_REFLECTION_LINEAR: boolean;
  23929. /**
  23930. * If the refraction texture on this material is in linear color space
  23931. * @hidden
  23932. */
  23933. IS_REFRACTION_LINEAR: boolean;
  23934. EXPOSURE: boolean;
  23935. constructor();
  23936. setReflectionMode(modeToEnable: string): void;
  23937. }
  23938. /**
  23939. * This is the default material used in Babylon. It is the best trade off between quality
  23940. * and performances.
  23941. * @see https://doc.babylonjs.com/babylon101/materials
  23942. */
  23943. export class StandardMaterial extends PushMaterial {
  23944. private _diffuseTexture;
  23945. /**
  23946. * The basic texture of the material as viewed under a light.
  23947. */
  23948. diffuseTexture: Nullable<BaseTexture>;
  23949. private _ambientTexture;
  23950. /**
  23951. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23952. */
  23953. ambientTexture: Nullable<BaseTexture>;
  23954. private _opacityTexture;
  23955. /**
  23956. * Define the transparency of the material from a texture.
  23957. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23958. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23959. */
  23960. opacityTexture: Nullable<BaseTexture>;
  23961. private _reflectionTexture;
  23962. /**
  23963. * Define the texture used to display the reflection.
  23964. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23965. */
  23966. reflectionTexture: Nullable<BaseTexture>;
  23967. private _emissiveTexture;
  23968. /**
  23969. * Define texture of the material as if self lit.
  23970. * This will be mixed in the final result even in the absence of light.
  23971. */
  23972. emissiveTexture: Nullable<BaseTexture>;
  23973. private _specularTexture;
  23974. /**
  23975. * Define how the color and intensity of the highlight given by the light in the material.
  23976. */
  23977. specularTexture: Nullable<BaseTexture>;
  23978. private _bumpTexture;
  23979. /**
  23980. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23981. * 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.
  23982. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  23983. */
  23984. bumpTexture: Nullable<BaseTexture>;
  23985. private _lightmapTexture;
  23986. /**
  23987. * Complex lighting can be computationally expensive to compute at runtime.
  23988. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23989. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  23990. */
  23991. lightmapTexture: Nullable<BaseTexture>;
  23992. private _refractionTexture;
  23993. /**
  23994. * Define the texture used to display the refraction.
  23995. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23996. */
  23997. refractionTexture: Nullable<BaseTexture>;
  23998. /**
  23999. * The color of the material lit by the environmental background lighting.
  24000. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24001. */
  24002. ambientColor: Color3;
  24003. /**
  24004. * The basic color of the material as viewed under a light.
  24005. */
  24006. diffuseColor: Color3;
  24007. /**
  24008. * Define how the color and intensity of the highlight given by the light in the material.
  24009. */
  24010. specularColor: Color3;
  24011. /**
  24012. * Define the color of the material as if self lit.
  24013. * This will be mixed in the final result even in the absence of light.
  24014. */
  24015. emissiveColor: Color3;
  24016. /**
  24017. * Defines how sharp are the highlights in the material.
  24018. * The bigger the value the sharper giving a more glossy feeling to the result.
  24019. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24020. */
  24021. specularPower: number;
  24022. private _useAlphaFromDiffuseTexture;
  24023. /**
  24024. * Does the transparency come from the diffuse texture alpha channel.
  24025. */
  24026. useAlphaFromDiffuseTexture: boolean;
  24027. private _useEmissiveAsIllumination;
  24028. /**
  24029. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24030. */
  24031. useEmissiveAsIllumination: boolean;
  24032. private _linkEmissiveWithDiffuse;
  24033. /**
  24034. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24035. * the emissive level when the final color is close to one.
  24036. */
  24037. linkEmissiveWithDiffuse: boolean;
  24038. private _useSpecularOverAlpha;
  24039. /**
  24040. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24041. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24042. */
  24043. useSpecularOverAlpha: boolean;
  24044. private _useReflectionOverAlpha;
  24045. /**
  24046. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24047. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24048. */
  24049. useReflectionOverAlpha: boolean;
  24050. private _disableLighting;
  24051. /**
  24052. * Does lights from the scene impacts this material.
  24053. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24054. */
  24055. disableLighting: boolean;
  24056. private _useObjectSpaceNormalMap;
  24057. /**
  24058. * Allows using an object space normal map (instead of tangent space).
  24059. */
  24060. useObjectSpaceNormalMap: boolean;
  24061. private _useParallax;
  24062. /**
  24063. * Is parallax enabled or not.
  24064. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24065. */
  24066. useParallax: boolean;
  24067. private _useParallaxOcclusion;
  24068. /**
  24069. * Is parallax occlusion enabled or not.
  24070. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24071. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24072. */
  24073. useParallaxOcclusion: boolean;
  24074. /**
  24075. * 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.
  24076. */
  24077. parallaxScaleBias: number;
  24078. private _roughness;
  24079. /**
  24080. * Helps to define how blurry the reflections should appears in the material.
  24081. */
  24082. roughness: number;
  24083. /**
  24084. * In case of refraction, define the value of the index of refraction.
  24085. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24086. */
  24087. indexOfRefraction: number;
  24088. /**
  24089. * Invert the refraction texture alongside the y axis.
  24090. * It can be useful with procedural textures or probe for instance.
  24091. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24092. */
  24093. invertRefractionY: boolean;
  24094. /**
  24095. * Defines the alpha limits in alpha test mode.
  24096. */
  24097. alphaCutOff: number;
  24098. private _useLightmapAsShadowmap;
  24099. /**
  24100. * In case of light mapping, define whether the map contains light or shadow informations.
  24101. */
  24102. useLightmapAsShadowmap: boolean;
  24103. private _diffuseFresnelParameters;
  24104. /**
  24105. * Define the diffuse fresnel parameters of the material.
  24106. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24107. */
  24108. diffuseFresnelParameters: FresnelParameters;
  24109. private _opacityFresnelParameters;
  24110. /**
  24111. * Define the opacity fresnel parameters of the material.
  24112. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24113. */
  24114. opacityFresnelParameters: FresnelParameters;
  24115. private _reflectionFresnelParameters;
  24116. /**
  24117. * Define the reflection fresnel parameters of the material.
  24118. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24119. */
  24120. reflectionFresnelParameters: FresnelParameters;
  24121. private _refractionFresnelParameters;
  24122. /**
  24123. * Define the refraction fresnel parameters of the material.
  24124. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24125. */
  24126. refractionFresnelParameters: FresnelParameters;
  24127. private _emissiveFresnelParameters;
  24128. /**
  24129. * Define the emissive fresnel parameters of the material.
  24130. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24131. */
  24132. emissiveFresnelParameters: FresnelParameters;
  24133. private _useReflectionFresnelFromSpecular;
  24134. /**
  24135. * If true automatically deducts the fresnels values from the material specularity.
  24136. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24137. */
  24138. useReflectionFresnelFromSpecular: boolean;
  24139. private _useGlossinessFromSpecularMapAlpha;
  24140. /**
  24141. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24142. */
  24143. useGlossinessFromSpecularMapAlpha: boolean;
  24144. private _maxSimultaneousLights;
  24145. /**
  24146. * Defines the maximum number of lights that can be used in the material
  24147. */
  24148. maxSimultaneousLights: number;
  24149. private _invertNormalMapX;
  24150. /**
  24151. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24152. */
  24153. invertNormalMapX: boolean;
  24154. private _invertNormalMapY;
  24155. /**
  24156. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24157. */
  24158. invertNormalMapY: boolean;
  24159. private _twoSidedLighting;
  24160. /**
  24161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24162. */
  24163. twoSidedLighting: boolean;
  24164. /**
  24165. * Default configuration related to image processing available in the standard Material.
  24166. */
  24167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24168. /**
  24169. * Gets the image processing configuration used either in this material.
  24170. */
  24171. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24172. /**
  24173. * Sets the Default image processing configuration used either in the this material.
  24174. *
  24175. * If sets to null, the scene one is in use.
  24176. */
  24177. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24178. /**
  24179. * Keep track of the image processing observer to allow dispose and replace.
  24180. */
  24181. private _imageProcessingObserver;
  24182. /**
  24183. * Attaches a new image processing configuration to the Standard Material.
  24184. * @param configuration
  24185. */
  24186. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24187. /**
  24188. * Defines additionnal PrePass parameters for the material.
  24189. */
  24190. readonly prePassConfiguration: PrePassConfiguration;
  24191. /**
  24192. * Gets wether the color curves effect is enabled.
  24193. */
  24194. get cameraColorCurvesEnabled(): boolean;
  24195. /**
  24196. * Sets wether the color curves effect is enabled.
  24197. */
  24198. set cameraColorCurvesEnabled(value: boolean);
  24199. /**
  24200. * Gets wether the color grading effect is enabled.
  24201. */
  24202. get cameraColorGradingEnabled(): boolean;
  24203. /**
  24204. * Gets wether the color grading effect is enabled.
  24205. */
  24206. set cameraColorGradingEnabled(value: boolean);
  24207. /**
  24208. * Gets wether tonemapping is enabled or not.
  24209. */
  24210. get cameraToneMappingEnabled(): boolean;
  24211. /**
  24212. * Sets wether tonemapping is enabled or not
  24213. */
  24214. set cameraToneMappingEnabled(value: boolean);
  24215. /**
  24216. * The camera exposure used on this material.
  24217. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24218. * This corresponds to a photographic exposure.
  24219. */
  24220. get cameraExposure(): number;
  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. set cameraExposure(value: number);
  24227. /**
  24228. * Gets The camera contrast used on this material.
  24229. */
  24230. get cameraContrast(): number;
  24231. /**
  24232. * Sets The camera contrast used on this material.
  24233. */
  24234. set cameraContrast(value: number);
  24235. /**
  24236. * Gets the Color Grading 2D Lookup Texture.
  24237. */
  24238. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24239. /**
  24240. * Sets the Color Grading 2D Lookup Texture.
  24241. */
  24242. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24243. /**
  24244. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24245. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24246. * 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;
  24247. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24248. */
  24249. get cameraColorCurves(): Nullable<ColorCurves>;
  24250. /**
  24251. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24252. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24253. * 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;
  24254. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24255. */
  24256. set cameraColorCurves(value: Nullable<ColorCurves>);
  24257. /**
  24258. * Can this material render to several textures at once
  24259. */
  24260. get canRenderToMRT(): boolean;
  24261. /**
  24262. * Defines the detail map parameters for the material.
  24263. */
  24264. readonly detailMap: DetailMapConfiguration;
  24265. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24266. protected _worldViewProjectionMatrix: Matrix;
  24267. protected _globalAmbientColor: Color3;
  24268. protected _useLogarithmicDepth: boolean;
  24269. protected _rebuildInParallel: boolean;
  24270. /**
  24271. * Instantiates a new standard material.
  24272. * This is the default material used in Babylon. It is the best trade off between quality
  24273. * and performances.
  24274. * @see https://doc.babylonjs.com/babylon101/materials
  24275. * @param name Define the name of the material in the scene
  24276. * @param scene Define the scene the material belong to
  24277. */
  24278. constructor(name: string, scene: Scene);
  24279. /**
  24280. * Gets a boolean indicating that current material needs to register RTT
  24281. */
  24282. get hasRenderTargetTextures(): boolean;
  24283. /**
  24284. * Gets the current class name of the material e.g. "StandardMaterial"
  24285. * Mainly use in serialization.
  24286. * @returns the class name
  24287. */
  24288. getClassName(): string;
  24289. /**
  24290. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24291. * You can try switching to logarithmic depth.
  24292. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24293. */
  24294. get useLogarithmicDepth(): boolean;
  24295. set useLogarithmicDepth(value: boolean);
  24296. /**
  24297. * Specifies if the material will require alpha blending
  24298. * @returns a boolean specifying if alpha blending is needed
  24299. */
  24300. needAlphaBlending(): boolean;
  24301. /**
  24302. * Specifies if this material should be rendered in alpha test mode
  24303. * @returns a boolean specifying if an alpha test is needed.
  24304. */
  24305. needAlphaTesting(): boolean;
  24306. /**
  24307. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24308. */
  24309. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24310. /**
  24311. * Specifies whether or not there is a usable alpha channel for transparency.
  24312. */
  24313. protected _hasAlphaChannel(): boolean;
  24314. /**
  24315. * Get the texture used for alpha test purpose.
  24316. * @returns the diffuse texture in case of the standard material.
  24317. */
  24318. getAlphaTestTexture(): Nullable<BaseTexture>;
  24319. /**
  24320. * Get if the submesh is ready to be used and all its information available.
  24321. * Child classes can use it to update shaders
  24322. * @param mesh defines the mesh to check
  24323. * @param subMesh defines which submesh to check
  24324. * @param useInstances specifies that instances should be used
  24325. * @returns a boolean indicating that the submesh is ready or not
  24326. */
  24327. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24328. /**
  24329. * Builds the material UBO layouts.
  24330. * Used internally during the effect preparation.
  24331. */
  24332. buildUniformLayout(): void;
  24333. /**
  24334. * Unbinds the material from the mesh
  24335. */
  24336. unbind(): void;
  24337. /**
  24338. * Binds the submesh to this material by preparing the effect and shader to draw
  24339. * @param world defines the world transformation matrix
  24340. * @param mesh defines the mesh containing the submesh
  24341. * @param subMesh defines the submesh to bind the material to
  24342. */
  24343. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24344. /**
  24345. * Get the list of animatables in the material.
  24346. * @returns the list of animatables object used in the material
  24347. */
  24348. getAnimatables(): IAnimatable[];
  24349. /**
  24350. * Gets the active textures from the material
  24351. * @returns an array of textures
  24352. */
  24353. getActiveTextures(): BaseTexture[];
  24354. /**
  24355. * Specifies if the material uses a texture
  24356. * @param texture defines the texture to check against the material
  24357. * @returns a boolean specifying if the material uses the texture
  24358. */
  24359. hasTexture(texture: BaseTexture): boolean;
  24360. /**
  24361. * Disposes the material
  24362. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24363. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24364. */
  24365. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24366. /**
  24367. * Makes a duplicate of the material, and gives it a new name
  24368. * @param name defines the new name for the duplicated material
  24369. * @returns the cloned material
  24370. */
  24371. clone(name: string): StandardMaterial;
  24372. /**
  24373. * Serializes this material in a JSON representation
  24374. * @returns the serialized material object
  24375. */
  24376. serialize(): any;
  24377. /**
  24378. * Creates a standard material from parsed material data
  24379. * @param source defines the JSON representation of the material
  24380. * @param scene defines the hosting scene
  24381. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24382. * @returns a new standard material
  24383. */
  24384. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24385. /**
  24386. * Are diffuse textures enabled in the application.
  24387. */
  24388. static get DiffuseTextureEnabled(): boolean;
  24389. static set DiffuseTextureEnabled(value: boolean);
  24390. /**
  24391. * Are detail textures enabled in the application.
  24392. */
  24393. static get DetailTextureEnabled(): boolean;
  24394. static set DetailTextureEnabled(value: boolean);
  24395. /**
  24396. * Are ambient textures enabled in the application.
  24397. */
  24398. static get AmbientTextureEnabled(): boolean;
  24399. static set AmbientTextureEnabled(value: boolean);
  24400. /**
  24401. * Are opacity textures enabled in the application.
  24402. */
  24403. static get OpacityTextureEnabled(): boolean;
  24404. static set OpacityTextureEnabled(value: boolean);
  24405. /**
  24406. * Are reflection textures enabled in the application.
  24407. */
  24408. static get ReflectionTextureEnabled(): boolean;
  24409. static set ReflectionTextureEnabled(value: boolean);
  24410. /**
  24411. * Are emissive textures enabled in the application.
  24412. */
  24413. static get EmissiveTextureEnabled(): boolean;
  24414. static set EmissiveTextureEnabled(value: boolean);
  24415. /**
  24416. * Are specular textures enabled in the application.
  24417. */
  24418. static get SpecularTextureEnabled(): boolean;
  24419. static set SpecularTextureEnabled(value: boolean);
  24420. /**
  24421. * Are bump textures enabled in the application.
  24422. */
  24423. static get BumpTextureEnabled(): boolean;
  24424. static set BumpTextureEnabled(value: boolean);
  24425. /**
  24426. * Are lightmap textures enabled in the application.
  24427. */
  24428. static get LightmapTextureEnabled(): boolean;
  24429. static set LightmapTextureEnabled(value: boolean);
  24430. /**
  24431. * Are refraction textures enabled in the application.
  24432. */
  24433. static get RefractionTextureEnabled(): boolean;
  24434. static set RefractionTextureEnabled(value: boolean);
  24435. /**
  24436. * Are color grading textures enabled in the application.
  24437. */
  24438. static get ColorGradingTextureEnabled(): boolean;
  24439. static set ColorGradingTextureEnabled(value: boolean);
  24440. /**
  24441. * Are fresnels enabled in the application.
  24442. */
  24443. static get FresnelEnabled(): boolean;
  24444. static set FresnelEnabled(value: boolean);
  24445. }
  24446. }
  24447. declare module BABYLON {
  24448. /** @hidden */
  24449. export var rgbdDecodePixelShader: {
  24450. name: string;
  24451. shader: string;
  24452. };
  24453. }
  24454. declare module BABYLON {
  24455. /**
  24456. * Class used to host RGBD texture specific utilities
  24457. */
  24458. export class RGBDTextureTools {
  24459. /**
  24460. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24461. * @param texture the texture to expand.
  24462. */
  24463. static ExpandRGBDTexture(texture: Texture): void;
  24464. }
  24465. }
  24466. declare module BABYLON {
  24467. /**
  24468. * Class used to host texture specific utilities
  24469. */
  24470. export class BRDFTextureTools {
  24471. /**
  24472. * Prevents texture cache collision
  24473. */
  24474. private static _instanceNumber;
  24475. /**
  24476. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24477. * @param scene defines the hosting scene
  24478. * @returns the environment BRDF texture
  24479. */
  24480. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24481. private static _environmentBRDFBase64Texture;
  24482. }
  24483. }
  24484. declare module BABYLON {
  24485. /**
  24486. * @hidden
  24487. */
  24488. export interface IMaterialClearCoatDefines {
  24489. CLEARCOAT: boolean;
  24490. CLEARCOAT_DEFAULTIOR: boolean;
  24491. CLEARCOAT_TEXTURE: boolean;
  24492. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24493. CLEARCOAT_TEXTUREDIRECTUV: number;
  24494. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24495. CLEARCOAT_BUMP: boolean;
  24496. CLEARCOAT_BUMPDIRECTUV: number;
  24497. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24498. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24499. CLEARCOAT_REMAP_F0: boolean;
  24500. CLEARCOAT_TINT: boolean;
  24501. CLEARCOAT_TINT_TEXTURE: boolean;
  24502. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24503. /** @hidden */
  24504. _areTexturesDirty: boolean;
  24505. }
  24506. /**
  24507. * Define the code related to the clear coat parameters of the pbr material.
  24508. */
  24509. export class PBRClearCoatConfiguration {
  24510. /**
  24511. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24512. * The default fits with a polyurethane material.
  24513. */
  24514. private static readonly _DefaultIndexOfRefraction;
  24515. private _isEnabled;
  24516. /**
  24517. * Defines if the clear coat is enabled in the material.
  24518. */
  24519. isEnabled: boolean;
  24520. /**
  24521. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24522. */
  24523. intensity: number;
  24524. /**
  24525. * Defines the clear coat layer roughness.
  24526. */
  24527. roughness: number;
  24528. private _indexOfRefraction;
  24529. /**
  24530. * Defines the index of refraction of the clear coat.
  24531. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24532. * The default fits with a polyurethane material.
  24533. * Changing the default value is more performance intensive.
  24534. */
  24535. indexOfRefraction: number;
  24536. private _texture;
  24537. /**
  24538. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24539. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24540. * if textureRoughness is not empty, else no texture roughness is used
  24541. */
  24542. texture: Nullable<BaseTexture>;
  24543. private _useRoughnessFromMainTexture;
  24544. /**
  24545. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24546. * If false, the green channel from textureRoughness is used for roughness
  24547. */
  24548. useRoughnessFromMainTexture: boolean;
  24549. private _textureRoughness;
  24550. /**
  24551. * Stores the clear coat roughness in a texture (green channel)
  24552. * Not used if useRoughnessFromMainTexture is true
  24553. */
  24554. textureRoughness: Nullable<BaseTexture>;
  24555. private _remapF0OnInterfaceChange;
  24556. /**
  24557. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24558. */
  24559. remapF0OnInterfaceChange: boolean;
  24560. private _bumpTexture;
  24561. /**
  24562. * Define the clear coat specific bump texture.
  24563. */
  24564. bumpTexture: Nullable<BaseTexture>;
  24565. private _isTintEnabled;
  24566. /**
  24567. * Defines if the clear coat tint is enabled in the material.
  24568. */
  24569. isTintEnabled: boolean;
  24570. /**
  24571. * Defines the clear coat tint of the material.
  24572. * This is only use if tint is enabled
  24573. */
  24574. tintColor: Color3;
  24575. /**
  24576. * Defines the distance at which the tint color should be found in the
  24577. * clear coat media.
  24578. * This is only use if tint is enabled
  24579. */
  24580. tintColorAtDistance: number;
  24581. /**
  24582. * Defines the clear coat layer thickness.
  24583. * This is only use if tint is enabled
  24584. */
  24585. tintThickness: number;
  24586. private _tintTexture;
  24587. /**
  24588. * Stores the clear tint values in a texture.
  24589. * rgb is tint
  24590. * a is a thickness factor
  24591. */
  24592. tintTexture: Nullable<BaseTexture>;
  24593. /** @hidden */
  24594. private _internalMarkAllSubMeshesAsTexturesDirty;
  24595. /** @hidden */
  24596. _markAllSubMeshesAsTexturesDirty(): void;
  24597. /**
  24598. * Instantiate a new istance of clear coat configuration.
  24599. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24600. */
  24601. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24602. /**
  24603. * Gets wehter the submesh is ready to be used or not.
  24604. * @param defines the list of "defines" to update.
  24605. * @param scene defines the scene the material belongs to.
  24606. * @param engine defines the engine the material belongs to.
  24607. * @param disableBumpMap defines wether the material disables bump or not.
  24608. * @returns - boolean indicating that the submesh is ready or not.
  24609. */
  24610. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24611. /**
  24612. * Checks to see if a texture is used in the material.
  24613. * @param defines the list of "defines" to update.
  24614. * @param scene defines the scene to the material belongs to.
  24615. */
  24616. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24617. /**
  24618. * Binds the material data.
  24619. * @param uniformBuffer defines the Uniform buffer to fill in.
  24620. * @param scene defines the scene the material belongs to.
  24621. * @param engine defines the engine the material belongs to.
  24622. * @param disableBumpMap defines wether the material disables bump or not.
  24623. * @param isFrozen defines wether the material is frozen or not.
  24624. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24625. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24626. * @param subMesh the submesh to bind data for
  24627. */
  24628. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24629. /**
  24630. * Checks to see if a texture is used in the material.
  24631. * @param texture - Base texture to use.
  24632. * @returns - Boolean specifying if a texture is used in the material.
  24633. */
  24634. hasTexture(texture: BaseTexture): boolean;
  24635. /**
  24636. * Returns an array of the actively used textures.
  24637. * @param activeTextures Array of BaseTextures
  24638. */
  24639. getActiveTextures(activeTextures: BaseTexture[]): void;
  24640. /**
  24641. * Returns the animatable textures.
  24642. * @param animatables Array of animatable textures.
  24643. */
  24644. getAnimatables(animatables: IAnimatable[]): void;
  24645. /**
  24646. * Disposes the resources of the material.
  24647. * @param forceDisposeTextures - Forces the disposal of all textures.
  24648. */
  24649. dispose(forceDisposeTextures?: boolean): void;
  24650. /**
  24651. * Get the current class name of the texture useful for serialization or dynamic coding.
  24652. * @returns "PBRClearCoatConfiguration"
  24653. */
  24654. getClassName(): string;
  24655. /**
  24656. * Add fallbacks to the effect fallbacks list.
  24657. * @param defines defines the Base texture to use.
  24658. * @param fallbacks defines the current fallback list.
  24659. * @param currentRank defines the current fallback rank.
  24660. * @returns the new fallback rank.
  24661. */
  24662. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24663. /**
  24664. * Add the required uniforms to the current list.
  24665. * @param uniforms defines the current uniform list.
  24666. */
  24667. static AddUniforms(uniforms: string[]): void;
  24668. /**
  24669. * Add the required samplers to the current list.
  24670. * @param samplers defines the current sampler list.
  24671. */
  24672. static AddSamplers(samplers: string[]): void;
  24673. /**
  24674. * Add the required uniforms to the current buffer.
  24675. * @param uniformBuffer defines the current uniform buffer.
  24676. */
  24677. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24678. /**
  24679. * Makes a duplicate of the current configuration into another one.
  24680. * @param clearCoatConfiguration define the config where to copy the info
  24681. */
  24682. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24683. /**
  24684. * Serializes this clear coat configuration.
  24685. * @returns - An object with the serialized config.
  24686. */
  24687. serialize(): any;
  24688. /**
  24689. * Parses a anisotropy Configuration from a serialized object.
  24690. * @param source - Serialized object.
  24691. * @param scene Defines the scene we are parsing for
  24692. * @param rootUrl Defines the rootUrl to load from
  24693. */
  24694. parse(source: any, scene: Scene, rootUrl: string): void;
  24695. }
  24696. }
  24697. declare module BABYLON {
  24698. /**
  24699. * @hidden
  24700. */
  24701. export interface IMaterialAnisotropicDefines {
  24702. ANISOTROPIC: boolean;
  24703. ANISOTROPIC_TEXTURE: boolean;
  24704. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24705. MAINUV1: boolean;
  24706. _areTexturesDirty: boolean;
  24707. _needUVs: boolean;
  24708. }
  24709. /**
  24710. * Define the code related to the anisotropic parameters of the pbr material.
  24711. */
  24712. export class PBRAnisotropicConfiguration {
  24713. private _isEnabled;
  24714. /**
  24715. * Defines if the anisotropy is enabled in the material.
  24716. */
  24717. isEnabled: boolean;
  24718. /**
  24719. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24720. */
  24721. intensity: number;
  24722. /**
  24723. * Defines if the effect is along the tangents, bitangents or in between.
  24724. * By default, the effect is "strectching" the highlights along the tangents.
  24725. */
  24726. direction: Vector2;
  24727. private _texture;
  24728. /**
  24729. * Stores the anisotropy values in a texture.
  24730. * rg is direction (like normal from -1 to 1)
  24731. * b is a intensity
  24732. */
  24733. texture: Nullable<BaseTexture>;
  24734. /** @hidden */
  24735. private _internalMarkAllSubMeshesAsTexturesDirty;
  24736. /** @hidden */
  24737. _markAllSubMeshesAsTexturesDirty(): void;
  24738. /**
  24739. * Instantiate a new istance of anisotropy configuration.
  24740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24741. */
  24742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24743. /**
  24744. * Specifies that the submesh is ready to be used.
  24745. * @param defines the list of "defines" to update.
  24746. * @param scene defines the scene the material belongs to.
  24747. * @returns - boolean indicating that the submesh is ready or not.
  24748. */
  24749. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  24750. /**
  24751. * Checks to see if a texture is used in the material.
  24752. * @param defines the list of "defines" to update.
  24753. * @param mesh the mesh we are preparing the defines for.
  24754. * @param scene defines the scene the material belongs to.
  24755. */
  24756. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  24757. /**
  24758. * Binds the material data.
  24759. * @param uniformBuffer defines the Uniform buffer to fill in.
  24760. * @param scene defines the scene the material belongs to.
  24761. * @param isFrozen defines wether the material is frozen or not.
  24762. */
  24763. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24764. /**
  24765. * Checks to see if a texture is used in the material.
  24766. * @param texture - Base texture to use.
  24767. * @returns - Boolean specifying if a texture is used in the material.
  24768. */
  24769. hasTexture(texture: BaseTexture): boolean;
  24770. /**
  24771. * Returns an array of the actively used textures.
  24772. * @param activeTextures Array of BaseTextures
  24773. */
  24774. getActiveTextures(activeTextures: BaseTexture[]): void;
  24775. /**
  24776. * Returns the animatable textures.
  24777. * @param animatables Array of animatable textures.
  24778. */
  24779. getAnimatables(animatables: IAnimatable[]): void;
  24780. /**
  24781. * Disposes the resources of the material.
  24782. * @param forceDisposeTextures - Forces the disposal of all textures.
  24783. */
  24784. dispose(forceDisposeTextures?: boolean): void;
  24785. /**
  24786. * Get the current class name of the texture useful for serialization or dynamic coding.
  24787. * @returns "PBRAnisotropicConfiguration"
  24788. */
  24789. getClassName(): string;
  24790. /**
  24791. * Add fallbacks to the effect fallbacks list.
  24792. * @param defines defines the Base texture to use.
  24793. * @param fallbacks defines the current fallback list.
  24794. * @param currentRank defines the current fallback rank.
  24795. * @returns the new fallback rank.
  24796. */
  24797. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24798. /**
  24799. * Add the required uniforms to the current list.
  24800. * @param uniforms defines the current uniform list.
  24801. */
  24802. static AddUniforms(uniforms: string[]): void;
  24803. /**
  24804. * Add the required uniforms to the current buffer.
  24805. * @param uniformBuffer defines the current uniform buffer.
  24806. */
  24807. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24808. /**
  24809. * Add the required samplers to the current list.
  24810. * @param samplers defines the current sampler list.
  24811. */
  24812. static AddSamplers(samplers: string[]): void;
  24813. /**
  24814. * Makes a duplicate of the current configuration into another one.
  24815. * @param anisotropicConfiguration define the config where to copy the info
  24816. */
  24817. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  24818. /**
  24819. * Serializes this anisotropy configuration.
  24820. * @returns - An object with the serialized config.
  24821. */
  24822. serialize(): any;
  24823. /**
  24824. * Parses a anisotropy Configuration from a serialized object.
  24825. * @param source - Serialized object.
  24826. * @param scene Defines the scene we are parsing for
  24827. * @param rootUrl Defines the rootUrl to load from
  24828. */
  24829. parse(source: any, scene: Scene, rootUrl: string): void;
  24830. }
  24831. }
  24832. declare module BABYLON {
  24833. /**
  24834. * @hidden
  24835. */
  24836. export interface IMaterialBRDFDefines {
  24837. BRDF_V_HEIGHT_CORRELATED: boolean;
  24838. MS_BRDF_ENERGY_CONSERVATION: boolean;
  24839. SPHERICAL_HARMONICS: boolean;
  24840. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  24841. /** @hidden */
  24842. _areMiscDirty: boolean;
  24843. }
  24844. /**
  24845. * Define the code related to the BRDF parameters of the pbr material.
  24846. */
  24847. export class PBRBRDFConfiguration {
  24848. /**
  24849. * Default value used for the energy conservation.
  24850. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24851. */
  24852. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  24853. /**
  24854. * Default value used for the Smith Visibility Height Correlated mode.
  24855. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24856. */
  24857. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  24858. /**
  24859. * Default value used for the IBL diffuse part.
  24860. * This can help switching back to the polynomials mode globally which is a tiny bit
  24861. * less GPU intensive at the drawback of a lower quality.
  24862. */
  24863. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  24864. /**
  24865. * Default value used for activating energy conservation for the specular workflow.
  24866. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24867. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24868. */
  24869. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  24870. private _useEnergyConservation;
  24871. /**
  24872. * Defines if the material uses energy conservation.
  24873. */
  24874. useEnergyConservation: boolean;
  24875. private _useSmithVisibilityHeightCorrelated;
  24876. /**
  24877. * LEGACY Mode set to false
  24878. * Defines if the material uses height smith correlated visibility term.
  24879. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  24880. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  24881. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  24882. * Not relying on height correlated will also disable energy conservation.
  24883. */
  24884. useSmithVisibilityHeightCorrelated: boolean;
  24885. private _useSphericalHarmonics;
  24886. /**
  24887. * LEGACY Mode set to false
  24888. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  24889. * diffuse part of the IBL.
  24890. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  24891. * to the ground truth.
  24892. */
  24893. useSphericalHarmonics: boolean;
  24894. private _useSpecularGlossinessInputEnergyConservation;
  24895. /**
  24896. * Defines if the material uses energy conservation, when the specular workflow is active.
  24897. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24898. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24899. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  24900. */
  24901. useSpecularGlossinessInputEnergyConservation: boolean;
  24902. /** @hidden */
  24903. private _internalMarkAllSubMeshesAsMiscDirty;
  24904. /** @hidden */
  24905. _markAllSubMeshesAsMiscDirty(): void;
  24906. /**
  24907. * Instantiate a new istance of clear coat configuration.
  24908. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  24909. */
  24910. constructor(markAllSubMeshesAsMiscDirty: () => void);
  24911. /**
  24912. * Checks to see if a texture is used in the material.
  24913. * @param defines the list of "defines" to update.
  24914. */
  24915. prepareDefines(defines: IMaterialBRDFDefines): void;
  24916. /**
  24917. * Get the current class name of the texture useful for serialization or dynamic coding.
  24918. * @returns "PBRClearCoatConfiguration"
  24919. */
  24920. getClassName(): string;
  24921. /**
  24922. * Makes a duplicate of the current configuration into another one.
  24923. * @param brdfConfiguration define the config where to copy the info
  24924. */
  24925. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  24926. /**
  24927. * Serializes this BRDF configuration.
  24928. * @returns - An object with the serialized config.
  24929. */
  24930. serialize(): any;
  24931. /**
  24932. * Parses a anisotropy Configuration from a serialized object.
  24933. * @param source - Serialized object.
  24934. * @param scene Defines the scene we are parsing for
  24935. * @param rootUrl Defines the rootUrl to load from
  24936. */
  24937. parse(source: any, scene: Scene, rootUrl: string): void;
  24938. }
  24939. }
  24940. declare module BABYLON {
  24941. /**
  24942. * @hidden
  24943. */
  24944. export interface IMaterialSheenDefines {
  24945. SHEEN: boolean;
  24946. SHEEN_TEXTURE: boolean;
  24947. SHEEN_TEXTURE_ROUGHNESS: boolean;
  24948. SHEEN_TEXTUREDIRECTUV: number;
  24949. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  24950. SHEEN_LINKWITHALBEDO: boolean;
  24951. SHEEN_ROUGHNESS: boolean;
  24952. SHEEN_ALBEDOSCALING: boolean;
  24953. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24954. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24955. /** @hidden */
  24956. _areTexturesDirty: boolean;
  24957. }
  24958. /**
  24959. * Define the code related to the Sheen parameters of the pbr material.
  24960. */
  24961. export class PBRSheenConfiguration {
  24962. private _isEnabled;
  24963. /**
  24964. * Defines if the material uses sheen.
  24965. */
  24966. isEnabled: boolean;
  24967. private _linkSheenWithAlbedo;
  24968. /**
  24969. * Defines if the sheen is linked to the sheen color.
  24970. */
  24971. linkSheenWithAlbedo: boolean;
  24972. /**
  24973. * Defines the sheen intensity.
  24974. */
  24975. intensity: number;
  24976. /**
  24977. * Defines the sheen color.
  24978. */
  24979. color: Color3;
  24980. private _texture;
  24981. /**
  24982. * Stores the sheen tint values in a texture.
  24983. * rgb is tint
  24984. * 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)
  24985. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  24986. */
  24987. texture: Nullable<BaseTexture>;
  24988. private _useRoughnessFromMainTexture;
  24989. /**
  24990. * Indicates that the alpha channel of the texture property will be used for roughness.
  24991. * Has no effect if the roughness (and texture!) property is not defined
  24992. */
  24993. useRoughnessFromMainTexture: boolean;
  24994. private _roughness;
  24995. /**
  24996. * Defines the sheen roughness.
  24997. * It is not taken into account if linkSheenWithAlbedo is true.
  24998. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  24999. */
  25000. roughness: Nullable<number>;
  25001. private _textureRoughness;
  25002. /**
  25003. * Stores the sheen roughness in a texture.
  25004. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25005. */
  25006. textureRoughness: Nullable<BaseTexture>;
  25007. private _albedoScaling;
  25008. /**
  25009. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25010. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25011. * making it easier to setup and tweak the effect
  25012. */
  25013. albedoScaling: boolean;
  25014. /** @hidden */
  25015. private _internalMarkAllSubMeshesAsTexturesDirty;
  25016. /** @hidden */
  25017. _markAllSubMeshesAsTexturesDirty(): void;
  25018. /**
  25019. * Instantiate a new istance of clear coat configuration.
  25020. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25021. */
  25022. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25023. /**
  25024. * Specifies that the submesh is ready to be used.
  25025. * @param defines the list of "defines" to update.
  25026. * @param scene defines the scene the material belongs to.
  25027. * @returns - boolean indicating that the submesh is ready or not.
  25028. */
  25029. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25030. /**
  25031. * Checks to see if a texture is used in the material.
  25032. * @param defines the list of "defines" to update.
  25033. * @param scene defines the scene the material belongs to.
  25034. */
  25035. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25036. /**
  25037. * Binds the material data.
  25038. * @param uniformBuffer defines the Uniform buffer to fill in.
  25039. * @param scene defines the scene the material belongs to.
  25040. * @param isFrozen defines wether the material is frozen or not.
  25041. * @param subMesh the submesh to bind data for
  25042. */
  25043. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25044. /**
  25045. * Checks to see if a texture is used in the material.
  25046. * @param texture - Base texture to use.
  25047. * @returns - Boolean specifying if a texture is used in the material.
  25048. */
  25049. hasTexture(texture: BaseTexture): boolean;
  25050. /**
  25051. * Returns an array of the actively used textures.
  25052. * @param activeTextures Array of BaseTextures
  25053. */
  25054. getActiveTextures(activeTextures: BaseTexture[]): void;
  25055. /**
  25056. * Returns the animatable textures.
  25057. * @param animatables Array of animatable textures.
  25058. */
  25059. getAnimatables(animatables: IAnimatable[]): void;
  25060. /**
  25061. * Disposes the resources of the material.
  25062. * @param forceDisposeTextures - Forces the disposal of all textures.
  25063. */
  25064. dispose(forceDisposeTextures?: boolean): void;
  25065. /**
  25066. * Get the current class name of the texture useful for serialization or dynamic coding.
  25067. * @returns "PBRSheenConfiguration"
  25068. */
  25069. getClassName(): string;
  25070. /**
  25071. * Add fallbacks to the effect fallbacks list.
  25072. * @param defines defines the Base texture to use.
  25073. * @param fallbacks defines the current fallback list.
  25074. * @param currentRank defines the current fallback rank.
  25075. * @returns the new fallback rank.
  25076. */
  25077. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25078. /**
  25079. * Add the required uniforms to the current list.
  25080. * @param uniforms defines the current uniform list.
  25081. */
  25082. static AddUniforms(uniforms: string[]): void;
  25083. /**
  25084. * Add the required uniforms to the current buffer.
  25085. * @param uniformBuffer defines the current uniform buffer.
  25086. */
  25087. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25088. /**
  25089. * Add the required samplers to the current list.
  25090. * @param samplers defines the current sampler list.
  25091. */
  25092. static AddSamplers(samplers: string[]): void;
  25093. /**
  25094. * Makes a duplicate of the current configuration into another one.
  25095. * @param sheenConfiguration define the config where to copy the info
  25096. */
  25097. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25098. /**
  25099. * Serializes this BRDF configuration.
  25100. * @returns - An object with the serialized config.
  25101. */
  25102. serialize(): any;
  25103. /**
  25104. * Parses a anisotropy Configuration from a serialized object.
  25105. * @param source - Serialized object.
  25106. * @param scene Defines the scene we are parsing for
  25107. * @param rootUrl Defines the rootUrl to load from
  25108. */
  25109. parse(source: any, scene: Scene, rootUrl: string): void;
  25110. }
  25111. }
  25112. declare module BABYLON {
  25113. /**
  25114. * @hidden
  25115. */
  25116. export interface IMaterialSubSurfaceDefines {
  25117. SUBSURFACE: boolean;
  25118. SS_REFRACTION: boolean;
  25119. SS_TRANSLUCENCY: boolean;
  25120. SS_SCATTERING: boolean;
  25121. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25122. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25123. SS_REFRACTIONMAP_3D: boolean;
  25124. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25125. SS_LODINREFRACTIONALPHA: boolean;
  25126. SS_GAMMAREFRACTION: boolean;
  25127. SS_RGBDREFRACTION: boolean;
  25128. SS_LINEARSPECULARREFRACTION: boolean;
  25129. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25130. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25131. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25132. /** @hidden */
  25133. _areTexturesDirty: boolean;
  25134. }
  25135. /**
  25136. * Define the code related to the sub surface parameters of the pbr material.
  25137. */
  25138. export class PBRSubSurfaceConfiguration {
  25139. private _isRefractionEnabled;
  25140. /**
  25141. * Defines if the refraction is enabled in the material.
  25142. */
  25143. isRefractionEnabled: boolean;
  25144. private _isTranslucencyEnabled;
  25145. /**
  25146. * Defines if the translucency is enabled in the material.
  25147. */
  25148. isTranslucencyEnabled: boolean;
  25149. private _isScatteringEnabled;
  25150. /**
  25151. * Defines if the sub surface scattering is enabled in the material.
  25152. */
  25153. isScatteringEnabled: boolean;
  25154. private _scatteringDiffusionProfileIndex;
  25155. /**
  25156. * Diffusion profile for subsurface scattering.
  25157. * Useful for better scattering in the skins or foliages.
  25158. */
  25159. get scatteringDiffusionProfile(): Nullable<Color3>;
  25160. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25161. /**
  25162. * Defines the refraction intensity of the material.
  25163. * The refraction when enabled replaces the Diffuse part of the material.
  25164. * The intensity helps transitionning between diffuse and refraction.
  25165. */
  25166. refractionIntensity: number;
  25167. /**
  25168. * Defines the translucency intensity of the material.
  25169. * When translucency has been enabled, this defines how much of the "translucency"
  25170. * is addded to the diffuse part of the material.
  25171. */
  25172. translucencyIntensity: number;
  25173. /**
  25174. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25175. */
  25176. useAlbedoToTintRefraction: boolean;
  25177. private _thicknessTexture;
  25178. /**
  25179. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25180. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25181. * 0 would mean minimumThickness
  25182. * 1 would mean maximumThickness
  25183. * The other channels might be use as a mask to vary the different effects intensity.
  25184. */
  25185. thicknessTexture: Nullable<BaseTexture>;
  25186. private _refractionTexture;
  25187. /**
  25188. * Defines the texture to use for refraction.
  25189. */
  25190. refractionTexture: Nullable<BaseTexture>;
  25191. private _indexOfRefraction;
  25192. /**
  25193. * Index of refraction of the material base layer.
  25194. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25195. *
  25196. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25197. *
  25198. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25199. */
  25200. indexOfRefraction: number;
  25201. private _volumeIndexOfRefraction;
  25202. /**
  25203. * Index of refraction of the material's volume.
  25204. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25205. *
  25206. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25207. * the volume will use the same IOR as the surface.
  25208. */
  25209. get volumeIndexOfRefraction(): number;
  25210. set volumeIndexOfRefraction(value: number);
  25211. private _invertRefractionY;
  25212. /**
  25213. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25214. */
  25215. invertRefractionY: boolean;
  25216. private _linkRefractionWithTransparency;
  25217. /**
  25218. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25219. * Materials half opaque for instance using refraction could benefit from this control.
  25220. */
  25221. linkRefractionWithTransparency: boolean;
  25222. /**
  25223. * Defines the minimum thickness stored in the thickness map.
  25224. * If no thickness map is defined, this value will be used to simulate thickness.
  25225. */
  25226. minimumThickness: number;
  25227. /**
  25228. * Defines the maximum thickness stored in the thickness map.
  25229. */
  25230. maximumThickness: number;
  25231. /**
  25232. * Defines the volume tint of the material.
  25233. * This is used for both translucency and scattering.
  25234. */
  25235. tintColor: Color3;
  25236. /**
  25237. * Defines the distance at which the tint color should be found in the media.
  25238. * This is used for refraction only.
  25239. */
  25240. tintColorAtDistance: number;
  25241. /**
  25242. * Defines how far each channel transmit through the media.
  25243. * It is defined as a color to simplify it selection.
  25244. */
  25245. diffusionDistance: Color3;
  25246. private _useMaskFromThicknessTexture;
  25247. /**
  25248. * Stores the intensity of the different subsurface effects in the thickness texture.
  25249. * * the green channel is the translucency intensity.
  25250. * * the blue channel is the scattering intensity.
  25251. * * the alpha channel is the refraction intensity.
  25252. */
  25253. useMaskFromThicknessTexture: boolean;
  25254. private _scene;
  25255. /** @hidden */
  25256. private _internalMarkAllSubMeshesAsTexturesDirty;
  25257. private _internalMarkScenePrePassDirty;
  25258. /** @hidden */
  25259. _markAllSubMeshesAsTexturesDirty(): void;
  25260. /** @hidden */
  25261. _markScenePrePassDirty(): void;
  25262. /**
  25263. * Instantiate a new istance of sub surface configuration.
  25264. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25265. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25266. * @param scene The scene
  25267. */
  25268. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25269. /**
  25270. * Gets wehter the submesh is ready to be used or not.
  25271. * @param defines the list of "defines" to update.
  25272. * @param scene defines the scene the material belongs to.
  25273. * @returns - boolean indicating that the submesh is ready or not.
  25274. */
  25275. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25276. /**
  25277. * Checks to see if a texture is used in the material.
  25278. * @param defines the list of "defines" to update.
  25279. * @param scene defines the scene to the material belongs to.
  25280. */
  25281. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25282. /**
  25283. * Binds the material data.
  25284. * @param uniformBuffer defines the Uniform buffer to fill in.
  25285. * @param scene defines the scene the material belongs to.
  25286. * @param engine defines the engine the material belongs to.
  25287. * @param isFrozen defines whether the material is frozen or not.
  25288. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25289. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25290. */
  25291. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25292. /**
  25293. * Unbinds the material from the mesh.
  25294. * @param activeEffect defines the effect that should be unbound from.
  25295. * @returns true if unbound, otherwise false
  25296. */
  25297. unbind(activeEffect: Effect): boolean;
  25298. /**
  25299. * Returns the texture used for refraction or null if none is used.
  25300. * @param scene defines the scene the material belongs to.
  25301. * @returns - Refraction texture if present. If no refraction texture and refraction
  25302. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25303. */
  25304. private _getRefractionTexture;
  25305. /**
  25306. * Returns true if alpha blending should be disabled.
  25307. */
  25308. get disableAlphaBlending(): boolean;
  25309. /**
  25310. * Fills the list of render target textures.
  25311. * @param renderTargets the list of render targets to update
  25312. */
  25313. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25314. /**
  25315. * Checks to see if a texture is used in the material.
  25316. * @param texture - Base texture to use.
  25317. * @returns - Boolean specifying if a texture is used in the material.
  25318. */
  25319. hasTexture(texture: BaseTexture): boolean;
  25320. /**
  25321. * Gets a boolean indicating that current material needs to register RTT
  25322. * @returns true if this uses a render target otherwise false.
  25323. */
  25324. hasRenderTargetTextures(): boolean;
  25325. /**
  25326. * Returns an array of the actively used textures.
  25327. * @param activeTextures Array of BaseTextures
  25328. */
  25329. getActiveTextures(activeTextures: BaseTexture[]): void;
  25330. /**
  25331. * Returns the animatable textures.
  25332. * @param animatables Array of animatable textures.
  25333. */
  25334. getAnimatables(animatables: IAnimatable[]): void;
  25335. /**
  25336. * Disposes the resources of the material.
  25337. * @param forceDisposeTextures - Forces the disposal of all textures.
  25338. */
  25339. dispose(forceDisposeTextures?: boolean): void;
  25340. /**
  25341. * Get the current class name of the texture useful for serialization or dynamic coding.
  25342. * @returns "PBRSubSurfaceConfiguration"
  25343. */
  25344. getClassName(): string;
  25345. /**
  25346. * Add fallbacks to the effect fallbacks list.
  25347. * @param defines defines the Base texture to use.
  25348. * @param fallbacks defines the current fallback list.
  25349. * @param currentRank defines the current fallback rank.
  25350. * @returns the new fallback rank.
  25351. */
  25352. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25353. /**
  25354. * Add the required uniforms to the current list.
  25355. * @param uniforms defines the current uniform list.
  25356. */
  25357. static AddUniforms(uniforms: string[]): void;
  25358. /**
  25359. * Add the required samplers to the current list.
  25360. * @param samplers defines the current sampler list.
  25361. */
  25362. static AddSamplers(samplers: string[]): void;
  25363. /**
  25364. * Add the required uniforms to the current buffer.
  25365. * @param uniformBuffer defines the current uniform buffer.
  25366. */
  25367. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25368. /**
  25369. * Makes a duplicate of the current configuration into another one.
  25370. * @param configuration define the config where to copy the info
  25371. */
  25372. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25373. /**
  25374. * Serializes this Sub Surface configuration.
  25375. * @returns - An object with the serialized config.
  25376. */
  25377. serialize(): any;
  25378. /**
  25379. * Parses a anisotropy Configuration from a serialized object.
  25380. * @param source - Serialized object.
  25381. * @param scene Defines the scene we are parsing for
  25382. * @param rootUrl Defines the rootUrl to load from
  25383. */
  25384. parse(source: any, scene: Scene, rootUrl: string): void;
  25385. }
  25386. }
  25387. declare module BABYLON {
  25388. /**
  25389. * Class representing spherical harmonics coefficients to the 3rd degree
  25390. */
  25391. export class SphericalHarmonics {
  25392. /**
  25393. * Defines whether or not the harmonics have been prescaled for rendering.
  25394. */
  25395. preScaled: boolean;
  25396. /**
  25397. * The l0,0 coefficients of the spherical harmonics
  25398. */
  25399. l00: Vector3;
  25400. /**
  25401. * The l1,-1 coefficients of the spherical harmonics
  25402. */
  25403. l1_1: Vector3;
  25404. /**
  25405. * The l1,0 coefficients of the spherical harmonics
  25406. */
  25407. l10: Vector3;
  25408. /**
  25409. * The l1,1 coefficients of the spherical harmonics
  25410. */
  25411. l11: Vector3;
  25412. /**
  25413. * The l2,-2 coefficients of the spherical harmonics
  25414. */
  25415. l2_2: Vector3;
  25416. /**
  25417. * The l2,-1 coefficients of the spherical harmonics
  25418. */
  25419. l2_1: Vector3;
  25420. /**
  25421. * The l2,0 coefficients of the spherical harmonics
  25422. */
  25423. l20: Vector3;
  25424. /**
  25425. * The l2,1 coefficients of the spherical harmonics
  25426. */
  25427. l21: Vector3;
  25428. /**
  25429. * The l2,2 coefficients of the spherical harmonics
  25430. */
  25431. l22: Vector3;
  25432. /**
  25433. * Adds a light to the spherical harmonics
  25434. * @param direction the direction of the light
  25435. * @param color the color of the light
  25436. * @param deltaSolidAngle the delta solid angle of the light
  25437. */
  25438. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25439. /**
  25440. * Scales the spherical harmonics by the given amount
  25441. * @param scale the amount to scale
  25442. */
  25443. scaleInPlace(scale: number): void;
  25444. /**
  25445. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25446. *
  25447. * ```
  25448. * E_lm = A_l * L_lm
  25449. * ```
  25450. *
  25451. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25452. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25453. * the scaling factors are given in equation 9.
  25454. */
  25455. convertIncidentRadianceToIrradiance(): void;
  25456. /**
  25457. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25458. *
  25459. * ```
  25460. * L = (1/pi) * E * rho
  25461. * ```
  25462. *
  25463. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25464. */
  25465. convertIrradianceToLambertianRadiance(): void;
  25466. /**
  25467. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25468. * required operations at run time.
  25469. *
  25470. * This is simply done by scaling back the SH with Ylm constants parameter.
  25471. * The trigonometric part being applied by the shader at run time.
  25472. */
  25473. preScaleForRendering(): void;
  25474. /**
  25475. * Constructs a spherical harmonics from an array.
  25476. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25477. * @returns the spherical harmonics
  25478. */
  25479. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25480. /**
  25481. * Gets the spherical harmonics from polynomial
  25482. * @param polynomial the spherical polynomial
  25483. * @returns the spherical harmonics
  25484. */
  25485. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25486. }
  25487. /**
  25488. * Class representing spherical polynomial coefficients to the 3rd degree
  25489. */
  25490. export class SphericalPolynomial {
  25491. private _harmonics;
  25492. /**
  25493. * The spherical harmonics used to create the polynomials.
  25494. */
  25495. get preScaledHarmonics(): SphericalHarmonics;
  25496. /**
  25497. * The x coefficients of the spherical polynomial
  25498. */
  25499. x: Vector3;
  25500. /**
  25501. * The y coefficients of the spherical polynomial
  25502. */
  25503. y: Vector3;
  25504. /**
  25505. * The z coefficients of the spherical polynomial
  25506. */
  25507. z: Vector3;
  25508. /**
  25509. * The xx coefficients of the spherical polynomial
  25510. */
  25511. xx: Vector3;
  25512. /**
  25513. * The yy coefficients of the spherical polynomial
  25514. */
  25515. yy: Vector3;
  25516. /**
  25517. * The zz coefficients of the spherical polynomial
  25518. */
  25519. zz: Vector3;
  25520. /**
  25521. * The xy coefficients of the spherical polynomial
  25522. */
  25523. xy: Vector3;
  25524. /**
  25525. * The yz coefficients of the spherical polynomial
  25526. */
  25527. yz: Vector3;
  25528. /**
  25529. * The zx coefficients of the spherical polynomial
  25530. */
  25531. zx: Vector3;
  25532. /**
  25533. * Adds an ambient color to the spherical polynomial
  25534. * @param color the color to add
  25535. */
  25536. addAmbient(color: Color3): void;
  25537. /**
  25538. * Scales the spherical polynomial by the given amount
  25539. * @param scale the amount to scale
  25540. */
  25541. scaleInPlace(scale: number): void;
  25542. /**
  25543. * Gets the spherical polynomial from harmonics
  25544. * @param harmonics the spherical harmonics
  25545. * @returns the spherical polynomial
  25546. */
  25547. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25548. /**
  25549. * Constructs a spherical polynomial from an array.
  25550. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25551. * @returns the spherical polynomial
  25552. */
  25553. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25554. }
  25555. }
  25556. declare module BABYLON {
  25557. /**
  25558. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25559. */
  25560. export interface CubeMapInfo {
  25561. /**
  25562. * The pixel array for the front face.
  25563. * This is stored in format, left to right, up to down format.
  25564. */
  25565. front: Nullable<ArrayBufferView>;
  25566. /**
  25567. * The pixel array for the back face.
  25568. * This is stored in format, left to right, up to down format.
  25569. */
  25570. back: Nullable<ArrayBufferView>;
  25571. /**
  25572. * The pixel array for the left face.
  25573. * This is stored in format, left to right, up to down format.
  25574. */
  25575. left: Nullable<ArrayBufferView>;
  25576. /**
  25577. * The pixel array for the right face.
  25578. * This is stored in format, left to right, up to down format.
  25579. */
  25580. right: Nullable<ArrayBufferView>;
  25581. /**
  25582. * The pixel array for the up face.
  25583. * This is stored in format, left to right, up to down format.
  25584. */
  25585. up: Nullable<ArrayBufferView>;
  25586. /**
  25587. * The pixel array for the down face.
  25588. * This is stored in format, left to right, up to down format.
  25589. */
  25590. down: Nullable<ArrayBufferView>;
  25591. /**
  25592. * The size of the cubemap stored.
  25593. *
  25594. * Each faces will be size * size pixels.
  25595. */
  25596. size: number;
  25597. /**
  25598. * The format of the texture.
  25599. *
  25600. * RGBA, RGB.
  25601. */
  25602. format: number;
  25603. /**
  25604. * The type of the texture data.
  25605. *
  25606. * UNSIGNED_INT, FLOAT.
  25607. */
  25608. type: number;
  25609. /**
  25610. * Specifies whether the texture is in gamma space.
  25611. */
  25612. gammaSpace: boolean;
  25613. }
  25614. /**
  25615. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25616. */
  25617. export class PanoramaToCubeMapTools {
  25618. private static FACE_LEFT;
  25619. private static FACE_RIGHT;
  25620. private static FACE_FRONT;
  25621. private static FACE_BACK;
  25622. private static FACE_DOWN;
  25623. private static FACE_UP;
  25624. /**
  25625. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25626. *
  25627. * @param float32Array The source data.
  25628. * @param inputWidth The width of the input panorama.
  25629. * @param inputHeight The height of the input panorama.
  25630. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25631. * @return The cubemap data
  25632. */
  25633. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25634. private static CreateCubemapTexture;
  25635. private static CalcProjectionSpherical;
  25636. }
  25637. }
  25638. declare module BABYLON {
  25639. /**
  25640. * Helper class dealing with the extraction of spherical polynomial dataArray
  25641. * from a cube map.
  25642. */
  25643. export class CubeMapToSphericalPolynomialTools {
  25644. private static FileFaces;
  25645. /**
  25646. * Converts a texture to the according Spherical Polynomial data.
  25647. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25648. *
  25649. * @param texture The texture to extract the information from.
  25650. * @return The Spherical Polynomial data.
  25651. */
  25652. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25653. /**
  25654. * Converts a cubemap to the according Spherical Polynomial data.
  25655. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25656. *
  25657. * @param cubeInfo The Cube map to extract the information from.
  25658. * @return The Spherical Polynomial data.
  25659. */
  25660. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25661. }
  25662. }
  25663. declare module BABYLON {
  25664. interface BaseTexture {
  25665. /**
  25666. * Get the polynomial representation of the texture data.
  25667. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25668. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25669. */
  25670. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25671. }
  25672. }
  25673. declare module BABYLON {
  25674. /** @hidden */
  25675. export var pbrFragmentDeclaration: {
  25676. name: string;
  25677. shader: string;
  25678. };
  25679. }
  25680. declare module BABYLON {
  25681. /** @hidden */
  25682. export var pbrUboDeclaration: {
  25683. name: string;
  25684. shader: string;
  25685. };
  25686. }
  25687. declare module BABYLON {
  25688. /** @hidden */
  25689. export var pbrFragmentExtraDeclaration: {
  25690. name: string;
  25691. shader: string;
  25692. };
  25693. }
  25694. declare module BABYLON {
  25695. /** @hidden */
  25696. export var pbrFragmentSamplersDeclaration: {
  25697. name: string;
  25698. shader: string;
  25699. };
  25700. }
  25701. declare module BABYLON {
  25702. /** @hidden */
  25703. export var subSurfaceScatteringFunctions: {
  25704. name: string;
  25705. shader: string;
  25706. };
  25707. }
  25708. declare module BABYLON {
  25709. /** @hidden */
  25710. export var importanceSampling: {
  25711. name: string;
  25712. shader: string;
  25713. };
  25714. }
  25715. declare module BABYLON {
  25716. /** @hidden */
  25717. export var pbrHelperFunctions: {
  25718. name: string;
  25719. shader: string;
  25720. };
  25721. }
  25722. declare module BABYLON {
  25723. /** @hidden */
  25724. export var harmonicsFunctions: {
  25725. name: string;
  25726. shader: string;
  25727. };
  25728. }
  25729. declare module BABYLON {
  25730. /** @hidden */
  25731. export var pbrDirectLightingSetupFunctions: {
  25732. name: string;
  25733. shader: string;
  25734. };
  25735. }
  25736. declare module BABYLON {
  25737. /** @hidden */
  25738. export var pbrDirectLightingFalloffFunctions: {
  25739. name: string;
  25740. shader: string;
  25741. };
  25742. }
  25743. declare module BABYLON {
  25744. /** @hidden */
  25745. export var pbrBRDFFunctions: {
  25746. name: string;
  25747. shader: string;
  25748. };
  25749. }
  25750. declare module BABYLON {
  25751. /** @hidden */
  25752. export var hdrFilteringFunctions: {
  25753. name: string;
  25754. shader: string;
  25755. };
  25756. }
  25757. declare module BABYLON {
  25758. /** @hidden */
  25759. export var pbrDirectLightingFunctions: {
  25760. name: string;
  25761. shader: string;
  25762. };
  25763. }
  25764. declare module BABYLON {
  25765. /** @hidden */
  25766. export var pbrIBLFunctions: {
  25767. name: string;
  25768. shader: string;
  25769. };
  25770. }
  25771. declare module BABYLON {
  25772. /** @hidden */
  25773. export var pbrBlockAlbedoOpacity: {
  25774. name: string;
  25775. shader: string;
  25776. };
  25777. }
  25778. declare module BABYLON {
  25779. /** @hidden */
  25780. export var pbrBlockReflectivity: {
  25781. name: string;
  25782. shader: string;
  25783. };
  25784. }
  25785. declare module BABYLON {
  25786. /** @hidden */
  25787. export var pbrBlockAmbientOcclusion: {
  25788. name: string;
  25789. shader: string;
  25790. };
  25791. }
  25792. declare module BABYLON {
  25793. /** @hidden */
  25794. export var pbrBlockAlphaFresnel: {
  25795. name: string;
  25796. shader: string;
  25797. };
  25798. }
  25799. declare module BABYLON {
  25800. /** @hidden */
  25801. export var pbrBlockAnisotropic: {
  25802. name: string;
  25803. shader: string;
  25804. };
  25805. }
  25806. declare module BABYLON {
  25807. /** @hidden */
  25808. export var pbrBlockReflection: {
  25809. name: string;
  25810. shader: string;
  25811. };
  25812. }
  25813. declare module BABYLON {
  25814. /** @hidden */
  25815. export var pbrBlockSheen: {
  25816. name: string;
  25817. shader: string;
  25818. };
  25819. }
  25820. declare module BABYLON {
  25821. /** @hidden */
  25822. export var pbrBlockClearcoat: {
  25823. name: string;
  25824. shader: string;
  25825. };
  25826. }
  25827. declare module BABYLON {
  25828. /** @hidden */
  25829. export var pbrBlockSubSurface: {
  25830. name: string;
  25831. shader: string;
  25832. };
  25833. }
  25834. declare module BABYLON {
  25835. /** @hidden */
  25836. export var pbrBlockNormalGeometric: {
  25837. name: string;
  25838. shader: string;
  25839. };
  25840. }
  25841. declare module BABYLON {
  25842. /** @hidden */
  25843. export var pbrBlockNormalFinal: {
  25844. name: string;
  25845. shader: string;
  25846. };
  25847. }
  25848. declare module BABYLON {
  25849. /** @hidden */
  25850. export var pbrBlockLightmapInit: {
  25851. name: string;
  25852. shader: string;
  25853. };
  25854. }
  25855. declare module BABYLON {
  25856. /** @hidden */
  25857. export var pbrBlockGeometryInfo: {
  25858. name: string;
  25859. shader: string;
  25860. };
  25861. }
  25862. declare module BABYLON {
  25863. /** @hidden */
  25864. export var pbrBlockReflectance0: {
  25865. name: string;
  25866. shader: string;
  25867. };
  25868. }
  25869. declare module BABYLON {
  25870. /** @hidden */
  25871. export var pbrBlockReflectance: {
  25872. name: string;
  25873. shader: string;
  25874. };
  25875. }
  25876. declare module BABYLON {
  25877. /** @hidden */
  25878. export var pbrBlockDirectLighting: {
  25879. name: string;
  25880. shader: string;
  25881. };
  25882. }
  25883. declare module BABYLON {
  25884. /** @hidden */
  25885. export var pbrBlockFinalLitComponents: {
  25886. name: string;
  25887. shader: string;
  25888. };
  25889. }
  25890. declare module BABYLON {
  25891. /** @hidden */
  25892. export var pbrBlockFinalUnlitComponents: {
  25893. name: string;
  25894. shader: string;
  25895. };
  25896. }
  25897. declare module BABYLON {
  25898. /** @hidden */
  25899. export var pbrBlockFinalColorComposition: {
  25900. name: string;
  25901. shader: string;
  25902. };
  25903. }
  25904. declare module BABYLON {
  25905. /** @hidden */
  25906. export var pbrBlockImageProcessing: {
  25907. name: string;
  25908. shader: string;
  25909. };
  25910. }
  25911. declare module BABYLON {
  25912. /** @hidden */
  25913. export var pbrDebug: {
  25914. name: string;
  25915. shader: string;
  25916. };
  25917. }
  25918. declare module BABYLON {
  25919. /** @hidden */
  25920. export var pbrPixelShader: {
  25921. name: string;
  25922. shader: string;
  25923. };
  25924. }
  25925. declare module BABYLON {
  25926. /** @hidden */
  25927. export var pbrVertexDeclaration: {
  25928. name: string;
  25929. shader: string;
  25930. };
  25931. }
  25932. declare module BABYLON {
  25933. /** @hidden */
  25934. export var pbrVertexShader: {
  25935. name: string;
  25936. shader: string;
  25937. };
  25938. }
  25939. declare module BABYLON {
  25940. /**
  25941. * Manages the defines for the PBR Material.
  25942. * @hidden
  25943. */
  25944. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  25945. PBR: boolean;
  25946. NUM_SAMPLES: string;
  25947. REALTIME_FILTERING: boolean;
  25948. MAINUV1: boolean;
  25949. MAINUV2: boolean;
  25950. UV1: boolean;
  25951. UV2: boolean;
  25952. ALBEDO: boolean;
  25953. GAMMAALBEDO: boolean;
  25954. ALBEDODIRECTUV: number;
  25955. VERTEXCOLOR: boolean;
  25956. DETAIL: boolean;
  25957. DETAILDIRECTUV: number;
  25958. DETAIL_NORMALBLENDMETHOD: number;
  25959. AMBIENT: boolean;
  25960. AMBIENTDIRECTUV: number;
  25961. AMBIENTINGRAYSCALE: boolean;
  25962. OPACITY: boolean;
  25963. VERTEXALPHA: boolean;
  25964. OPACITYDIRECTUV: number;
  25965. OPACITYRGB: boolean;
  25966. ALPHATEST: boolean;
  25967. DEPTHPREPASS: boolean;
  25968. ALPHABLEND: boolean;
  25969. ALPHAFROMALBEDO: boolean;
  25970. ALPHATESTVALUE: string;
  25971. SPECULAROVERALPHA: boolean;
  25972. RADIANCEOVERALPHA: boolean;
  25973. ALPHAFRESNEL: boolean;
  25974. LINEARALPHAFRESNEL: boolean;
  25975. PREMULTIPLYALPHA: boolean;
  25976. EMISSIVE: boolean;
  25977. EMISSIVEDIRECTUV: number;
  25978. REFLECTIVITY: boolean;
  25979. REFLECTIVITYDIRECTUV: number;
  25980. SPECULARTERM: boolean;
  25981. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  25982. MICROSURFACEAUTOMATIC: boolean;
  25983. LODBASEDMICROSFURACE: boolean;
  25984. MICROSURFACEMAP: boolean;
  25985. MICROSURFACEMAPDIRECTUV: number;
  25986. METALLICWORKFLOW: boolean;
  25987. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  25988. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  25989. METALLNESSSTOREINMETALMAPBLUE: boolean;
  25990. AOSTOREINMETALMAPRED: boolean;
  25991. METALLIC_REFLECTANCE: boolean;
  25992. METALLIC_REFLECTANCEDIRECTUV: number;
  25993. ENVIRONMENTBRDF: boolean;
  25994. ENVIRONMENTBRDF_RGBD: boolean;
  25995. NORMAL: boolean;
  25996. TANGENT: boolean;
  25997. BUMP: boolean;
  25998. BUMPDIRECTUV: number;
  25999. OBJECTSPACE_NORMALMAP: boolean;
  26000. PARALLAX: boolean;
  26001. PARALLAXOCCLUSION: boolean;
  26002. NORMALXYSCALE: boolean;
  26003. LIGHTMAP: boolean;
  26004. LIGHTMAPDIRECTUV: number;
  26005. USELIGHTMAPASSHADOWMAP: boolean;
  26006. GAMMALIGHTMAP: boolean;
  26007. RGBDLIGHTMAP: boolean;
  26008. REFLECTION: boolean;
  26009. REFLECTIONMAP_3D: boolean;
  26010. REFLECTIONMAP_SPHERICAL: boolean;
  26011. REFLECTIONMAP_PLANAR: boolean;
  26012. REFLECTIONMAP_CUBIC: boolean;
  26013. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26014. REFLECTIONMAP_PROJECTION: boolean;
  26015. REFLECTIONMAP_SKYBOX: boolean;
  26016. REFLECTIONMAP_EXPLICIT: boolean;
  26017. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26018. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26019. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26020. INVERTCUBICMAP: boolean;
  26021. USESPHERICALFROMREFLECTIONMAP: boolean;
  26022. USEIRRADIANCEMAP: boolean;
  26023. SPHERICAL_HARMONICS: boolean;
  26024. USESPHERICALINVERTEX: boolean;
  26025. REFLECTIONMAP_OPPOSITEZ: boolean;
  26026. LODINREFLECTIONALPHA: boolean;
  26027. GAMMAREFLECTION: boolean;
  26028. RGBDREFLECTION: boolean;
  26029. LINEARSPECULARREFLECTION: boolean;
  26030. RADIANCEOCCLUSION: boolean;
  26031. HORIZONOCCLUSION: boolean;
  26032. INSTANCES: boolean;
  26033. THIN_INSTANCES: boolean;
  26034. PREPASS: boolean;
  26035. PREPASS_IRRADIANCE: boolean;
  26036. PREPASS_IRRADIANCE_INDEX: number;
  26037. PREPASS_ALBEDO: boolean;
  26038. PREPASS_ALBEDO_INDEX: number;
  26039. PREPASS_DEPTHNORMAL: boolean;
  26040. PREPASS_DEPTHNORMAL_INDEX: number;
  26041. PREPASS_POSITION: boolean;
  26042. PREPASS_POSITION_INDEX: number;
  26043. PREPASS_VELOCITY: boolean;
  26044. PREPASS_VELOCITY_INDEX: number;
  26045. PREPASS_REFLECTIVITY: boolean;
  26046. PREPASS_REFLECTIVITY_INDEX: number;
  26047. SCENE_MRT_COUNT: number;
  26048. NUM_BONE_INFLUENCERS: number;
  26049. BonesPerMesh: number;
  26050. BONETEXTURE: boolean;
  26051. BONES_VELOCITY_ENABLED: boolean;
  26052. NONUNIFORMSCALING: boolean;
  26053. MORPHTARGETS: boolean;
  26054. MORPHTARGETS_NORMAL: boolean;
  26055. MORPHTARGETS_TANGENT: boolean;
  26056. MORPHTARGETS_UV: boolean;
  26057. NUM_MORPH_INFLUENCERS: number;
  26058. IMAGEPROCESSING: boolean;
  26059. VIGNETTE: boolean;
  26060. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26061. VIGNETTEBLENDMODEOPAQUE: boolean;
  26062. TONEMAPPING: boolean;
  26063. TONEMAPPING_ACES: boolean;
  26064. CONTRAST: boolean;
  26065. COLORCURVES: boolean;
  26066. COLORGRADING: boolean;
  26067. COLORGRADING3D: boolean;
  26068. SAMPLER3DGREENDEPTH: boolean;
  26069. SAMPLER3DBGRMAP: boolean;
  26070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26071. EXPOSURE: boolean;
  26072. MULTIVIEW: boolean;
  26073. USEPHYSICALLIGHTFALLOFF: boolean;
  26074. USEGLTFLIGHTFALLOFF: boolean;
  26075. TWOSIDEDLIGHTING: boolean;
  26076. SHADOWFLOAT: boolean;
  26077. CLIPPLANE: boolean;
  26078. CLIPPLANE2: boolean;
  26079. CLIPPLANE3: boolean;
  26080. CLIPPLANE4: boolean;
  26081. CLIPPLANE5: boolean;
  26082. CLIPPLANE6: boolean;
  26083. POINTSIZE: boolean;
  26084. FOG: boolean;
  26085. LOGARITHMICDEPTH: boolean;
  26086. FORCENORMALFORWARD: boolean;
  26087. SPECULARAA: boolean;
  26088. CLEARCOAT: boolean;
  26089. CLEARCOAT_DEFAULTIOR: boolean;
  26090. CLEARCOAT_TEXTURE: boolean;
  26091. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26092. CLEARCOAT_TEXTUREDIRECTUV: number;
  26093. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26094. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26095. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26096. CLEARCOAT_BUMP: boolean;
  26097. CLEARCOAT_BUMPDIRECTUV: number;
  26098. CLEARCOAT_REMAP_F0: boolean;
  26099. CLEARCOAT_TINT: boolean;
  26100. CLEARCOAT_TINT_TEXTURE: boolean;
  26101. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26102. ANISOTROPIC: boolean;
  26103. ANISOTROPIC_TEXTURE: boolean;
  26104. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26105. BRDF_V_HEIGHT_CORRELATED: boolean;
  26106. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26107. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26108. SHEEN: boolean;
  26109. SHEEN_TEXTURE: boolean;
  26110. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26111. SHEEN_TEXTUREDIRECTUV: number;
  26112. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26113. SHEEN_LINKWITHALBEDO: boolean;
  26114. SHEEN_ROUGHNESS: boolean;
  26115. SHEEN_ALBEDOSCALING: boolean;
  26116. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26117. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26118. SUBSURFACE: boolean;
  26119. SS_REFRACTION: boolean;
  26120. SS_TRANSLUCENCY: boolean;
  26121. SS_SCATTERING: boolean;
  26122. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26123. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26124. SS_REFRACTIONMAP_3D: boolean;
  26125. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26126. SS_LODINREFRACTIONALPHA: boolean;
  26127. SS_GAMMAREFRACTION: boolean;
  26128. SS_RGBDREFRACTION: boolean;
  26129. SS_LINEARSPECULARREFRACTION: boolean;
  26130. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26131. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26132. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26133. UNLIT: boolean;
  26134. DEBUGMODE: number;
  26135. /**
  26136. * Initializes the PBR Material defines.
  26137. */
  26138. constructor();
  26139. /**
  26140. * Resets the PBR Material defines.
  26141. */
  26142. reset(): void;
  26143. }
  26144. /**
  26145. * The Physically based material base class of BJS.
  26146. *
  26147. * This offers the main features of a standard PBR material.
  26148. * For more information, please refer to the documentation :
  26149. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26150. */
  26151. export abstract class PBRBaseMaterial extends PushMaterial {
  26152. /**
  26153. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26154. */
  26155. static readonly PBRMATERIAL_OPAQUE: number;
  26156. /**
  26157. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26158. */
  26159. static readonly PBRMATERIAL_ALPHATEST: number;
  26160. /**
  26161. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26162. */
  26163. static readonly PBRMATERIAL_ALPHABLEND: number;
  26164. /**
  26165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26166. * They are also discarded below the alpha cutoff threshold to improve performances.
  26167. */
  26168. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26169. /**
  26170. * Defines the default value of how much AO map is occluding the analytical lights
  26171. * (point spot...).
  26172. */
  26173. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26174. /**
  26175. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26176. */
  26177. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26178. /**
  26179. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26180. * to enhance interoperability with other engines.
  26181. */
  26182. static readonly LIGHTFALLOFF_GLTF: number;
  26183. /**
  26184. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26185. * to enhance interoperability with other materials.
  26186. */
  26187. static readonly LIGHTFALLOFF_STANDARD: number;
  26188. /**
  26189. * Intensity of the direct lights e.g. the four lights available in your scene.
  26190. * This impacts both the direct diffuse and specular highlights.
  26191. */
  26192. protected _directIntensity: number;
  26193. /**
  26194. * Intensity of the emissive part of the material.
  26195. * This helps controlling the emissive effect without modifying the emissive color.
  26196. */
  26197. protected _emissiveIntensity: number;
  26198. /**
  26199. * Intensity of the environment e.g. how much the environment will light the object
  26200. * either through harmonics for rough material or through the refelction for shiny ones.
  26201. */
  26202. protected _environmentIntensity: number;
  26203. /**
  26204. * This is a special control allowing the reduction of the specular highlights coming from the
  26205. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26206. */
  26207. protected _specularIntensity: number;
  26208. /**
  26209. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26210. */
  26211. private _lightingInfos;
  26212. /**
  26213. * Debug Control allowing disabling the bump map on this material.
  26214. */
  26215. protected _disableBumpMap: boolean;
  26216. /**
  26217. * AKA Diffuse Texture in standard nomenclature.
  26218. */
  26219. protected _albedoTexture: Nullable<BaseTexture>;
  26220. /**
  26221. * AKA Occlusion Texture in other nomenclature.
  26222. */
  26223. protected _ambientTexture: Nullable<BaseTexture>;
  26224. /**
  26225. * AKA Occlusion Texture Intensity in other nomenclature.
  26226. */
  26227. protected _ambientTextureStrength: number;
  26228. /**
  26229. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26230. * 1 means it completely occludes it
  26231. * 0 mean it has no impact
  26232. */
  26233. protected _ambientTextureImpactOnAnalyticalLights: number;
  26234. /**
  26235. * Stores the alpha values in a texture.
  26236. */
  26237. protected _opacityTexture: Nullable<BaseTexture>;
  26238. /**
  26239. * Stores the reflection values in a texture.
  26240. */
  26241. protected _reflectionTexture: Nullable<BaseTexture>;
  26242. /**
  26243. * Stores the emissive values in a texture.
  26244. */
  26245. protected _emissiveTexture: Nullable<BaseTexture>;
  26246. /**
  26247. * AKA Specular texture in other nomenclature.
  26248. */
  26249. protected _reflectivityTexture: Nullable<BaseTexture>;
  26250. /**
  26251. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26252. */
  26253. protected _metallicTexture: Nullable<BaseTexture>;
  26254. /**
  26255. * Specifies the metallic scalar of the metallic/roughness workflow.
  26256. * Can also be used to scale the metalness values of the metallic texture.
  26257. */
  26258. protected _metallic: Nullable<number>;
  26259. /**
  26260. * Specifies the roughness scalar of the metallic/roughness workflow.
  26261. * Can also be used to scale the roughness values of the metallic texture.
  26262. */
  26263. protected _roughness: Nullable<number>;
  26264. /**
  26265. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26266. * By default the indexOfrefraction is used to compute F0;
  26267. *
  26268. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26269. *
  26270. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26271. * F90 = metallicReflectanceColor;
  26272. */
  26273. protected _metallicF0Factor: number;
  26274. /**
  26275. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26276. * By default the F90 is always 1;
  26277. *
  26278. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26279. *
  26280. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26281. * F90 = metallicReflectanceColor;
  26282. */
  26283. protected _metallicReflectanceColor: Color3;
  26284. /**
  26285. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26286. * This is multiply against the scalar values defined in the material.
  26287. */
  26288. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26289. /**
  26290. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26291. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26292. */
  26293. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26294. /**
  26295. * Stores surface normal data used to displace a mesh in a texture.
  26296. */
  26297. protected _bumpTexture: Nullable<BaseTexture>;
  26298. /**
  26299. * Stores the pre-calculated light information of a mesh in a texture.
  26300. */
  26301. protected _lightmapTexture: Nullable<BaseTexture>;
  26302. /**
  26303. * The color of a material in ambient lighting.
  26304. */
  26305. protected _ambientColor: Color3;
  26306. /**
  26307. * AKA Diffuse Color in other nomenclature.
  26308. */
  26309. protected _albedoColor: Color3;
  26310. /**
  26311. * AKA Specular Color in other nomenclature.
  26312. */
  26313. protected _reflectivityColor: Color3;
  26314. /**
  26315. * The color applied when light is reflected from a material.
  26316. */
  26317. protected _reflectionColor: Color3;
  26318. /**
  26319. * The color applied when light is emitted from a material.
  26320. */
  26321. protected _emissiveColor: Color3;
  26322. /**
  26323. * AKA Glossiness in other nomenclature.
  26324. */
  26325. protected _microSurface: number;
  26326. /**
  26327. * Specifies that the material will use the light map as a show map.
  26328. */
  26329. protected _useLightmapAsShadowmap: boolean;
  26330. /**
  26331. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26332. * makes the reflect vector face the model (under horizon).
  26333. */
  26334. protected _useHorizonOcclusion: boolean;
  26335. /**
  26336. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26337. * too much the area relying on ambient texture to define their ambient occlusion.
  26338. */
  26339. protected _useRadianceOcclusion: boolean;
  26340. /**
  26341. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26342. */
  26343. protected _useAlphaFromAlbedoTexture: boolean;
  26344. /**
  26345. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26346. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26347. */
  26348. protected _useSpecularOverAlpha: boolean;
  26349. /**
  26350. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26351. */
  26352. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26353. /**
  26354. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26355. */
  26356. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26357. /**
  26358. * Specifies if the metallic texture contains the roughness information in its green channel.
  26359. */
  26360. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26361. /**
  26362. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26363. */
  26364. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26365. /**
  26366. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26367. */
  26368. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26369. /**
  26370. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26371. */
  26372. protected _useAmbientInGrayScale: boolean;
  26373. /**
  26374. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26375. * The material will try to infer what glossiness each pixel should be.
  26376. */
  26377. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26378. /**
  26379. * Defines the falloff type used in this material.
  26380. * It by default is Physical.
  26381. */
  26382. protected _lightFalloff: number;
  26383. /**
  26384. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26385. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26386. */
  26387. protected _useRadianceOverAlpha: boolean;
  26388. /**
  26389. * Allows using an object space normal map (instead of tangent space).
  26390. */
  26391. protected _useObjectSpaceNormalMap: boolean;
  26392. /**
  26393. * Allows using the bump map in parallax mode.
  26394. */
  26395. protected _useParallax: boolean;
  26396. /**
  26397. * Allows using the bump map in parallax occlusion mode.
  26398. */
  26399. protected _useParallaxOcclusion: boolean;
  26400. /**
  26401. * Controls the scale bias of the parallax mode.
  26402. */
  26403. protected _parallaxScaleBias: number;
  26404. /**
  26405. * If sets to true, disables all the lights affecting the material.
  26406. */
  26407. protected _disableLighting: boolean;
  26408. /**
  26409. * Number of Simultaneous lights allowed on the material.
  26410. */
  26411. protected _maxSimultaneousLights: number;
  26412. /**
  26413. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26414. */
  26415. protected _invertNormalMapX: boolean;
  26416. /**
  26417. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26418. */
  26419. protected _invertNormalMapY: boolean;
  26420. /**
  26421. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26422. */
  26423. protected _twoSidedLighting: boolean;
  26424. /**
  26425. * Defines the alpha limits in alpha test mode.
  26426. */
  26427. protected _alphaCutOff: number;
  26428. /**
  26429. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26430. */
  26431. protected _forceAlphaTest: boolean;
  26432. /**
  26433. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26434. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26435. */
  26436. protected _useAlphaFresnel: boolean;
  26437. /**
  26438. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26439. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26440. */
  26441. protected _useLinearAlphaFresnel: boolean;
  26442. /**
  26443. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26444. * from cos thetav and roughness:
  26445. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26446. */
  26447. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26448. /**
  26449. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26450. */
  26451. protected _forceIrradianceInFragment: boolean;
  26452. private _realTimeFiltering;
  26453. /**
  26454. * Enables realtime filtering on the texture.
  26455. */
  26456. get realTimeFiltering(): boolean;
  26457. set realTimeFiltering(b: boolean);
  26458. private _realTimeFilteringQuality;
  26459. /**
  26460. * Quality switch for realtime filtering
  26461. */
  26462. get realTimeFilteringQuality(): number;
  26463. set realTimeFilteringQuality(n: number);
  26464. /**
  26465. * Can this material render to several textures at once
  26466. */
  26467. get canRenderToMRT(): boolean;
  26468. /**
  26469. * Force normal to face away from face.
  26470. */
  26471. protected _forceNormalForward: boolean;
  26472. /**
  26473. * Enables specular anti aliasing in the PBR shader.
  26474. * It will both interacts on the Geometry for analytical and IBL lighting.
  26475. * It also prefilter the roughness map based on the bump values.
  26476. */
  26477. protected _enableSpecularAntiAliasing: boolean;
  26478. /**
  26479. * Default configuration related to image processing available in the PBR Material.
  26480. */
  26481. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26482. /**
  26483. * Keep track of the image processing observer to allow dispose and replace.
  26484. */
  26485. private _imageProcessingObserver;
  26486. /**
  26487. * Attaches a new image processing configuration to the PBR Material.
  26488. * @param configuration
  26489. */
  26490. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26491. /**
  26492. * Stores the available render targets.
  26493. */
  26494. private _renderTargets;
  26495. /**
  26496. * Sets the global ambient color for the material used in lighting calculations.
  26497. */
  26498. private _globalAmbientColor;
  26499. /**
  26500. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26501. */
  26502. private _useLogarithmicDepth;
  26503. /**
  26504. * If set to true, no lighting calculations will be applied.
  26505. */
  26506. private _unlit;
  26507. private _debugMode;
  26508. /**
  26509. * @hidden
  26510. * This is reserved for the inspector.
  26511. * Defines the material debug mode.
  26512. * It helps seeing only some components of the material while troubleshooting.
  26513. */
  26514. debugMode: number;
  26515. /**
  26516. * @hidden
  26517. * This is reserved for the inspector.
  26518. * Specify from where on screen the debug mode should start.
  26519. * The value goes from -1 (full screen) to 1 (not visible)
  26520. * It helps with side by side comparison against the final render
  26521. * This defaults to -1
  26522. */
  26523. private debugLimit;
  26524. /**
  26525. * @hidden
  26526. * This is reserved for the inspector.
  26527. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26528. * You can use the factor to better multiply the final value.
  26529. */
  26530. private debugFactor;
  26531. /**
  26532. * Defines the clear coat layer parameters for the material.
  26533. */
  26534. readonly clearCoat: PBRClearCoatConfiguration;
  26535. /**
  26536. * Defines the anisotropic parameters for the material.
  26537. */
  26538. readonly anisotropy: PBRAnisotropicConfiguration;
  26539. /**
  26540. * Defines the BRDF parameters for the material.
  26541. */
  26542. readonly brdf: PBRBRDFConfiguration;
  26543. /**
  26544. * Defines the Sheen parameters for the material.
  26545. */
  26546. readonly sheen: PBRSheenConfiguration;
  26547. /**
  26548. * Defines the SubSurface parameters for the material.
  26549. */
  26550. readonly subSurface: PBRSubSurfaceConfiguration;
  26551. /**
  26552. * Defines additionnal PrePass parameters for the material.
  26553. */
  26554. readonly prePassConfiguration: PrePassConfiguration;
  26555. /**
  26556. * Defines the detail map parameters for the material.
  26557. */
  26558. readonly detailMap: DetailMapConfiguration;
  26559. protected _rebuildInParallel: boolean;
  26560. /**
  26561. * Instantiates a new PBRMaterial instance.
  26562. *
  26563. * @param name The material name
  26564. * @param scene The scene the material will be use in.
  26565. */
  26566. constructor(name: string, scene: Scene);
  26567. /**
  26568. * Gets a boolean indicating that current material needs to register RTT
  26569. */
  26570. get hasRenderTargetTextures(): boolean;
  26571. /**
  26572. * Gets the name of the material class.
  26573. */
  26574. getClassName(): string;
  26575. /**
  26576. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26577. */
  26578. get useLogarithmicDepth(): boolean;
  26579. /**
  26580. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26581. */
  26582. set useLogarithmicDepth(value: boolean);
  26583. /**
  26584. * Returns true if alpha blending should be disabled.
  26585. */
  26586. protected get _disableAlphaBlending(): boolean;
  26587. /**
  26588. * Specifies whether or not this material should be rendered in alpha blend mode.
  26589. */
  26590. needAlphaBlending(): boolean;
  26591. /**
  26592. * Specifies whether or not this material should be rendered in alpha test mode.
  26593. */
  26594. needAlphaTesting(): boolean;
  26595. /**
  26596. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26597. */
  26598. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26599. /**
  26600. * Specifies whether or not there is a usable alpha channel for transparency.
  26601. */
  26602. protected _hasAlphaChannel(): boolean;
  26603. /**
  26604. * Gets the texture used for the alpha test.
  26605. */
  26606. getAlphaTestTexture(): Nullable<BaseTexture>;
  26607. /**
  26608. * Specifies that the submesh is ready to be used.
  26609. * @param mesh - BJS mesh.
  26610. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26611. * @param useInstances - Specifies that instances should be used.
  26612. * @returns - boolean indicating that the submesh is ready or not.
  26613. */
  26614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26615. /**
  26616. * Specifies if the material uses metallic roughness workflow.
  26617. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26618. */
  26619. isMetallicWorkflow(): boolean;
  26620. private _prepareEffect;
  26621. private _prepareDefines;
  26622. /**
  26623. * Force shader compilation
  26624. */
  26625. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26626. /**
  26627. * Initializes the uniform buffer layout for the shader.
  26628. */
  26629. buildUniformLayout(): void;
  26630. /**
  26631. * Unbinds the material from the mesh
  26632. */
  26633. unbind(): void;
  26634. /**
  26635. * Binds the submesh data.
  26636. * @param world - The world matrix.
  26637. * @param mesh - The BJS mesh.
  26638. * @param subMesh - A submesh of the BJS mesh.
  26639. */
  26640. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26641. /**
  26642. * Returns the animatable textures.
  26643. * @returns - Array of animatable textures.
  26644. */
  26645. getAnimatables(): IAnimatable[];
  26646. /**
  26647. * Returns the texture used for reflections.
  26648. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26649. */
  26650. private _getReflectionTexture;
  26651. /**
  26652. * Returns an array of the actively used textures.
  26653. * @returns - Array of BaseTextures
  26654. */
  26655. getActiveTextures(): BaseTexture[];
  26656. /**
  26657. * Checks to see if a texture is used in the material.
  26658. * @param texture - Base texture to use.
  26659. * @returns - Boolean specifying if a texture is used in the material.
  26660. */
  26661. hasTexture(texture: BaseTexture): boolean;
  26662. /**
  26663. * Sets the required values to the prepass renderer.
  26664. * @param prePassRenderer defines the prepass renderer to setup
  26665. */
  26666. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26667. /**
  26668. * Disposes the resources of the material.
  26669. * @param forceDisposeEffect - Forces the disposal of effects.
  26670. * @param forceDisposeTextures - Forces the disposal of all textures.
  26671. */
  26672. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26673. }
  26674. }
  26675. declare module BABYLON {
  26676. /**
  26677. * The Physically based material of BJS.
  26678. *
  26679. * This offers the main features of a standard PBR material.
  26680. * For more information, please refer to the documentation :
  26681. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26682. */
  26683. export class PBRMaterial extends PBRBaseMaterial {
  26684. /**
  26685. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26686. */
  26687. static readonly PBRMATERIAL_OPAQUE: number;
  26688. /**
  26689. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26690. */
  26691. static readonly PBRMATERIAL_ALPHATEST: number;
  26692. /**
  26693. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26694. */
  26695. static readonly PBRMATERIAL_ALPHABLEND: number;
  26696. /**
  26697. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26698. * They are also discarded below the alpha cutoff threshold to improve performances.
  26699. */
  26700. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26701. /**
  26702. * Defines the default value of how much AO map is occluding the analytical lights
  26703. * (point spot...).
  26704. */
  26705. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26706. /**
  26707. * Intensity of the direct lights e.g. the four lights available in your scene.
  26708. * This impacts both the direct diffuse and specular highlights.
  26709. */
  26710. directIntensity: number;
  26711. /**
  26712. * Intensity of the emissive part of the material.
  26713. * This helps controlling the emissive effect without modifying the emissive color.
  26714. */
  26715. emissiveIntensity: number;
  26716. /**
  26717. * Intensity of the environment e.g. how much the environment will light the object
  26718. * either through harmonics for rough material or through the refelction for shiny ones.
  26719. */
  26720. environmentIntensity: number;
  26721. /**
  26722. * This is a special control allowing the reduction of the specular highlights coming from the
  26723. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26724. */
  26725. specularIntensity: number;
  26726. /**
  26727. * Debug Control allowing disabling the bump map on this material.
  26728. */
  26729. disableBumpMap: boolean;
  26730. /**
  26731. * AKA Diffuse Texture in standard nomenclature.
  26732. */
  26733. albedoTexture: BaseTexture;
  26734. /**
  26735. * AKA Occlusion Texture in other nomenclature.
  26736. */
  26737. ambientTexture: BaseTexture;
  26738. /**
  26739. * AKA Occlusion Texture Intensity in other nomenclature.
  26740. */
  26741. ambientTextureStrength: number;
  26742. /**
  26743. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26744. * 1 means it completely occludes it
  26745. * 0 mean it has no impact
  26746. */
  26747. ambientTextureImpactOnAnalyticalLights: number;
  26748. /**
  26749. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  26750. */
  26751. opacityTexture: BaseTexture;
  26752. /**
  26753. * Stores the reflection values in a texture.
  26754. */
  26755. reflectionTexture: Nullable<BaseTexture>;
  26756. /**
  26757. * Stores the emissive values in a texture.
  26758. */
  26759. emissiveTexture: BaseTexture;
  26760. /**
  26761. * AKA Specular texture in other nomenclature.
  26762. */
  26763. reflectivityTexture: BaseTexture;
  26764. /**
  26765. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26766. */
  26767. metallicTexture: BaseTexture;
  26768. /**
  26769. * Specifies the metallic scalar of the metallic/roughness workflow.
  26770. * Can also be used to scale the metalness values of the metallic texture.
  26771. */
  26772. metallic: Nullable<number>;
  26773. /**
  26774. * Specifies the roughness scalar of the metallic/roughness workflow.
  26775. * Can also be used to scale the roughness values of the metallic texture.
  26776. */
  26777. roughness: Nullable<number>;
  26778. /**
  26779. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26780. * By default the indexOfrefraction is used to compute F0;
  26781. *
  26782. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26783. *
  26784. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26785. * F90 = metallicReflectanceColor;
  26786. */
  26787. metallicF0Factor: number;
  26788. /**
  26789. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26790. * By default the F90 is always 1;
  26791. *
  26792. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26793. *
  26794. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26795. * F90 = metallicReflectanceColor;
  26796. */
  26797. metallicReflectanceColor: Color3;
  26798. /**
  26799. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26800. * This is multiply against the scalar values defined in the material.
  26801. */
  26802. metallicReflectanceTexture: Nullable<BaseTexture>;
  26803. /**
  26804. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26805. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26806. */
  26807. microSurfaceTexture: BaseTexture;
  26808. /**
  26809. * Stores surface normal data used to displace a mesh in a texture.
  26810. */
  26811. bumpTexture: BaseTexture;
  26812. /**
  26813. * Stores the pre-calculated light information of a mesh in a texture.
  26814. */
  26815. lightmapTexture: BaseTexture;
  26816. /**
  26817. * Stores the refracted light information in a texture.
  26818. */
  26819. get refractionTexture(): Nullable<BaseTexture>;
  26820. set refractionTexture(value: Nullable<BaseTexture>);
  26821. /**
  26822. * The color of a material in ambient lighting.
  26823. */
  26824. ambientColor: Color3;
  26825. /**
  26826. * AKA Diffuse Color in other nomenclature.
  26827. */
  26828. albedoColor: Color3;
  26829. /**
  26830. * AKA Specular Color in other nomenclature.
  26831. */
  26832. reflectivityColor: Color3;
  26833. /**
  26834. * The color reflected from the material.
  26835. */
  26836. reflectionColor: Color3;
  26837. /**
  26838. * The color emitted from the material.
  26839. */
  26840. emissiveColor: Color3;
  26841. /**
  26842. * AKA Glossiness in other nomenclature.
  26843. */
  26844. microSurface: number;
  26845. /**
  26846. * Index of refraction of the material base layer.
  26847. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26848. *
  26849. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26850. *
  26851. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26852. */
  26853. get indexOfRefraction(): number;
  26854. set indexOfRefraction(value: number);
  26855. /**
  26856. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26857. */
  26858. get invertRefractionY(): boolean;
  26859. set invertRefractionY(value: boolean);
  26860. /**
  26861. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26862. * Materials half opaque for instance using refraction could benefit from this control.
  26863. */
  26864. get linkRefractionWithTransparency(): boolean;
  26865. set linkRefractionWithTransparency(value: boolean);
  26866. /**
  26867. * If true, the light map contains occlusion information instead of lighting info.
  26868. */
  26869. useLightmapAsShadowmap: boolean;
  26870. /**
  26871. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26872. */
  26873. useAlphaFromAlbedoTexture: boolean;
  26874. /**
  26875. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26876. */
  26877. forceAlphaTest: boolean;
  26878. /**
  26879. * Defines the alpha limits in alpha test mode.
  26880. */
  26881. alphaCutOff: number;
  26882. /**
  26883. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26884. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26885. */
  26886. useSpecularOverAlpha: boolean;
  26887. /**
  26888. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26889. */
  26890. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26891. /**
  26892. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26893. */
  26894. useRoughnessFromMetallicTextureAlpha: boolean;
  26895. /**
  26896. * Specifies if the metallic texture contains the roughness information in its green channel.
  26897. */
  26898. useRoughnessFromMetallicTextureGreen: boolean;
  26899. /**
  26900. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26901. */
  26902. useMetallnessFromMetallicTextureBlue: boolean;
  26903. /**
  26904. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26905. */
  26906. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26907. /**
  26908. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26909. */
  26910. useAmbientInGrayScale: boolean;
  26911. /**
  26912. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26913. * The material will try to infer what glossiness each pixel should be.
  26914. */
  26915. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26916. /**
  26917. * BJS is using an harcoded light falloff based on a manually sets up range.
  26918. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26919. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26920. */
  26921. get usePhysicalLightFalloff(): 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. set usePhysicalLightFalloff(value: boolean);
  26928. /**
  26929. * In order to support the falloff compatibility with gltf, a special mode has been added
  26930. * to reproduce the gltf light falloff.
  26931. */
  26932. get useGLTFLightFalloff(): boolean;
  26933. /**
  26934. * In order to support the falloff compatibility with gltf, a special mode has been added
  26935. * to reproduce the gltf light falloff.
  26936. */
  26937. set useGLTFLightFalloff(value: boolean);
  26938. /**
  26939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26941. */
  26942. useRadianceOverAlpha: boolean;
  26943. /**
  26944. * Allows using an object space normal map (instead of tangent space).
  26945. */
  26946. useObjectSpaceNormalMap: boolean;
  26947. /**
  26948. * Allows using the bump map in parallax mode.
  26949. */
  26950. useParallax: boolean;
  26951. /**
  26952. * Allows using the bump map in parallax occlusion mode.
  26953. */
  26954. useParallaxOcclusion: boolean;
  26955. /**
  26956. * Controls the scale bias of the parallax mode.
  26957. */
  26958. parallaxScaleBias: number;
  26959. /**
  26960. * If sets to true, disables all the lights affecting the material.
  26961. */
  26962. disableLighting: boolean;
  26963. /**
  26964. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26965. */
  26966. forceIrradianceInFragment: boolean;
  26967. /**
  26968. * Number of Simultaneous lights allowed on the material.
  26969. */
  26970. maxSimultaneousLights: number;
  26971. /**
  26972. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26973. */
  26974. invertNormalMapX: boolean;
  26975. /**
  26976. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26977. */
  26978. invertNormalMapY: boolean;
  26979. /**
  26980. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26981. */
  26982. twoSidedLighting: boolean;
  26983. /**
  26984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26985. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26986. */
  26987. useAlphaFresnel: boolean;
  26988. /**
  26989. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26990. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26991. */
  26992. useLinearAlphaFresnel: boolean;
  26993. /**
  26994. * Let user defines the brdf lookup texture used for IBL.
  26995. * A default 8bit version is embedded but you could point at :
  26996. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  26997. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  26998. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  26999. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27000. */
  27001. environmentBRDFTexture: Nullable<BaseTexture>;
  27002. /**
  27003. * Force normal to face away from face.
  27004. */
  27005. forceNormalForward: boolean;
  27006. /**
  27007. * Enables specular anti aliasing in the PBR shader.
  27008. * It will both interacts on the Geometry for analytical and IBL lighting.
  27009. * It also prefilter the roughness map based on the bump values.
  27010. */
  27011. enableSpecularAntiAliasing: boolean;
  27012. /**
  27013. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27014. * makes the reflect vector face the model (under horizon).
  27015. */
  27016. useHorizonOcclusion: boolean;
  27017. /**
  27018. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27019. * too much the area relying on ambient texture to define their ambient occlusion.
  27020. */
  27021. useRadianceOcclusion: boolean;
  27022. /**
  27023. * If set to true, no lighting calculations will be applied.
  27024. */
  27025. unlit: boolean;
  27026. /**
  27027. * Gets the image processing configuration used either in this material.
  27028. */
  27029. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27030. /**
  27031. * Sets the Default image processing configuration used either in the this material.
  27032. *
  27033. * If sets to null, the scene one is in use.
  27034. */
  27035. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27036. /**
  27037. * Gets wether the color curves effect is enabled.
  27038. */
  27039. get cameraColorCurvesEnabled(): boolean;
  27040. /**
  27041. * Sets wether the color curves effect is enabled.
  27042. */
  27043. set cameraColorCurvesEnabled(value: boolean);
  27044. /**
  27045. * Gets wether the color grading effect is enabled.
  27046. */
  27047. get cameraColorGradingEnabled(): boolean;
  27048. /**
  27049. * Gets wether the color grading effect is enabled.
  27050. */
  27051. set cameraColorGradingEnabled(value: boolean);
  27052. /**
  27053. * Gets wether tonemapping is enabled or not.
  27054. */
  27055. get cameraToneMappingEnabled(): boolean;
  27056. /**
  27057. * Sets wether tonemapping is enabled or not
  27058. */
  27059. set cameraToneMappingEnabled(value: boolean);
  27060. /**
  27061. * The camera exposure used on this material.
  27062. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27063. * This corresponds to a photographic exposure.
  27064. */
  27065. get cameraExposure(): number;
  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. set cameraExposure(value: number);
  27072. /**
  27073. * Gets The camera contrast used on this material.
  27074. */
  27075. get cameraContrast(): number;
  27076. /**
  27077. * Sets The camera contrast used on this material.
  27078. */
  27079. set cameraContrast(value: number);
  27080. /**
  27081. * Gets the Color Grading 2D Lookup Texture.
  27082. */
  27083. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27084. /**
  27085. * Sets the Color Grading 2D Lookup Texture.
  27086. */
  27087. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27088. /**
  27089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27091. * 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;
  27092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27093. */
  27094. get cameraColorCurves(): Nullable<ColorCurves>;
  27095. /**
  27096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27098. * 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;
  27099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27100. */
  27101. set cameraColorCurves(value: Nullable<ColorCurves>);
  27102. /**
  27103. * Instantiates a new PBRMaterial instance.
  27104. *
  27105. * @param name The material name
  27106. * @param scene The scene the material will be use in.
  27107. */
  27108. constructor(name: string, scene: Scene);
  27109. /**
  27110. * Returns the name of this material class.
  27111. */
  27112. getClassName(): string;
  27113. /**
  27114. * Makes a duplicate of the current material.
  27115. * @param name - name to use for the new material.
  27116. */
  27117. clone(name: string): PBRMaterial;
  27118. /**
  27119. * Serializes this PBR Material.
  27120. * @returns - An object with the serialized material.
  27121. */
  27122. serialize(): any;
  27123. /**
  27124. * Parses a PBR Material from a serialized object.
  27125. * @param source - Serialized object.
  27126. * @param scene - BJS scene instance.
  27127. * @param rootUrl - url for the scene object
  27128. * @returns - PBRMaterial
  27129. */
  27130. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27131. }
  27132. }
  27133. declare module BABYLON {
  27134. /** @hidden */
  27135. export var mrtFragmentDeclaration: {
  27136. name: string;
  27137. shader: string;
  27138. };
  27139. }
  27140. declare module BABYLON {
  27141. /** @hidden */
  27142. export var geometryPixelShader: {
  27143. name: string;
  27144. shader: string;
  27145. };
  27146. }
  27147. declare module BABYLON {
  27148. /** @hidden */
  27149. export var geometryVertexShader: {
  27150. name: string;
  27151. shader: string;
  27152. };
  27153. }
  27154. declare module BABYLON {
  27155. /** @hidden */
  27156. interface ISavedTransformationMatrix {
  27157. world: Matrix;
  27158. viewProjection: Matrix;
  27159. }
  27160. /**
  27161. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27162. */
  27163. export class GeometryBufferRenderer {
  27164. /**
  27165. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27166. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27167. */
  27168. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27169. /**
  27170. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27171. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27172. */
  27173. static readonly POSITION_TEXTURE_TYPE: number;
  27174. /**
  27175. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27176. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27177. */
  27178. static readonly VELOCITY_TEXTURE_TYPE: number;
  27179. /**
  27180. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27181. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27182. */
  27183. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27184. /**
  27185. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27186. * in order to compute objects velocities when enableVelocity is set to "true"
  27187. * @hidden
  27188. */
  27189. _previousTransformationMatrices: {
  27190. [index: number]: ISavedTransformationMatrix;
  27191. };
  27192. /**
  27193. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27194. * in order to compute objects velocities when enableVelocity is set to "true"
  27195. * @hidden
  27196. */
  27197. _previousBonesTransformationMatrices: {
  27198. [index: number]: Float32Array;
  27199. };
  27200. /**
  27201. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27202. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27203. */
  27204. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27205. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27206. renderTransparentMeshes: boolean;
  27207. private _scene;
  27208. private _resizeObserver;
  27209. private _multiRenderTarget;
  27210. private _ratio;
  27211. private _enablePosition;
  27212. private _enableVelocity;
  27213. private _enableReflectivity;
  27214. private _positionIndex;
  27215. private _velocityIndex;
  27216. private _reflectivityIndex;
  27217. private _depthNormalIndex;
  27218. private _linkedWithPrePass;
  27219. private _prePassRenderer;
  27220. private _attachments;
  27221. protected _effect: Effect;
  27222. protected _cachedDefines: string;
  27223. /**
  27224. * @hidden
  27225. * Sets up internal structures to share outputs with PrePassRenderer
  27226. * This method should only be called by the PrePassRenderer itself
  27227. */
  27228. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27229. /**
  27230. * @hidden
  27231. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27232. * This method should only be called by the PrePassRenderer itself
  27233. */
  27234. _unlinkPrePassRenderer(): void;
  27235. /**
  27236. * @hidden
  27237. * Resets the geometry buffer layout
  27238. */
  27239. _resetLayout(): void;
  27240. /**
  27241. * @hidden
  27242. * Replaces a texture in the geometry buffer renderer
  27243. * Useful when linking textures of the prepass renderer
  27244. */
  27245. _forceTextureType(geometryBufferType: number, index: number): void;
  27246. /**
  27247. * @hidden
  27248. * Sets texture attachments
  27249. * Useful when linking textures of the prepass renderer
  27250. */
  27251. _setAttachments(attachments: number[]): void;
  27252. /**
  27253. * @hidden
  27254. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27255. * Useful when linking textures of the prepass renderer
  27256. */
  27257. _linkInternalTexture(internalTexture: InternalTexture): void;
  27258. /**
  27259. * Gets the render list (meshes to be rendered) used in the G buffer.
  27260. */
  27261. get renderList(): Nullable<AbstractMesh[]>;
  27262. /**
  27263. * Set the render list (meshes to be rendered) used in the G buffer.
  27264. */
  27265. set renderList(meshes: Nullable<AbstractMesh[]>);
  27266. /**
  27267. * Gets wether or not G buffer are supported by the running hardware.
  27268. * This requires draw buffer supports
  27269. */
  27270. get isSupported(): boolean;
  27271. /**
  27272. * Returns the index of the given texture type in the G-Buffer textures array
  27273. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27274. * @returns the index of the given texture type in the G-Buffer textures array
  27275. */
  27276. getTextureIndex(textureType: number): number;
  27277. /**
  27278. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27279. */
  27280. get enablePosition(): boolean;
  27281. /**
  27282. * Sets whether or not objects positions are enabled for the G buffer.
  27283. */
  27284. set enablePosition(enable: boolean);
  27285. /**
  27286. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27287. */
  27288. get enableVelocity(): boolean;
  27289. /**
  27290. * Sets wether or not objects velocities are enabled for the G buffer.
  27291. */
  27292. set enableVelocity(enable: boolean);
  27293. /**
  27294. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27295. */
  27296. get enableReflectivity(): boolean;
  27297. /**
  27298. * Sets wether or not objects roughness are enabled for the G buffer.
  27299. */
  27300. set enableReflectivity(enable: boolean);
  27301. /**
  27302. * Gets the scene associated with the buffer.
  27303. */
  27304. get scene(): Scene;
  27305. /**
  27306. * Gets the ratio used by the buffer during its creation.
  27307. * How big is the buffer related to the main canvas.
  27308. */
  27309. get ratio(): number;
  27310. /** @hidden */
  27311. static _SceneComponentInitialization: (scene: Scene) => void;
  27312. /**
  27313. * Creates a new G Buffer for the scene
  27314. * @param scene The scene the buffer belongs to
  27315. * @param ratio How big is the buffer related to the main canvas.
  27316. */
  27317. constructor(scene: Scene, ratio?: number);
  27318. /**
  27319. * Checks wether everything is ready to render a submesh to the G buffer.
  27320. * @param subMesh the submesh to check readiness for
  27321. * @param useInstances is the mesh drawn using instance or not
  27322. * @returns true if ready otherwise false
  27323. */
  27324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27325. /**
  27326. * Gets the current underlying G Buffer.
  27327. * @returns the buffer
  27328. */
  27329. getGBuffer(): MultiRenderTarget;
  27330. /**
  27331. * Gets the number of samples used to render the buffer (anti aliasing).
  27332. */
  27333. get samples(): number;
  27334. /**
  27335. * Sets the number of samples used to render the buffer (anti aliasing).
  27336. */
  27337. set samples(value: number);
  27338. /**
  27339. * Disposes the renderer and frees up associated resources.
  27340. */
  27341. dispose(): void;
  27342. private _assignRenderTargetIndices;
  27343. protected _createRenderTargets(): void;
  27344. private _copyBonesTransformationMatrices;
  27345. }
  27346. }
  27347. declare module BABYLON {
  27348. /**
  27349. * Renders a pre pass of the scene
  27350. * This means every mesh in the scene will be rendered to a render target texture
  27351. * And then this texture will be composited to the rendering canvas with post processes
  27352. * It is necessary for effects like subsurface scattering or deferred shading
  27353. */
  27354. export class PrePassRenderer {
  27355. /** @hidden */
  27356. static _SceneComponentInitialization: (scene: Scene) => void;
  27357. private _textureFormats;
  27358. /**
  27359. * To save performance, we can excluded skinned meshes from the prepass
  27360. */
  27361. excludedSkinnedMesh: AbstractMesh[];
  27362. /**
  27363. * Force material to be excluded from the prepass
  27364. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27365. * and you don't want a material to show in the effect.
  27366. */
  27367. excludedMaterials: Material[];
  27368. private _textureIndices;
  27369. private _scene;
  27370. private _engine;
  27371. private _isDirty;
  27372. /**
  27373. * Number of textures in the multi render target texture where the scene is directly rendered
  27374. */
  27375. mrtCount: number;
  27376. /**
  27377. * The render target where the scene is directly rendered
  27378. */
  27379. prePassRT: MultiRenderTarget;
  27380. private _multiRenderAttachments;
  27381. private _defaultAttachments;
  27382. private _clearAttachments;
  27383. private _postProcesses;
  27384. private readonly _clearColor;
  27385. /**
  27386. * Image processing post process for composition
  27387. */
  27388. imageProcessingPostProcess: ImageProcessingPostProcess;
  27389. /**
  27390. * Configuration for prepass effects
  27391. */
  27392. private _effectConfigurations;
  27393. private _mrtFormats;
  27394. private _mrtLayout;
  27395. private _enabled;
  27396. /**
  27397. * Indicates if the prepass is enabled
  27398. */
  27399. get enabled(): boolean;
  27400. /**
  27401. * How many samples are used for MSAA of the scene render target
  27402. */
  27403. get samples(): number;
  27404. set samples(n: number);
  27405. private _geometryBuffer;
  27406. private _useGeometryBufferFallback;
  27407. /**
  27408. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27409. */
  27410. get useGeometryBufferFallback(): boolean;
  27411. set useGeometryBufferFallback(value: boolean);
  27412. /**
  27413. * Instanciates a prepass renderer
  27414. * @param scene The scene
  27415. */
  27416. constructor(scene: Scene);
  27417. private _initializeAttachments;
  27418. private _createCompositionEffect;
  27419. /**
  27420. * Indicates if rendering a prepass is supported
  27421. */
  27422. get isSupported(): boolean;
  27423. /**
  27424. * Sets the proper output textures to draw in the engine.
  27425. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27426. * @param subMesh Submesh on which the effect is applied
  27427. */
  27428. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27429. /**
  27430. * @hidden
  27431. */
  27432. _beforeCameraDraw(): void;
  27433. /**
  27434. * @hidden
  27435. */
  27436. _afterCameraDraw(): void;
  27437. private _checkRTSize;
  27438. private _bindFrameBuffer;
  27439. /**
  27440. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27441. */
  27442. clear(): void;
  27443. private _setState;
  27444. private _updateGeometryBufferLayout;
  27445. /**
  27446. * Adds an effect configuration to the prepass.
  27447. * If an effect has already been added, it won't add it twice and will return the configuration
  27448. * already present.
  27449. * @param cfg the effect configuration
  27450. * @return the effect configuration now used by the prepass
  27451. */
  27452. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27453. /**
  27454. * Returns the index of a texture in the multi render target texture array.
  27455. * @param type Texture type
  27456. * @return The index
  27457. */
  27458. getIndex(type: number): number;
  27459. private _enable;
  27460. private _disable;
  27461. private _resetLayout;
  27462. private _resetPostProcessChain;
  27463. private _bindPostProcessChain;
  27464. /**
  27465. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27466. */
  27467. markAsDirty(): void;
  27468. /**
  27469. * Enables a texture on the MultiRenderTarget for prepass
  27470. */
  27471. private _enableTextures;
  27472. private _update;
  27473. private _markAllMaterialsAsPrePassDirty;
  27474. /**
  27475. * Disposes the prepass renderer.
  27476. */
  27477. dispose(): void;
  27478. }
  27479. }
  27480. declare module BABYLON {
  27481. /**
  27482. * Size options for a post process
  27483. */
  27484. export type PostProcessOptions = {
  27485. width: number;
  27486. height: number;
  27487. };
  27488. /**
  27489. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27490. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27491. */
  27492. export class PostProcess {
  27493. /**
  27494. * Gets or sets the unique id of the post process
  27495. */
  27496. uniqueId: number;
  27497. /** Name of the PostProcess. */
  27498. name: string;
  27499. /**
  27500. * Width of the texture to apply the post process on
  27501. */
  27502. width: number;
  27503. /**
  27504. * Height of the texture to apply the post process on
  27505. */
  27506. height: number;
  27507. /**
  27508. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27509. */
  27510. nodeMaterialSource: Nullable<NodeMaterial>;
  27511. /**
  27512. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27513. * @hidden
  27514. */
  27515. _outputTexture: Nullable<InternalTexture>;
  27516. /**
  27517. * Sampling mode used by the shader
  27518. * See https://doc.babylonjs.com/classes/3.1/texture
  27519. */
  27520. renderTargetSamplingMode: number;
  27521. /**
  27522. * Clear color to use when screen clearing
  27523. */
  27524. clearColor: Color4;
  27525. /**
  27526. * If the buffer needs to be cleared before applying the post process. (default: true)
  27527. * Should be set to false if shader will overwrite all previous pixels.
  27528. */
  27529. autoClear: boolean;
  27530. /**
  27531. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27532. */
  27533. alphaMode: number;
  27534. /**
  27535. * Sets the setAlphaBlendConstants of the babylon engine
  27536. */
  27537. alphaConstants: Color4;
  27538. /**
  27539. * Animations to be used for the post processing
  27540. */
  27541. animations: Animation[];
  27542. /**
  27543. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27544. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27545. */
  27546. enablePixelPerfectMode: boolean;
  27547. /**
  27548. * Force the postprocess to be applied without taking in account viewport
  27549. */
  27550. forceFullscreenViewport: boolean;
  27551. /**
  27552. * List of inspectable custom properties (used by the Inspector)
  27553. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27554. */
  27555. inspectableCustomProperties: IInspectable[];
  27556. /**
  27557. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27558. *
  27559. * | Value | Type | Description |
  27560. * | ----- | ----------------------------------- | ----------- |
  27561. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27562. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27563. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27564. *
  27565. */
  27566. scaleMode: number;
  27567. /**
  27568. * Force textures to be a power of two (default: false)
  27569. */
  27570. alwaysForcePOT: boolean;
  27571. private _samples;
  27572. /**
  27573. * Number of sample textures (default: 1)
  27574. */
  27575. get samples(): number;
  27576. set samples(n: number);
  27577. /**
  27578. * Modify the scale of the post process to be the same as the viewport (default: false)
  27579. */
  27580. adaptScaleToCurrentViewport: boolean;
  27581. private _camera;
  27582. protected _scene: Scene;
  27583. private _engine;
  27584. private _options;
  27585. private _reusable;
  27586. private _textureType;
  27587. private _textureFormat;
  27588. /**
  27589. * Smart array of input and output textures for the post process.
  27590. * @hidden
  27591. */
  27592. _textures: SmartArray<InternalTexture>;
  27593. /**
  27594. * The index in _textures that corresponds to the output texture.
  27595. * @hidden
  27596. */
  27597. _currentRenderTextureInd: number;
  27598. private _effect;
  27599. private _samplers;
  27600. private _fragmentUrl;
  27601. private _vertexUrl;
  27602. private _parameters;
  27603. private _scaleRatio;
  27604. protected _indexParameters: any;
  27605. private _shareOutputWithPostProcess;
  27606. private _texelSize;
  27607. private _forcedOutputTexture;
  27608. /**
  27609. * Prepass configuration in case this post process needs a texture from prepass
  27610. * @hidden
  27611. */
  27612. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27613. /**
  27614. * Returns the fragment url or shader name used in the post process.
  27615. * @returns the fragment url or name in the shader store.
  27616. */
  27617. getEffectName(): string;
  27618. /**
  27619. * An event triggered when the postprocess is activated.
  27620. */
  27621. onActivateObservable: Observable<Camera>;
  27622. private _onActivateObserver;
  27623. /**
  27624. * A function that is added to the onActivateObservable
  27625. */
  27626. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27627. /**
  27628. * An event triggered when the postprocess changes its size.
  27629. */
  27630. onSizeChangedObservable: Observable<PostProcess>;
  27631. private _onSizeChangedObserver;
  27632. /**
  27633. * A function that is added to the onSizeChangedObservable
  27634. */
  27635. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27636. /**
  27637. * An event triggered when the postprocess applies its effect.
  27638. */
  27639. onApplyObservable: Observable<Effect>;
  27640. private _onApplyObserver;
  27641. /**
  27642. * A function that is added to the onApplyObservable
  27643. */
  27644. set onApply(callback: (effect: Effect) => void);
  27645. /**
  27646. * An event triggered before rendering the postprocess
  27647. */
  27648. onBeforeRenderObservable: Observable<Effect>;
  27649. private _onBeforeRenderObserver;
  27650. /**
  27651. * A function that is added to the onBeforeRenderObservable
  27652. */
  27653. set onBeforeRender(callback: (effect: Effect) => void);
  27654. /**
  27655. * An event triggered after rendering the postprocess
  27656. */
  27657. onAfterRenderObservable: Observable<Effect>;
  27658. private _onAfterRenderObserver;
  27659. /**
  27660. * A function that is added to the onAfterRenderObservable
  27661. */
  27662. set onAfterRender(callback: (efect: Effect) => void);
  27663. /**
  27664. * 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
  27665. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27666. */
  27667. get inputTexture(): InternalTexture;
  27668. set inputTexture(value: InternalTexture);
  27669. /**
  27670. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27671. * the only way to unset it is to use this function to restore its internal state
  27672. */
  27673. restoreDefaultInputTexture(): void;
  27674. /**
  27675. * Gets the camera which post process is applied to.
  27676. * @returns The camera the post process is applied to.
  27677. */
  27678. getCamera(): Camera;
  27679. /**
  27680. * Gets the texel size of the postprocess.
  27681. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27682. */
  27683. get texelSize(): Vector2;
  27684. /**
  27685. * Creates a new instance PostProcess
  27686. * @param name The name of the PostProcess.
  27687. * @param fragmentUrl The url of the fragment shader to be used.
  27688. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27689. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27690. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27691. * @param camera The camera to apply the render pass to.
  27692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27693. * @param engine The engine which the post process will be applied. (default: current engine)
  27694. * @param reusable If the post process can be reused on the same frame. (default: false)
  27695. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27696. * @param textureType Type of textures used when performing the post process. (default: 0)
  27697. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27698. * @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
  27699. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27700. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27701. */
  27702. 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);
  27703. /**
  27704. * Gets a string identifying the name of the class
  27705. * @returns "PostProcess" string
  27706. */
  27707. getClassName(): string;
  27708. /**
  27709. * Gets the engine which this post process belongs to.
  27710. * @returns The engine the post process was enabled with.
  27711. */
  27712. getEngine(): Engine;
  27713. /**
  27714. * The effect that is created when initializing the post process.
  27715. * @returns The created effect corresponding the the postprocess.
  27716. */
  27717. getEffect(): Effect;
  27718. /**
  27719. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27720. * @param postProcess The post process to share the output with.
  27721. * @returns This post process.
  27722. */
  27723. shareOutputWith(postProcess: PostProcess): PostProcess;
  27724. /**
  27725. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27726. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27727. */
  27728. useOwnOutput(): void;
  27729. /**
  27730. * Updates the effect with the current post process compile time values and recompiles the shader.
  27731. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27732. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27733. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27734. * @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
  27735. * @param onCompiled Called when the shader has been compiled.
  27736. * @param onError Called if there is an error when compiling a shader.
  27737. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27738. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27739. */
  27740. 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;
  27741. /**
  27742. * The post process is reusable if it can be used multiple times within one frame.
  27743. * @returns If the post process is reusable
  27744. */
  27745. isReusable(): boolean;
  27746. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27747. markTextureDirty(): void;
  27748. /**
  27749. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27750. * 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.
  27751. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27752. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27753. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27754. * @returns The target texture that was bound to be written to.
  27755. */
  27756. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27757. /**
  27758. * If the post process is supported.
  27759. */
  27760. get isSupported(): boolean;
  27761. /**
  27762. * The aspect ratio of the output texture.
  27763. */
  27764. get aspectRatio(): number;
  27765. /**
  27766. * Get a value indicating if the post-process is ready to be used
  27767. * @returns true if the post-process is ready (shader is compiled)
  27768. */
  27769. isReady(): boolean;
  27770. /**
  27771. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27772. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  27773. */
  27774. apply(): Nullable<Effect>;
  27775. private _disposeTextures;
  27776. /**
  27777. * Sets the required values to the prepass renderer.
  27778. * @param prePassRenderer defines the prepass renderer to setup.
  27779. * @returns true if the pre pass is needed.
  27780. */
  27781. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27782. /**
  27783. * Disposes the post process.
  27784. * @param camera The camera to dispose the post process on.
  27785. */
  27786. dispose(camera?: Camera): void;
  27787. /**
  27788. * Serializes the particle system to a JSON object
  27789. * @returns the JSON object
  27790. */
  27791. serialize(): any;
  27792. /**
  27793. * Creates a material from parsed material data
  27794. * @param parsedPostProcess defines parsed post process data
  27795. * @param scene defines the hosting scene
  27796. * @param rootUrl defines the root URL to use to load textures
  27797. * @returns a new post process
  27798. */
  27799. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  27800. }
  27801. }
  27802. declare module BABYLON {
  27803. /** @hidden */
  27804. export var kernelBlurVaryingDeclaration: {
  27805. name: string;
  27806. shader: string;
  27807. };
  27808. }
  27809. declare module BABYLON {
  27810. /** @hidden */
  27811. export var kernelBlurFragment: {
  27812. name: string;
  27813. shader: string;
  27814. };
  27815. }
  27816. declare module BABYLON {
  27817. /** @hidden */
  27818. export var kernelBlurFragment2: {
  27819. name: string;
  27820. shader: string;
  27821. };
  27822. }
  27823. declare module BABYLON {
  27824. /** @hidden */
  27825. export var kernelBlurPixelShader: {
  27826. name: string;
  27827. shader: string;
  27828. };
  27829. }
  27830. declare module BABYLON {
  27831. /** @hidden */
  27832. export var kernelBlurVertex: {
  27833. name: string;
  27834. shader: string;
  27835. };
  27836. }
  27837. declare module BABYLON {
  27838. /** @hidden */
  27839. export var kernelBlurVertexShader: {
  27840. name: string;
  27841. shader: string;
  27842. };
  27843. }
  27844. declare module BABYLON {
  27845. /**
  27846. * The Blur Post Process which blurs an image based on a kernel and direction.
  27847. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27848. */
  27849. export class BlurPostProcess extends PostProcess {
  27850. private blockCompilation;
  27851. protected _kernel: number;
  27852. protected _idealKernel: number;
  27853. protected _packedFloat: boolean;
  27854. private _staticDefines;
  27855. /** The direction in which to blur the image. */
  27856. direction: Vector2;
  27857. /**
  27858. * Sets the length in pixels of the blur sample region
  27859. */
  27860. set kernel(v: number);
  27861. /**
  27862. * Gets the length in pixels of the blur sample region
  27863. */
  27864. get kernel(): number;
  27865. /**
  27866. * Sets wether or not the blur needs to unpack/repack floats
  27867. */
  27868. set packedFloat(v: boolean);
  27869. /**
  27870. * Gets wether or not the blur is unpacking/repacking floats
  27871. */
  27872. get packedFloat(): boolean;
  27873. /**
  27874. * Gets a string identifying the name of the class
  27875. * @returns "BlurPostProcess" string
  27876. */
  27877. getClassName(): string;
  27878. /**
  27879. * Creates a new instance BlurPostProcess
  27880. * @param name The name of the effect.
  27881. * @param direction The direction in which to blur the image.
  27882. * @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.
  27883. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27884. * @param camera The camera to apply the render pass to.
  27885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27886. * @param engine The engine which the post process will be applied. (default: current engine)
  27887. * @param reusable If the post process can be reused on the same frame. (default: false)
  27888. * @param textureType Type of textures used when performing the post process. (default: 0)
  27889. * @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)
  27890. */
  27891. 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);
  27892. /**
  27893. * Updates the effect with the current post process compile time values and recompiles the shader.
  27894. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27895. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27896. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27897. * @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
  27898. * @param onCompiled Called when the shader has been compiled.
  27899. * @param onError Called if there is an error when compiling a shader.
  27900. */
  27901. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27902. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27903. /**
  27904. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27905. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27906. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27907. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27908. * The gaps between physical kernels are compensated for in the weighting of the samples
  27909. * @param idealKernel Ideal blur kernel.
  27910. * @return Nearest best kernel.
  27911. */
  27912. protected _nearestBestKernel(idealKernel: number): number;
  27913. /**
  27914. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27915. * @param x The point on the Gaussian distribution to sample.
  27916. * @return the value of the Gaussian function at x.
  27917. */
  27918. protected _gaussianWeight(x: number): number;
  27919. /**
  27920. * Generates a string that can be used as a floating point number in GLSL.
  27921. * @param x Value to print.
  27922. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27923. * @return GLSL float string.
  27924. */
  27925. protected _glslFloat(x: number, decimalFigures?: number): string;
  27926. /** @hidden */
  27927. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  27928. }
  27929. }
  27930. declare module BABYLON {
  27931. /**
  27932. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27933. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27934. * You can then easily use it as a reflectionTexture on a flat surface.
  27935. * In case the surface is not a plane, please consider relying on reflection probes.
  27936. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27937. */
  27938. export class MirrorTexture extends RenderTargetTexture {
  27939. private scene;
  27940. /**
  27941. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  27942. * 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.
  27943. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27944. */
  27945. mirrorPlane: Plane;
  27946. /**
  27947. * Define the blur ratio used to blur the reflection if needed.
  27948. */
  27949. set blurRatio(value: number);
  27950. get blurRatio(): number;
  27951. /**
  27952. * Define the adaptive blur kernel used to blur the reflection if needed.
  27953. * This will autocompute the closest best match for the `blurKernel`
  27954. */
  27955. set adaptiveBlurKernel(value: number);
  27956. /**
  27957. * Define the blur kernel used to blur the reflection if needed.
  27958. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27959. */
  27960. set blurKernel(value: number);
  27961. /**
  27962. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  27963. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27964. */
  27965. set blurKernelX(value: number);
  27966. get blurKernelX(): number;
  27967. /**
  27968. * Define the blur kernel on the Y 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 blurKernelY(value: number);
  27972. get blurKernelY(): number;
  27973. private _autoComputeBlurKernel;
  27974. protected _onRatioRescale(): void;
  27975. private _updateGammaSpace;
  27976. private _imageProcessingConfigChangeObserver;
  27977. private _transformMatrix;
  27978. private _mirrorMatrix;
  27979. private _savedViewMatrix;
  27980. private _blurX;
  27981. private _blurY;
  27982. private _adaptiveBlurKernel;
  27983. private _blurKernelX;
  27984. private _blurKernelY;
  27985. private _blurRatio;
  27986. /**
  27987. * Instantiates a Mirror Texture.
  27988. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27989. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27990. * You can then easily use it as a reflectionTexture on a flat surface.
  27991. * In case the surface is not a plane, please consider relying on reflection probes.
  27992. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27993. * @param name
  27994. * @param size
  27995. * @param scene
  27996. * @param generateMipMaps
  27997. * @param type
  27998. * @param samplingMode
  27999. * @param generateDepthBuffer
  28000. */
  28001. constructor(name: string, size: number | {
  28002. width: number;
  28003. height: number;
  28004. } | {
  28005. ratio: number;
  28006. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28007. private _preparePostProcesses;
  28008. /**
  28009. * Clone the mirror texture.
  28010. * @returns the cloned texture
  28011. */
  28012. clone(): MirrorTexture;
  28013. /**
  28014. * Serialize the texture to a JSON representation you could use in Parse later on
  28015. * @returns the serialized JSON representation
  28016. */
  28017. serialize(): any;
  28018. /**
  28019. * Dispose the texture and release its associated resources.
  28020. */
  28021. dispose(): void;
  28022. }
  28023. }
  28024. declare module BABYLON {
  28025. /**
  28026. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28027. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28028. */
  28029. export class Texture extends BaseTexture {
  28030. /**
  28031. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28032. */
  28033. static SerializeBuffers: boolean;
  28034. /** @hidden */
  28035. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28036. /** @hidden */
  28037. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28038. /** @hidden */
  28039. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28040. /** nearest is mag = nearest and min = nearest and mip = linear */
  28041. static readonly NEAREST_SAMPLINGMODE: number;
  28042. /** nearest is mag = nearest and min = nearest and mip = linear */
  28043. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28044. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28045. static readonly BILINEAR_SAMPLINGMODE: number;
  28046. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28047. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28048. /** Trilinear is mag = linear and min = linear and mip = linear */
  28049. static readonly TRILINEAR_SAMPLINGMODE: number;
  28050. /** Trilinear is mag = linear and min = linear and mip = linear */
  28051. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28052. /** mag = nearest and min = nearest and mip = nearest */
  28053. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28054. /** mag = nearest and min = linear and mip = nearest */
  28055. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28056. /** mag = nearest and min = linear and mip = linear */
  28057. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28058. /** mag = nearest and min = linear and mip = none */
  28059. static readonly NEAREST_LINEAR: number;
  28060. /** mag = nearest and min = nearest and mip = none */
  28061. static readonly NEAREST_NEAREST: number;
  28062. /** mag = linear and min = nearest and mip = nearest */
  28063. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28064. /** mag = linear and min = nearest and mip = linear */
  28065. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28066. /** mag = linear and min = linear and mip = none */
  28067. static readonly LINEAR_LINEAR: number;
  28068. /** mag = linear and min = nearest and mip = none */
  28069. static readonly LINEAR_NEAREST: number;
  28070. /** Explicit coordinates mode */
  28071. static readonly EXPLICIT_MODE: number;
  28072. /** Spherical coordinates mode */
  28073. static readonly SPHERICAL_MODE: number;
  28074. /** Planar coordinates mode */
  28075. static readonly PLANAR_MODE: number;
  28076. /** Cubic coordinates mode */
  28077. static readonly CUBIC_MODE: number;
  28078. /** Projection coordinates mode */
  28079. static readonly PROJECTION_MODE: number;
  28080. /** Inverse Cubic coordinates mode */
  28081. static readonly SKYBOX_MODE: number;
  28082. /** Inverse Cubic coordinates mode */
  28083. static readonly INVCUBIC_MODE: number;
  28084. /** Equirectangular coordinates mode */
  28085. static readonly EQUIRECTANGULAR_MODE: number;
  28086. /** Equirectangular Fixed coordinates mode */
  28087. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28088. /** Equirectangular Fixed Mirrored coordinates mode */
  28089. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28090. /** Texture is not repeating outside of 0..1 UVs */
  28091. static readonly CLAMP_ADDRESSMODE: number;
  28092. /** Texture is repeating outside of 0..1 UVs */
  28093. static readonly WRAP_ADDRESSMODE: number;
  28094. /** Texture is repeating and mirrored */
  28095. static readonly MIRROR_ADDRESSMODE: number;
  28096. /**
  28097. * 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
  28098. */
  28099. static UseSerializedUrlIfAny: boolean;
  28100. /**
  28101. * Define the url of the texture.
  28102. */
  28103. url: Nullable<string>;
  28104. /**
  28105. * Define an offset on the texture to offset the u coordinates of the UVs
  28106. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28107. */
  28108. uOffset: number;
  28109. /**
  28110. * Define an offset on the texture to offset the v coordinates of the UVs
  28111. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28112. */
  28113. vOffset: number;
  28114. /**
  28115. * Define an offset on the texture to scale the u coordinates of the UVs
  28116. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28117. */
  28118. uScale: number;
  28119. /**
  28120. * Define an offset on the texture to scale the v coordinates of the UVs
  28121. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28122. */
  28123. vScale: number;
  28124. /**
  28125. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28126. * @see https://doc.babylonjs.com/how_to/more_materials
  28127. */
  28128. uAng: number;
  28129. /**
  28130. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28131. * @see https://doc.babylonjs.com/how_to/more_materials
  28132. */
  28133. vAng: number;
  28134. /**
  28135. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28136. * @see https://doc.babylonjs.com/how_to/more_materials
  28137. */
  28138. wAng: number;
  28139. /**
  28140. * Defines the center of rotation (U)
  28141. */
  28142. uRotationCenter: number;
  28143. /**
  28144. * Defines the center of rotation (V)
  28145. */
  28146. vRotationCenter: number;
  28147. /**
  28148. * Defines the center of rotation (W)
  28149. */
  28150. wRotationCenter: number;
  28151. /**
  28152. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28153. */
  28154. homogeneousRotationInUVTransform: boolean;
  28155. /**
  28156. * Are mip maps generated for this texture or not.
  28157. */
  28158. get noMipmap(): boolean;
  28159. /**
  28160. * List of inspectable custom properties (used by the Inspector)
  28161. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28162. */
  28163. inspectableCustomProperties: Nullable<IInspectable[]>;
  28164. private _noMipmap;
  28165. /** @hidden */
  28166. _invertY: boolean;
  28167. private _rowGenerationMatrix;
  28168. private _cachedTextureMatrix;
  28169. private _projectionModeMatrix;
  28170. private _t0;
  28171. private _t1;
  28172. private _t2;
  28173. private _cachedUOffset;
  28174. private _cachedVOffset;
  28175. private _cachedUScale;
  28176. private _cachedVScale;
  28177. private _cachedUAng;
  28178. private _cachedVAng;
  28179. private _cachedWAng;
  28180. private _cachedProjectionMatrixId;
  28181. private _cachedURotationCenter;
  28182. private _cachedVRotationCenter;
  28183. private _cachedWRotationCenter;
  28184. private _cachedHomogeneousRotationInUVTransform;
  28185. private _cachedCoordinatesMode;
  28186. /** @hidden */
  28187. protected _initialSamplingMode: number;
  28188. /** @hidden */
  28189. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28190. private _deleteBuffer;
  28191. protected _format: Nullable<number>;
  28192. private _delayedOnLoad;
  28193. private _delayedOnError;
  28194. private _mimeType?;
  28195. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28196. get mimeType(): string | undefined;
  28197. /**
  28198. * Observable triggered once the texture has been loaded.
  28199. */
  28200. onLoadObservable: Observable<Texture>;
  28201. protected _isBlocking: boolean;
  28202. /**
  28203. * Is the texture preventing material to render while loading.
  28204. * If false, a default texture will be used instead of the loading one during the preparation step.
  28205. */
  28206. set isBlocking(value: boolean);
  28207. get isBlocking(): boolean;
  28208. /**
  28209. * Get the current sampling mode associated with the texture.
  28210. */
  28211. get samplingMode(): number;
  28212. /**
  28213. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28214. */
  28215. get invertY(): boolean;
  28216. /**
  28217. * Instantiates a new texture.
  28218. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28219. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28220. * @param url defines the url of the picture to load as a texture
  28221. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28222. * @param noMipmap defines if the texture will require mip maps or not
  28223. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28224. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28225. * @param onLoad defines a callback triggered when the texture has been loaded
  28226. * @param onError defines a callback triggered when an error occurred during the loading session
  28227. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28228. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28229. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28230. * @param mimeType defines an optional mime type information
  28231. */
  28232. 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);
  28233. /**
  28234. * Update the url (and optional buffer) of this texture if url was null during construction.
  28235. * @param url the url of the texture
  28236. * @param buffer the buffer of the texture (defaults to null)
  28237. * @param onLoad callback called when the texture is loaded (defaults to null)
  28238. */
  28239. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28240. /**
  28241. * Finish the loading sequence of a texture flagged as delayed load.
  28242. * @hidden
  28243. */
  28244. delayLoad(): void;
  28245. private _prepareRowForTextureGeneration;
  28246. /**
  28247. * Checks if the texture has the same transform matrix than another texture
  28248. * @param texture texture to check against
  28249. * @returns true if the transforms are the same, else false
  28250. */
  28251. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28252. /**
  28253. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28254. * @returns the transform matrix of the texture.
  28255. */
  28256. getTextureMatrix(uBase?: number): Matrix;
  28257. /**
  28258. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28259. * @returns The reflection texture transform
  28260. */
  28261. getReflectionTextureMatrix(): Matrix;
  28262. /**
  28263. * Clones the texture.
  28264. * @returns the cloned texture
  28265. */
  28266. clone(): Texture;
  28267. /**
  28268. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28269. * @returns The JSON representation of the texture
  28270. */
  28271. serialize(): any;
  28272. /**
  28273. * Get the current class name of the texture useful for serialization or dynamic coding.
  28274. * @returns "Texture"
  28275. */
  28276. getClassName(): string;
  28277. /**
  28278. * Dispose the texture and release its associated resources.
  28279. */
  28280. dispose(): void;
  28281. /**
  28282. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28283. * @param parsedTexture Define the JSON representation of the texture
  28284. * @param scene Define the scene the parsed texture should be instantiated in
  28285. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28286. * @returns The parsed texture if successful
  28287. */
  28288. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28289. /**
  28290. * Creates a texture from its base 64 representation.
  28291. * @param data Define the base64 payload without the data: prefix
  28292. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28293. * @param scene Define the scene the texture should belong to
  28294. * @param noMipmap Forces the texture to not create mip map information if true
  28295. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28296. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28297. * @param onLoad define a callback triggered when the texture has been loaded
  28298. * @param onError define a callback triggered when an error occurred during the loading session
  28299. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28300. * @returns the created texture
  28301. */
  28302. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28303. /**
  28304. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28305. * @param data Define the base64 payload without the data: prefix
  28306. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28307. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28308. * @param scene Define the scene the texture should belong to
  28309. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28310. * @param noMipmap Forces the texture to not create mip map information if true
  28311. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28312. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28313. * @param onLoad define a callback triggered when the texture has been loaded
  28314. * @param onError define a callback triggered when an error occurred during the loading session
  28315. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28316. * @returns the created texture
  28317. */
  28318. 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;
  28319. }
  28320. }
  28321. declare module BABYLON {
  28322. /**
  28323. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28324. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28325. */
  28326. export class PostProcessManager {
  28327. private _scene;
  28328. private _indexBuffer;
  28329. private _vertexBuffers;
  28330. /**
  28331. * Creates a new instance PostProcess
  28332. * @param scene The scene that the post process is associated with.
  28333. */
  28334. constructor(scene: Scene);
  28335. private _prepareBuffers;
  28336. private _buildIndexBuffer;
  28337. /**
  28338. * Rebuilds the vertex buffers of the manager.
  28339. * @hidden
  28340. */
  28341. _rebuild(): void;
  28342. /**
  28343. * Prepares a frame to be run through a post process.
  28344. * @param sourceTexture The input texture to the post procesess. (default: null)
  28345. * @param postProcesses An array of post processes to be run. (default: null)
  28346. * @returns True if the post processes were able to be run.
  28347. * @hidden
  28348. */
  28349. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28350. /**
  28351. * Manually render a set of post processes to a texture.
  28352. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28353. * @param postProcesses An array of post processes to be run.
  28354. * @param targetTexture The target texture to render to.
  28355. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28356. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28357. * @param lodLevel defines which lod of the texture to render to
  28358. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28359. */
  28360. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28361. /**
  28362. * Finalize the result of the output of the postprocesses.
  28363. * @param doNotPresent If true the result will not be displayed to the screen.
  28364. * @param targetTexture The target texture to render to.
  28365. * @param faceIndex The index of the face to bind the target texture to.
  28366. * @param postProcesses The array of post processes to render.
  28367. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28368. * @hidden
  28369. */
  28370. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28371. /**
  28372. * Disposes of the post process manager.
  28373. */
  28374. dispose(): void;
  28375. }
  28376. }
  28377. declare module BABYLON {
  28378. /**
  28379. * This Helps creating a texture that will be created from a camera in your scene.
  28380. * It is basically a dynamic texture that could be used to create special effects for instance.
  28381. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28382. */
  28383. export class RenderTargetTexture extends Texture {
  28384. /**
  28385. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28386. */
  28387. static readonly REFRESHRATE_RENDER_ONCE: number;
  28388. /**
  28389. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28390. */
  28391. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28392. /**
  28393. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28394. * the central point of your effect and can save a lot of performances.
  28395. */
  28396. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28397. /**
  28398. * Use this predicate to dynamically define the list of mesh you want to render.
  28399. * If set, the renderList property will be overwritten.
  28400. */
  28401. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28402. private _renderList;
  28403. /**
  28404. * Use this list to define the list of mesh you want to render.
  28405. */
  28406. get renderList(): Nullable<Array<AbstractMesh>>;
  28407. set renderList(value: Nullable<Array<AbstractMesh>>);
  28408. /**
  28409. * Use this function to overload the renderList array at rendering time.
  28410. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28411. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28412. * the cube (if the RTT is a cube, else layerOrFace=0).
  28413. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28414. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28415. * hold dummy elements!
  28416. */
  28417. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28418. private _hookArray;
  28419. /**
  28420. * Define if particles should be rendered in your texture.
  28421. */
  28422. renderParticles: boolean;
  28423. /**
  28424. * Define if sprites should be rendered in your texture.
  28425. */
  28426. renderSprites: boolean;
  28427. /**
  28428. * Define the camera used to render the texture.
  28429. */
  28430. activeCamera: Nullable<Camera>;
  28431. /**
  28432. * Override the mesh isReady function with your own one.
  28433. */
  28434. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28435. /**
  28436. * Override the render function of the texture with your own one.
  28437. */
  28438. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28439. /**
  28440. * Define if camera post processes should be use while rendering the texture.
  28441. */
  28442. useCameraPostProcesses: boolean;
  28443. /**
  28444. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28445. */
  28446. ignoreCameraViewport: boolean;
  28447. private _postProcessManager;
  28448. private _postProcesses;
  28449. private _resizeObserver;
  28450. /**
  28451. * An event triggered when the texture is unbind.
  28452. */
  28453. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28454. /**
  28455. * An event triggered when the texture is unbind.
  28456. */
  28457. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28458. private _onAfterUnbindObserver;
  28459. /**
  28460. * Set a after unbind callback in the texture.
  28461. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28462. */
  28463. set onAfterUnbind(callback: () => void);
  28464. /**
  28465. * An event triggered before rendering the texture
  28466. */
  28467. onBeforeRenderObservable: Observable<number>;
  28468. private _onBeforeRenderObserver;
  28469. /**
  28470. * Set a before render callback in the texture.
  28471. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28472. */
  28473. set onBeforeRender(callback: (faceIndex: number) => void);
  28474. /**
  28475. * An event triggered after rendering the texture
  28476. */
  28477. onAfterRenderObservable: Observable<number>;
  28478. private _onAfterRenderObserver;
  28479. /**
  28480. * Set a after render callback in the texture.
  28481. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28482. */
  28483. set onAfterRender(callback: (faceIndex: number) => void);
  28484. /**
  28485. * An event triggered after the texture clear
  28486. */
  28487. onClearObservable: Observable<Engine>;
  28488. private _onClearObserver;
  28489. /**
  28490. * Set a clear callback in the texture.
  28491. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28492. */
  28493. set onClear(callback: (Engine: Engine) => void);
  28494. /**
  28495. * An event triggered when the texture is resized.
  28496. */
  28497. onResizeObservable: Observable<RenderTargetTexture>;
  28498. /**
  28499. * Define the clear color of the Render Target if it should be different from the scene.
  28500. */
  28501. clearColor: Color4;
  28502. protected _size: number | {
  28503. width: number;
  28504. height: number;
  28505. layers?: number;
  28506. };
  28507. protected _initialSizeParameter: number | {
  28508. width: number;
  28509. height: number;
  28510. } | {
  28511. ratio: number;
  28512. };
  28513. protected _sizeRatio: Nullable<number>;
  28514. /** @hidden */
  28515. _generateMipMaps: boolean;
  28516. protected _renderingManager: RenderingManager;
  28517. /** @hidden */
  28518. _waitingRenderList?: string[];
  28519. protected _doNotChangeAspectRatio: boolean;
  28520. protected _currentRefreshId: number;
  28521. protected _refreshRate: number;
  28522. protected _textureMatrix: Matrix;
  28523. protected _samples: number;
  28524. protected _renderTargetOptions: RenderTargetCreationOptions;
  28525. /**
  28526. * Gets render target creation options that were used.
  28527. */
  28528. get renderTargetOptions(): RenderTargetCreationOptions;
  28529. protected _onRatioRescale(): void;
  28530. /**
  28531. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28532. * It must define where the camera used to render the texture is set
  28533. */
  28534. boundingBoxPosition: Vector3;
  28535. private _boundingBoxSize;
  28536. /**
  28537. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28538. * When defined, the cubemap will switch to local mode
  28539. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28540. * @example https://www.babylonjs-playground.com/#RNASML
  28541. */
  28542. set boundingBoxSize(value: Vector3);
  28543. get boundingBoxSize(): Vector3;
  28544. /**
  28545. * In case the RTT has been created with a depth texture, get the associated
  28546. * depth texture.
  28547. * Otherwise, return null.
  28548. */
  28549. get depthStencilTexture(): Nullable<InternalTexture>;
  28550. /**
  28551. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28552. * or used a shadow, depth texture...
  28553. * @param name The friendly name of the texture
  28554. * @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)
  28555. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28556. * @param generateMipMaps True if mip maps need to be generated after render.
  28557. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28558. * @param type The type of the buffer in the RTT (int, half float, float...)
  28559. * @param isCube True if a cube texture needs to be created
  28560. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28561. * @param generateDepthBuffer True to generate a depth buffer
  28562. * @param generateStencilBuffer True to generate a stencil buffer
  28563. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28564. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28565. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28566. */
  28567. constructor(name: string, size: number | {
  28568. width: number;
  28569. height: number;
  28570. layers?: number;
  28571. } | {
  28572. ratio: number;
  28573. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28574. /**
  28575. * Creates a depth stencil texture.
  28576. * This is only available in WebGL 2 or with the depth texture extension available.
  28577. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28578. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28579. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28580. */
  28581. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28582. private _processSizeParameter;
  28583. /**
  28584. * Define the number of samples to use in case of MSAA.
  28585. * It defaults to one meaning no MSAA has been enabled.
  28586. */
  28587. get samples(): number;
  28588. set samples(value: number);
  28589. /**
  28590. * Resets the refresh counter of the texture and start bak from scratch.
  28591. * Could be useful to regenerate the texture if it is setup to render only once.
  28592. */
  28593. resetRefreshCounter(): void;
  28594. /**
  28595. * Define the refresh rate of the texture or the rendering frequency.
  28596. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28597. */
  28598. get refreshRate(): number;
  28599. set refreshRate(value: number);
  28600. /**
  28601. * Adds a post process to the render target rendering passes.
  28602. * @param postProcess define the post process to add
  28603. */
  28604. addPostProcess(postProcess: PostProcess): void;
  28605. /**
  28606. * Clear all the post processes attached to the render target
  28607. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28608. */
  28609. clearPostProcesses(dispose?: boolean): void;
  28610. /**
  28611. * Remove one of the post process from the list of attached post processes to the texture
  28612. * @param postProcess define the post process to remove from the list
  28613. */
  28614. removePostProcess(postProcess: PostProcess): void;
  28615. /** @hidden */
  28616. _shouldRender(): boolean;
  28617. /**
  28618. * Gets the actual render size of the texture.
  28619. * @returns the width of the render size
  28620. */
  28621. getRenderSize(): number;
  28622. /**
  28623. * Gets the actual render width of the texture.
  28624. * @returns the width of the render size
  28625. */
  28626. getRenderWidth(): number;
  28627. /**
  28628. * Gets the actual render height of the texture.
  28629. * @returns the height of the render size
  28630. */
  28631. getRenderHeight(): number;
  28632. /**
  28633. * Gets the actual number of layers of the texture.
  28634. * @returns the number of layers
  28635. */
  28636. getRenderLayers(): number;
  28637. /**
  28638. * Get if the texture can be rescaled or not.
  28639. */
  28640. get canRescale(): boolean;
  28641. /**
  28642. * Resize the texture using a ratio.
  28643. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28644. */
  28645. scale(ratio: number): void;
  28646. /**
  28647. * Get the texture reflection matrix used to rotate/transform the reflection.
  28648. * @returns the reflection matrix
  28649. */
  28650. getReflectionTextureMatrix(): Matrix;
  28651. /**
  28652. * Resize the texture to a new desired size.
  28653. * Be carrefull as it will recreate all the data in the new texture.
  28654. * @param size Define the new size. It can be:
  28655. * - a number for squared texture,
  28656. * - an object containing { width: number, height: number }
  28657. * - or an object containing a ratio { ratio: number }
  28658. */
  28659. resize(size: number | {
  28660. width: number;
  28661. height: number;
  28662. } | {
  28663. ratio: number;
  28664. }): void;
  28665. private _defaultRenderListPrepared;
  28666. /**
  28667. * Renders all the objects from the render list into the texture.
  28668. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28669. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28670. */
  28671. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28672. private _bestReflectionRenderTargetDimension;
  28673. private _prepareRenderingManager;
  28674. /**
  28675. * @hidden
  28676. * @param faceIndex face index to bind to if this is a cubetexture
  28677. * @param layer defines the index of the texture to bind in the array
  28678. */
  28679. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28680. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28681. private renderToTarget;
  28682. /**
  28683. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28684. * This allowed control for front to back rendering or reversly depending of the special needs.
  28685. *
  28686. * @param renderingGroupId The rendering group id corresponding to its index
  28687. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28688. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28689. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28690. */
  28691. 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;
  28692. /**
  28693. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28694. *
  28695. * @param renderingGroupId The rendering group id corresponding to its index
  28696. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28697. */
  28698. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28699. /**
  28700. * Clones the texture.
  28701. * @returns the cloned texture
  28702. */
  28703. clone(): RenderTargetTexture;
  28704. /**
  28705. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28706. * @returns The JSON representation of the texture
  28707. */
  28708. serialize(): any;
  28709. /**
  28710. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28711. */
  28712. disposeFramebufferObjects(): void;
  28713. /**
  28714. * Dispose the texture and release its associated resources.
  28715. */
  28716. dispose(): void;
  28717. /** @hidden */
  28718. _rebuild(): void;
  28719. /**
  28720. * Clear the info related to rendering groups preventing retention point in material dispose.
  28721. */
  28722. freeRenderingGroups(): void;
  28723. /**
  28724. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28725. * @returns the view count
  28726. */
  28727. getViewCount(): number;
  28728. }
  28729. }
  28730. declare module BABYLON {
  28731. /**
  28732. * Class used to manipulate GUIDs
  28733. */
  28734. export class GUID {
  28735. /**
  28736. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28737. * Be aware Math.random() could cause collisions, but:
  28738. * "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"
  28739. * @returns a pseudo random id
  28740. */
  28741. static RandomId(): string;
  28742. }
  28743. }
  28744. declare module BABYLON {
  28745. /**
  28746. * Options to be used when creating a shadow depth material
  28747. */
  28748. export interface IIOptionShadowDepthMaterial {
  28749. /** Variables in the vertex shader code that need to have their names remapped.
  28750. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  28751. * "var_name" should be either: worldPos or vNormalW
  28752. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  28753. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  28754. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  28755. */
  28756. remappedVariables?: string[];
  28757. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  28758. standalone?: boolean;
  28759. }
  28760. /**
  28761. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  28762. */
  28763. export class ShadowDepthWrapper {
  28764. private _scene;
  28765. private _options?;
  28766. private _baseMaterial;
  28767. private _onEffectCreatedObserver;
  28768. private _subMeshToEffect;
  28769. private _subMeshToDepthEffect;
  28770. private _meshes;
  28771. /** @hidden */
  28772. _matriceNames: any;
  28773. /** Gets the standalone status of the wrapper */
  28774. get standalone(): boolean;
  28775. /** Gets the base material the wrapper is built upon */
  28776. get baseMaterial(): Material;
  28777. /**
  28778. * Instantiate a new shadow depth wrapper.
  28779. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  28780. * generate the shadow depth map. For more information, please refer to the documentation:
  28781. * https://doc.babylonjs.com/babylon101/shadows
  28782. * @param baseMaterial Material to wrap
  28783. * @param scene Define the scene the material belongs to
  28784. * @param options Options used to create the wrapper
  28785. */
  28786. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  28787. /**
  28788. * Gets the effect to use to generate the depth map
  28789. * @param subMesh subMesh to get the effect for
  28790. * @param shadowGenerator shadow generator to get the effect for
  28791. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  28792. */
  28793. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  28794. /**
  28795. * Specifies that the submesh is ready to be used for depth rendering
  28796. * @param subMesh submesh to check
  28797. * @param defines the list of defines to take into account when checking the effect
  28798. * @param shadowGenerator combined with subMesh, it defines the effect to check
  28799. * @param useInstances specifies that instances should be used
  28800. * @returns a boolean indicating that the submesh is ready or not
  28801. */
  28802. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  28803. /**
  28804. * Disposes the resources
  28805. */
  28806. dispose(): void;
  28807. private _makeEffect;
  28808. }
  28809. }
  28810. declare module BABYLON {
  28811. /**
  28812. * Options for compiling materials.
  28813. */
  28814. export interface IMaterialCompilationOptions {
  28815. /**
  28816. * Defines whether clip planes are enabled.
  28817. */
  28818. clipPlane: boolean;
  28819. /**
  28820. * Defines whether instances are enabled.
  28821. */
  28822. useInstances: boolean;
  28823. }
  28824. /**
  28825. * Options passed when calling customShaderNameResolve
  28826. */
  28827. export interface ICustomShaderNameResolveOptions {
  28828. /**
  28829. * 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
  28830. */
  28831. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  28832. }
  28833. /**
  28834. * Base class for the main features of a material in Babylon.js
  28835. */
  28836. export class Material implements IAnimatable {
  28837. /**
  28838. * Returns the triangle fill mode
  28839. */
  28840. static readonly TriangleFillMode: number;
  28841. /**
  28842. * Returns the wireframe mode
  28843. */
  28844. static readonly WireFrameFillMode: number;
  28845. /**
  28846. * Returns the point fill mode
  28847. */
  28848. static readonly PointFillMode: number;
  28849. /**
  28850. * Returns the point list draw mode
  28851. */
  28852. static readonly PointListDrawMode: number;
  28853. /**
  28854. * Returns the line list draw mode
  28855. */
  28856. static readonly LineListDrawMode: number;
  28857. /**
  28858. * Returns the line loop draw mode
  28859. */
  28860. static readonly LineLoopDrawMode: number;
  28861. /**
  28862. * Returns the line strip draw mode
  28863. */
  28864. static readonly LineStripDrawMode: number;
  28865. /**
  28866. * Returns the triangle strip draw mode
  28867. */
  28868. static readonly TriangleStripDrawMode: number;
  28869. /**
  28870. * Returns the triangle fan draw mode
  28871. */
  28872. static readonly TriangleFanDrawMode: number;
  28873. /**
  28874. * Stores the clock-wise side orientation
  28875. */
  28876. static readonly ClockWiseSideOrientation: number;
  28877. /**
  28878. * Stores the counter clock-wise side orientation
  28879. */
  28880. static readonly CounterClockWiseSideOrientation: number;
  28881. /**
  28882. * The dirty texture flag value
  28883. */
  28884. static readonly TextureDirtyFlag: number;
  28885. /**
  28886. * The dirty light flag value
  28887. */
  28888. static readonly LightDirtyFlag: number;
  28889. /**
  28890. * The dirty fresnel flag value
  28891. */
  28892. static readonly FresnelDirtyFlag: number;
  28893. /**
  28894. * The dirty attribute flag value
  28895. */
  28896. static readonly AttributesDirtyFlag: number;
  28897. /**
  28898. * The dirty misc flag value
  28899. */
  28900. static readonly MiscDirtyFlag: number;
  28901. /**
  28902. * The dirty prepass flag value
  28903. */
  28904. static readonly PrePassDirtyFlag: number;
  28905. /**
  28906. * The all dirty flag value
  28907. */
  28908. static readonly AllDirtyFlag: number;
  28909. /**
  28910. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28911. */
  28912. static readonly MATERIAL_OPAQUE: number;
  28913. /**
  28914. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28915. */
  28916. static readonly MATERIAL_ALPHATEST: number;
  28917. /**
  28918. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28919. */
  28920. static readonly MATERIAL_ALPHABLEND: number;
  28921. /**
  28922. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28923. * They are also discarded below the alpha cutoff threshold to improve performances.
  28924. */
  28925. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  28926. /**
  28927. * The Whiteout method is used to blend normals.
  28928. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28929. */
  28930. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  28931. /**
  28932. * The Reoriented Normal Mapping method is used to blend normals.
  28933. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28934. */
  28935. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  28936. /**
  28937. * Custom callback helping to override the default shader used in the material.
  28938. */
  28939. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  28940. /**
  28941. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  28942. */
  28943. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  28944. /**
  28945. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  28946. * This means that the material can keep using a previous shader while a new one is being compiled.
  28947. * This is mostly used when shader parallel compilation is supported (true by default)
  28948. */
  28949. allowShaderHotSwapping: boolean;
  28950. /**
  28951. * The ID of the material
  28952. */
  28953. id: string;
  28954. /**
  28955. * Gets or sets the unique id of the material
  28956. */
  28957. uniqueId: number;
  28958. /**
  28959. * The name of the material
  28960. */
  28961. name: string;
  28962. /**
  28963. * Gets or sets user defined metadata
  28964. */
  28965. metadata: any;
  28966. /**
  28967. * For internal use only. Please do not use.
  28968. */
  28969. reservedDataStore: any;
  28970. /**
  28971. * Specifies if the ready state should be checked on each call
  28972. */
  28973. checkReadyOnEveryCall: boolean;
  28974. /**
  28975. * Specifies if the ready state should be checked once
  28976. */
  28977. checkReadyOnlyOnce: boolean;
  28978. /**
  28979. * The state of the material
  28980. */
  28981. state: string;
  28982. /**
  28983. * If the material can be rendered to several textures with MRT extension
  28984. */
  28985. get canRenderToMRT(): boolean;
  28986. /**
  28987. * The alpha value of the material
  28988. */
  28989. protected _alpha: number;
  28990. /**
  28991. * List of inspectable custom properties (used by the Inspector)
  28992. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28993. */
  28994. inspectableCustomProperties: IInspectable[];
  28995. /**
  28996. * Sets the alpha value of the material
  28997. */
  28998. set alpha(value: number);
  28999. /**
  29000. * Gets the alpha value of the material
  29001. */
  29002. get alpha(): number;
  29003. /**
  29004. * Specifies if back face culling is enabled
  29005. */
  29006. protected _backFaceCulling: boolean;
  29007. /**
  29008. * Sets the back-face culling state
  29009. */
  29010. set backFaceCulling(value: boolean);
  29011. /**
  29012. * Gets the back-face culling state
  29013. */
  29014. get backFaceCulling(): boolean;
  29015. /**
  29016. * Stores the value for side orientation
  29017. */
  29018. sideOrientation: number;
  29019. /**
  29020. * Callback triggered when the material is compiled
  29021. */
  29022. onCompiled: Nullable<(effect: Effect) => void>;
  29023. /**
  29024. * Callback triggered when an error occurs
  29025. */
  29026. onError: Nullable<(effect: Effect, errors: string) => void>;
  29027. /**
  29028. * Callback triggered to get the render target textures
  29029. */
  29030. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29031. /**
  29032. * Gets a boolean indicating that current material needs to register RTT
  29033. */
  29034. get hasRenderTargetTextures(): boolean;
  29035. /**
  29036. * Specifies if the material should be serialized
  29037. */
  29038. doNotSerialize: boolean;
  29039. /**
  29040. * @hidden
  29041. */
  29042. _storeEffectOnSubMeshes: boolean;
  29043. /**
  29044. * Stores the animations for the material
  29045. */
  29046. animations: Nullable<Array<Animation>>;
  29047. /**
  29048. * An event triggered when the material is disposed
  29049. */
  29050. onDisposeObservable: Observable<Material>;
  29051. /**
  29052. * An observer which watches for dispose events
  29053. */
  29054. private _onDisposeObserver;
  29055. private _onUnBindObservable;
  29056. /**
  29057. * Called during a dispose event
  29058. */
  29059. set onDispose(callback: () => void);
  29060. private _onBindObservable;
  29061. /**
  29062. * An event triggered when the material is bound
  29063. */
  29064. get onBindObservable(): Observable<AbstractMesh>;
  29065. /**
  29066. * An observer which watches for bind events
  29067. */
  29068. private _onBindObserver;
  29069. /**
  29070. * Called during a bind event
  29071. */
  29072. set onBind(callback: (Mesh: AbstractMesh) => void);
  29073. /**
  29074. * An event triggered when the material is unbound
  29075. */
  29076. get onUnBindObservable(): Observable<Material>;
  29077. protected _onEffectCreatedObservable: Nullable<Observable<{
  29078. effect: Effect;
  29079. subMesh: Nullable<SubMesh>;
  29080. }>>;
  29081. /**
  29082. * An event triggered when the effect is (re)created
  29083. */
  29084. get onEffectCreatedObservable(): Observable<{
  29085. effect: Effect;
  29086. subMesh: Nullable<SubMesh>;
  29087. }>;
  29088. /**
  29089. * Stores the value of the alpha mode
  29090. */
  29091. private _alphaMode;
  29092. /**
  29093. * Sets the value of the alpha mode.
  29094. *
  29095. * | Value | Type | Description |
  29096. * | --- | --- | --- |
  29097. * | 0 | ALPHA_DISABLE | |
  29098. * | 1 | ALPHA_ADD | |
  29099. * | 2 | ALPHA_COMBINE | |
  29100. * | 3 | ALPHA_SUBTRACT | |
  29101. * | 4 | ALPHA_MULTIPLY | |
  29102. * | 5 | ALPHA_MAXIMIZED | |
  29103. * | 6 | ALPHA_ONEONE | |
  29104. * | 7 | ALPHA_PREMULTIPLIED | |
  29105. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29106. * | 9 | ALPHA_INTERPOLATE | |
  29107. * | 10 | ALPHA_SCREENMODE | |
  29108. *
  29109. */
  29110. set alphaMode(value: number);
  29111. /**
  29112. * Gets the value of the alpha mode
  29113. */
  29114. get alphaMode(): number;
  29115. /**
  29116. * Stores the state of the need depth pre-pass value
  29117. */
  29118. private _needDepthPrePass;
  29119. /**
  29120. * Sets the need depth pre-pass value
  29121. */
  29122. set needDepthPrePass(value: boolean);
  29123. /**
  29124. * Gets the depth pre-pass value
  29125. */
  29126. get needDepthPrePass(): boolean;
  29127. /**
  29128. * Specifies if depth writing should be disabled
  29129. */
  29130. disableDepthWrite: boolean;
  29131. /**
  29132. * Specifies if color writing should be disabled
  29133. */
  29134. disableColorWrite: boolean;
  29135. /**
  29136. * Specifies if depth writing should be forced
  29137. */
  29138. forceDepthWrite: boolean;
  29139. /**
  29140. * Specifies the depth function that should be used. 0 means the default engine function
  29141. */
  29142. depthFunction: number;
  29143. /**
  29144. * Specifies if there should be a separate pass for culling
  29145. */
  29146. separateCullingPass: boolean;
  29147. /**
  29148. * Stores the state specifing if fog should be enabled
  29149. */
  29150. private _fogEnabled;
  29151. /**
  29152. * Sets the state for enabling fog
  29153. */
  29154. set fogEnabled(value: boolean);
  29155. /**
  29156. * Gets the value of the fog enabled state
  29157. */
  29158. get fogEnabled(): boolean;
  29159. /**
  29160. * Stores the size of points
  29161. */
  29162. pointSize: number;
  29163. /**
  29164. * Stores the z offset value
  29165. */
  29166. zOffset: number;
  29167. get wireframe(): boolean;
  29168. /**
  29169. * Sets the state of wireframe mode
  29170. */
  29171. set wireframe(value: boolean);
  29172. /**
  29173. * Gets the value specifying if point clouds are enabled
  29174. */
  29175. get pointsCloud(): boolean;
  29176. /**
  29177. * Sets the state of point cloud mode
  29178. */
  29179. set pointsCloud(value: boolean);
  29180. /**
  29181. * Gets the material fill mode
  29182. */
  29183. get fillMode(): number;
  29184. /**
  29185. * Sets the material fill mode
  29186. */
  29187. set fillMode(value: number);
  29188. /**
  29189. * @hidden
  29190. * Stores the effects for the material
  29191. */
  29192. _effect: Nullable<Effect>;
  29193. /**
  29194. * Specifies if uniform buffers should be used
  29195. */
  29196. private _useUBO;
  29197. /**
  29198. * Stores a reference to the scene
  29199. */
  29200. private _scene;
  29201. /**
  29202. * Stores the fill mode state
  29203. */
  29204. private _fillMode;
  29205. /**
  29206. * Specifies if the depth write state should be cached
  29207. */
  29208. private _cachedDepthWriteState;
  29209. /**
  29210. * Specifies if the color write state should be cached
  29211. */
  29212. private _cachedColorWriteState;
  29213. /**
  29214. * Specifies if the depth function state should be cached
  29215. */
  29216. private _cachedDepthFunctionState;
  29217. /**
  29218. * Stores the uniform buffer
  29219. */
  29220. protected _uniformBuffer: UniformBuffer;
  29221. /** @hidden */
  29222. _indexInSceneMaterialArray: number;
  29223. /** @hidden */
  29224. meshMap: Nullable<{
  29225. [id: string]: AbstractMesh | undefined;
  29226. }>;
  29227. /**
  29228. * Creates a material instance
  29229. * @param name defines the name of the material
  29230. * @param scene defines the scene to reference
  29231. * @param doNotAdd specifies if the material should be added to the scene
  29232. */
  29233. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29234. /**
  29235. * Returns a string representation of the current material
  29236. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29237. * @returns a string with material information
  29238. */
  29239. toString(fullDetails?: boolean): string;
  29240. /**
  29241. * Gets the class name of the material
  29242. * @returns a string with the class name of the material
  29243. */
  29244. getClassName(): string;
  29245. /**
  29246. * Specifies if updates for the material been locked
  29247. */
  29248. get isFrozen(): boolean;
  29249. /**
  29250. * Locks updates for the material
  29251. */
  29252. freeze(): void;
  29253. /**
  29254. * Unlocks updates for the material
  29255. */
  29256. unfreeze(): void;
  29257. /**
  29258. * Specifies if the material is ready to be used
  29259. * @param mesh defines the mesh to check
  29260. * @param useInstances specifies if instances should be used
  29261. * @returns a boolean indicating if the material is ready to be used
  29262. */
  29263. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29264. /**
  29265. * Specifies that the submesh is ready to be used
  29266. * @param mesh defines the mesh to check
  29267. * @param subMesh defines which submesh to check
  29268. * @param useInstances specifies that instances should be used
  29269. * @returns a boolean indicating that the submesh is ready or not
  29270. */
  29271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29272. /**
  29273. * Returns the material effect
  29274. * @returns the effect associated with the material
  29275. */
  29276. getEffect(): Nullable<Effect>;
  29277. /**
  29278. * Returns the current scene
  29279. * @returns a Scene
  29280. */
  29281. getScene(): Scene;
  29282. /**
  29283. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29284. */
  29285. protected _forceAlphaTest: boolean;
  29286. /**
  29287. * The transparency mode of the material.
  29288. */
  29289. protected _transparencyMode: Nullable<number>;
  29290. /**
  29291. * Gets the current transparency mode.
  29292. */
  29293. get transparencyMode(): Nullable<number>;
  29294. /**
  29295. * Sets the transparency mode of the material.
  29296. *
  29297. * | Value | Type | Description |
  29298. * | ----- | ----------------------------------- | ----------- |
  29299. * | 0 | OPAQUE | |
  29300. * | 1 | ALPHATEST | |
  29301. * | 2 | ALPHABLEND | |
  29302. * | 3 | ALPHATESTANDBLEND | |
  29303. *
  29304. */
  29305. set transparencyMode(value: Nullable<number>);
  29306. /**
  29307. * Returns true if alpha blending should be disabled.
  29308. */
  29309. protected get _disableAlphaBlending(): boolean;
  29310. /**
  29311. * Specifies whether or not this material should be rendered in alpha blend mode.
  29312. * @returns a boolean specifying if alpha blending is needed
  29313. */
  29314. needAlphaBlending(): boolean;
  29315. /**
  29316. * Specifies if the mesh will require alpha blending
  29317. * @param mesh defines the mesh to check
  29318. * @returns a boolean specifying if alpha blending is needed for the mesh
  29319. */
  29320. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29321. /**
  29322. * Specifies whether or not this material should be rendered in alpha test mode.
  29323. * @returns a boolean specifying if an alpha test is needed.
  29324. */
  29325. needAlphaTesting(): boolean;
  29326. /**
  29327. * Specifies if material alpha testing should be turned on for the mesh
  29328. * @param mesh defines the mesh to check
  29329. */
  29330. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29331. /**
  29332. * Gets the texture used for the alpha test
  29333. * @returns the texture to use for alpha testing
  29334. */
  29335. getAlphaTestTexture(): Nullable<BaseTexture>;
  29336. /**
  29337. * Marks the material to indicate that it needs to be re-calculated
  29338. */
  29339. markDirty(): void;
  29340. /** @hidden */
  29341. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29342. /**
  29343. * Binds the material to the mesh
  29344. * @param world defines the world transformation matrix
  29345. * @param mesh defines the mesh to bind the material to
  29346. */
  29347. bind(world: Matrix, mesh?: Mesh): void;
  29348. /**
  29349. * Binds the submesh to the material
  29350. * @param world defines the world transformation matrix
  29351. * @param mesh defines the mesh containing the submesh
  29352. * @param subMesh defines the submesh to bind the material to
  29353. */
  29354. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29355. /**
  29356. * Binds the world matrix to the material
  29357. * @param world defines the world transformation matrix
  29358. */
  29359. bindOnlyWorldMatrix(world: Matrix): void;
  29360. /**
  29361. * Binds the scene's uniform buffer to the effect.
  29362. * @param effect defines the effect to bind to the scene uniform buffer
  29363. * @param sceneUbo defines the uniform buffer storing scene data
  29364. */
  29365. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29366. /**
  29367. * Binds the view matrix to the effect
  29368. * @param effect defines the effect to bind the view matrix to
  29369. */
  29370. bindView(effect: Effect): void;
  29371. /**
  29372. * Binds the view projection matrix to the effect
  29373. * @param effect defines the effect to bind the view projection matrix to
  29374. */
  29375. bindViewProjection(effect: Effect): void;
  29376. /**
  29377. * Processes to execute after binding the material to a mesh
  29378. * @param mesh defines the rendered mesh
  29379. */
  29380. protected _afterBind(mesh?: Mesh): void;
  29381. /**
  29382. * Unbinds the material from the mesh
  29383. */
  29384. unbind(): void;
  29385. /**
  29386. * Gets the active textures from the material
  29387. * @returns an array of textures
  29388. */
  29389. getActiveTextures(): BaseTexture[];
  29390. /**
  29391. * Specifies if the material uses a texture
  29392. * @param texture defines the texture to check against the material
  29393. * @returns a boolean specifying if the material uses the texture
  29394. */
  29395. hasTexture(texture: BaseTexture): boolean;
  29396. /**
  29397. * Makes a duplicate of the material, and gives it a new name
  29398. * @param name defines the new name for the duplicated material
  29399. * @returns the cloned material
  29400. */
  29401. clone(name: string): Nullable<Material>;
  29402. /**
  29403. * Gets the meshes bound to the material
  29404. * @returns an array of meshes bound to the material
  29405. */
  29406. getBindedMeshes(): AbstractMesh[];
  29407. /**
  29408. * Force shader compilation
  29409. * @param mesh defines the mesh associated with this material
  29410. * @param onCompiled defines a function to execute once the material is compiled
  29411. * @param options defines the options to configure the compilation
  29412. * @param onError defines a function to execute if the material fails compiling
  29413. */
  29414. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29415. /**
  29416. * Force shader compilation
  29417. * @param mesh defines the mesh that will use this material
  29418. * @param options defines additional options for compiling the shaders
  29419. * @returns a promise that resolves when the compilation completes
  29420. */
  29421. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29422. private static readonly _AllDirtyCallBack;
  29423. private static readonly _ImageProcessingDirtyCallBack;
  29424. private static readonly _TextureDirtyCallBack;
  29425. private static readonly _FresnelDirtyCallBack;
  29426. private static readonly _MiscDirtyCallBack;
  29427. private static readonly _PrePassDirtyCallBack;
  29428. private static readonly _LightsDirtyCallBack;
  29429. private static readonly _AttributeDirtyCallBack;
  29430. private static _FresnelAndMiscDirtyCallBack;
  29431. private static _TextureAndMiscDirtyCallBack;
  29432. private static readonly _DirtyCallbackArray;
  29433. private static readonly _RunDirtyCallBacks;
  29434. /**
  29435. * Marks a define in the material to indicate that it needs to be re-computed
  29436. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29437. */
  29438. markAsDirty(flag: number): void;
  29439. /**
  29440. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29441. * @param func defines a function which checks material defines against the submeshes
  29442. */
  29443. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29444. /**
  29445. * Indicates that the scene should check if the rendering now needs a prepass
  29446. */
  29447. protected _markScenePrePassDirty(): void;
  29448. /**
  29449. * Indicates that we need to re-calculated for all submeshes
  29450. */
  29451. protected _markAllSubMeshesAsAllDirty(): void;
  29452. /**
  29453. * Indicates that image processing needs to be re-calculated for all submeshes
  29454. */
  29455. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29456. /**
  29457. * Indicates that textures need to be re-calculated for all submeshes
  29458. */
  29459. protected _markAllSubMeshesAsTexturesDirty(): void;
  29460. /**
  29461. * Indicates that fresnel needs to be re-calculated for all submeshes
  29462. */
  29463. protected _markAllSubMeshesAsFresnelDirty(): void;
  29464. /**
  29465. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29466. */
  29467. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29468. /**
  29469. * Indicates that lights need to be re-calculated for all submeshes
  29470. */
  29471. protected _markAllSubMeshesAsLightsDirty(): void;
  29472. /**
  29473. * Indicates that attributes need to be re-calculated for all submeshes
  29474. */
  29475. protected _markAllSubMeshesAsAttributesDirty(): void;
  29476. /**
  29477. * Indicates that misc needs to be re-calculated for all submeshes
  29478. */
  29479. protected _markAllSubMeshesAsMiscDirty(): void;
  29480. /**
  29481. * Indicates that prepass needs to be re-calculated for all submeshes
  29482. */
  29483. protected _markAllSubMeshesAsPrePassDirty(): void;
  29484. /**
  29485. * Indicates that textures and misc need to be re-calculated for all submeshes
  29486. */
  29487. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29488. /**
  29489. * Sets the required values to the prepass renderer.
  29490. * @param prePassRenderer defines the prepass renderer to setup.
  29491. * @returns true if the pre pass is needed.
  29492. */
  29493. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29494. /**
  29495. * Disposes the material
  29496. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29497. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29498. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29499. */
  29500. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29501. /** @hidden */
  29502. private releaseVertexArrayObject;
  29503. /**
  29504. * Serializes this material
  29505. * @returns the serialized material object
  29506. */
  29507. serialize(): any;
  29508. /**
  29509. * Creates a material from parsed material data
  29510. * @param parsedMaterial defines parsed material data
  29511. * @param scene defines the hosting scene
  29512. * @param rootUrl defines the root URL to use to load textures
  29513. * @returns a new material
  29514. */
  29515. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29516. }
  29517. }
  29518. declare module BABYLON {
  29519. /**
  29520. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29521. * separate meshes. This can be use to improve performances.
  29522. * @see https://doc.babylonjs.com/how_to/multi_materials
  29523. */
  29524. export class MultiMaterial extends Material {
  29525. private _subMaterials;
  29526. /**
  29527. * Gets or Sets the list of Materials used within the multi material.
  29528. * They need to be ordered according to the submeshes order in the associated mesh
  29529. */
  29530. get subMaterials(): Nullable<Material>[];
  29531. set subMaterials(value: Nullable<Material>[]);
  29532. /**
  29533. * Function used to align with Node.getChildren()
  29534. * @returns the list of Materials used within the multi material
  29535. */
  29536. getChildren(): Nullable<Material>[];
  29537. /**
  29538. * Instantiates a new Multi Material
  29539. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29540. * separate meshes. This can be use to improve performances.
  29541. * @see https://doc.babylonjs.com/how_to/multi_materials
  29542. * @param name Define the name in the scene
  29543. * @param scene Define the scene the material belongs to
  29544. */
  29545. constructor(name: string, scene: Scene);
  29546. private _hookArray;
  29547. /**
  29548. * Get one of the submaterial by its index in the submaterials array
  29549. * @param index The index to look the sub material at
  29550. * @returns The Material if the index has been defined
  29551. */
  29552. getSubMaterial(index: number): Nullable<Material>;
  29553. /**
  29554. * Get the list of active textures for the whole sub materials list.
  29555. * @returns All the textures that will be used during the rendering
  29556. */
  29557. getActiveTextures(): BaseTexture[];
  29558. /**
  29559. * Gets the current class name of the material e.g. "MultiMaterial"
  29560. * Mainly use in serialization.
  29561. * @returns the class name
  29562. */
  29563. getClassName(): string;
  29564. /**
  29565. * Checks if the material is ready to render the requested sub mesh
  29566. * @param mesh Define the mesh the submesh belongs to
  29567. * @param subMesh Define the sub mesh to look readyness for
  29568. * @param useInstances Define whether or not the material is used with instances
  29569. * @returns true if ready, otherwise false
  29570. */
  29571. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29572. /**
  29573. * Clones the current material and its related sub materials
  29574. * @param name Define the name of the newly cloned material
  29575. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29576. * @returns the cloned material
  29577. */
  29578. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29579. /**
  29580. * Serializes the materials into a JSON representation.
  29581. * @returns the JSON representation
  29582. */
  29583. serialize(): any;
  29584. /**
  29585. * Dispose the material and release its associated resources
  29586. * @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)
  29587. * @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)
  29588. * @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)
  29589. */
  29590. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29591. /**
  29592. * Creates a MultiMaterial from parsed MultiMaterial data.
  29593. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29594. * @param scene defines the hosting scene
  29595. * @returns a new MultiMaterial
  29596. */
  29597. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29598. }
  29599. }
  29600. declare module BABYLON {
  29601. /**
  29602. * Defines a subdivision inside a mesh
  29603. */
  29604. export class SubMesh implements ICullable {
  29605. /** the material index to use */
  29606. materialIndex: number;
  29607. /** vertex index start */
  29608. verticesStart: number;
  29609. /** vertices count */
  29610. verticesCount: number;
  29611. /** index start */
  29612. indexStart: number;
  29613. /** indices count */
  29614. indexCount: number;
  29615. /** @hidden */
  29616. _materialDefines: Nullable<MaterialDefines>;
  29617. /** @hidden */
  29618. _materialEffect: Nullable<Effect>;
  29619. /** @hidden */
  29620. _effectOverride: Nullable<Effect>;
  29621. /**
  29622. * Gets material defines used by the effect associated to the sub mesh
  29623. */
  29624. get materialDefines(): Nullable<MaterialDefines>;
  29625. /**
  29626. * Sets material defines used by the effect associated to the sub mesh
  29627. */
  29628. set materialDefines(defines: Nullable<MaterialDefines>);
  29629. /**
  29630. * Gets associated effect
  29631. */
  29632. get effect(): Nullable<Effect>;
  29633. /**
  29634. * Sets associated effect (effect used to render this submesh)
  29635. * @param effect defines the effect to associate with
  29636. * @param defines defines the set of defines used to compile this effect
  29637. */
  29638. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29639. /** @hidden */
  29640. _linesIndexCount: number;
  29641. private _mesh;
  29642. private _renderingMesh;
  29643. private _boundingInfo;
  29644. private _linesIndexBuffer;
  29645. /** @hidden */
  29646. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29647. /** @hidden */
  29648. _trianglePlanes: Plane[];
  29649. /** @hidden */
  29650. _lastColliderTransformMatrix: Nullable<Matrix>;
  29651. /** @hidden */
  29652. _renderId: number;
  29653. /** @hidden */
  29654. _alphaIndex: number;
  29655. /** @hidden */
  29656. _distanceToCamera: number;
  29657. /** @hidden */
  29658. _id: number;
  29659. private _currentMaterial;
  29660. /**
  29661. * Add a new submesh to a mesh
  29662. * @param materialIndex defines the material index to use
  29663. * @param verticesStart defines vertex index start
  29664. * @param verticesCount defines vertices count
  29665. * @param indexStart defines index start
  29666. * @param indexCount defines indices count
  29667. * @param mesh defines the parent mesh
  29668. * @param renderingMesh defines an optional rendering mesh
  29669. * @param createBoundingBox defines if bounding box should be created for this submesh
  29670. * @returns the new submesh
  29671. */
  29672. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29673. /**
  29674. * Creates a new submesh
  29675. * @param materialIndex defines the material index to use
  29676. * @param verticesStart defines vertex index start
  29677. * @param verticesCount defines vertices count
  29678. * @param indexStart defines index start
  29679. * @param indexCount defines indices count
  29680. * @param mesh defines the parent mesh
  29681. * @param renderingMesh defines an optional rendering mesh
  29682. * @param createBoundingBox defines if bounding box should be created for this submesh
  29683. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29684. */
  29685. constructor(
  29686. /** the material index to use */
  29687. materialIndex: number,
  29688. /** vertex index start */
  29689. verticesStart: number,
  29690. /** vertices count */
  29691. verticesCount: number,
  29692. /** index start */
  29693. indexStart: number,
  29694. /** indices count */
  29695. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29696. /**
  29697. * Returns true if this submesh covers the entire parent mesh
  29698. * @ignorenaming
  29699. */
  29700. get IsGlobal(): boolean;
  29701. /**
  29702. * Returns the submesh BoudingInfo object
  29703. * @returns current bounding info (or mesh's one if the submesh is global)
  29704. */
  29705. getBoundingInfo(): BoundingInfo;
  29706. /**
  29707. * Sets the submesh BoundingInfo
  29708. * @param boundingInfo defines the new bounding info to use
  29709. * @returns the SubMesh
  29710. */
  29711. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29712. /**
  29713. * Returns the mesh of the current submesh
  29714. * @return the parent mesh
  29715. */
  29716. getMesh(): AbstractMesh;
  29717. /**
  29718. * Returns the rendering mesh of the submesh
  29719. * @returns the rendering mesh (could be different from parent mesh)
  29720. */
  29721. getRenderingMesh(): Mesh;
  29722. /**
  29723. * Returns the replacement mesh of the submesh
  29724. * @returns the replacement mesh (could be different from parent mesh)
  29725. */
  29726. getReplacementMesh(): Nullable<AbstractMesh>;
  29727. /**
  29728. * Returns the effective mesh of the submesh
  29729. * @returns the effective mesh (could be different from parent mesh)
  29730. */
  29731. getEffectiveMesh(): AbstractMesh;
  29732. /**
  29733. * Returns the submesh material
  29734. * @returns null or the current material
  29735. */
  29736. getMaterial(): Nullable<Material>;
  29737. private _IsMultiMaterial;
  29738. /**
  29739. * Sets a new updated BoundingInfo object to the submesh
  29740. * @param data defines an optional position array to use to determine the bounding info
  29741. * @returns the SubMesh
  29742. */
  29743. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  29744. /** @hidden */
  29745. _checkCollision(collider: Collider): boolean;
  29746. /**
  29747. * Updates the submesh BoundingInfo
  29748. * @param world defines the world matrix to use to update the bounding info
  29749. * @returns the submesh
  29750. */
  29751. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29752. /**
  29753. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29754. * @param frustumPlanes defines the frustum planes
  29755. * @returns true if the submesh is intersecting with the frustum
  29756. */
  29757. isInFrustum(frustumPlanes: Plane[]): boolean;
  29758. /**
  29759. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29760. * @param frustumPlanes defines the frustum planes
  29761. * @returns true if the submesh is inside the frustum
  29762. */
  29763. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29764. /**
  29765. * Renders the submesh
  29766. * @param enableAlphaMode defines if alpha needs to be used
  29767. * @returns the submesh
  29768. */
  29769. render(enableAlphaMode: boolean): SubMesh;
  29770. /**
  29771. * @hidden
  29772. */
  29773. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  29774. /**
  29775. * Checks if the submesh intersects with a ray
  29776. * @param ray defines the ray to test
  29777. * @returns true is the passed ray intersects the submesh bounding box
  29778. */
  29779. canIntersects(ray: Ray): boolean;
  29780. /**
  29781. * Intersects current submesh with a ray
  29782. * @param ray defines the ray to test
  29783. * @param positions defines mesh's positions array
  29784. * @param indices defines mesh's indices array
  29785. * @param fastCheck defines if the first intersection will be used (and not the closest)
  29786. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29787. * @returns intersection info or null if no intersection
  29788. */
  29789. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  29790. /** @hidden */
  29791. private _intersectLines;
  29792. /** @hidden */
  29793. private _intersectUnIndexedLines;
  29794. /** @hidden */
  29795. private _intersectTriangles;
  29796. /** @hidden */
  29797. private _intersectUnIndexedTriangles;
  29798. /** @hidden */
  29799. _rebuild(): void;
  29800. /**
  29801. * Creates a new submesh from the passed mesh
  29802. * @param newMesh defines the new hosting mesh
  29803. * @param newRenderingMesh defines an optional rendering mesh
  29804. * @returns the new submesh
  29805. */
  29806. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29807. /**
  29808. * Release associated resources
  29809. */
  29810. dispose(): void;
  29811. /**
  29812. * Gets the class name
  29813. * @returns the string "SubMesh".
  29814. */
  29815. getClassName(): string;
  29816. /**
  29817. * Creates a new submesh from indices data
  29818. * @param materialIndex the index of the main mesh material
  29819. * @param startIndex the index where to start the copy in the mesh indices array
  29820. * @param indexCount the number of indices to copy then from the startIndex
  29821. * @param mesh the main mesh to create the submesh from
  29822. * @param renderingMesh the optional rendering mesh
  29823. * @returns a new submesh
  29824. */
  29825. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29826. }
  29827. }
  29828. declare module BABYLON {
  29829. /**
  29830. * Class used to represent data loading progression
  29831. */
  29832. export class SceneLoaderFlags {
  29833. private static _ForceFullSceneLoadingForIncremental;
  29834. private static _ShowLoadingScreen;
  29835. private static _CleanBoneMatrixWeights;
  29836. private static _loggingLevel;
  29837. /**
  29838. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  29839. */
  29840. static get ForceFullSceneLoadingForIncremental(): boolean;
  29841. static set ForceFullSceneLoadingForIncremental(value: boolean);
  29842. /**
  29843. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  29844. */
  29845. static get ShowLoadingScreen(): boolean;
  29846. static set ShowLoadingScreen(value: boolean);
  29847. /**
  29848. * Defines the current logging level (while loading the scene)
  29849. * @ignorenaming
  29850. */
  29851. static get loggingLevel(): number;
  29852. static set loggingLevel(value: number);
  29853. /**
  29854. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  29855. */
  29856. static get CleanBoneMatrixWeights(): boolean;
  29857. static set CleanBoneMatrixWeights(value: boolean);
  29858. }
  29859. }
  29860. declare module BABYLON {
  29861. /**
  29862. * Class used to store geometry data (vertex buffers + index buffer)
  29863. */
  29864. export class Geometry implements IGetSetVerticesData {
  29865. /**
  29866. * Gets or sets the ID of the geometry
  29867. */
  29868. id: string;
  29869. /**
  29870. * Gets or sets the unique ID of the geometry
  29871. */
  29872. uniqueId: number;
  29873. /**
  29874. * Gets the delay loading state of the geometry (none by default which means not delayed)
  29875. */
  29876. delayLoadState: number;
  29877. /**
  29878. * Gets the file containing the data to load when running in delay load state
  29879. */
  29880. delayLoadingFile: Nullable<string>;
  29881. /**
  29882. * Callback called when the geometry is updated
  29883. */
  29884. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  29885. private _scene;
  29886. private _engine;
  29887. private _meshes;
  29888. private _totalVertices;
  29889. /** @hidden */
  29890. _indices: IndicesArray;
  29891. /** @hidden */
  29892. _vertexBuffers: {
  29893. [key: string]: VertexBuffer;
  29894. };
  29895. private _isDisposed;
  29896. private _extend;
  29897. private _boundingBias;
  29898. /** @hidden */
  29899. _delayInfo: Array<string>;
  29900. private _indexBuffer;
  29901. private _indexBufferIsUpdatable;
  29902. /** @hidden */
  29903. _boundingInfo: Nullable<BoundingInfo>;
  29904. /** @hidden */
  29905. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  29906. /** @hidden */
  29907. _softwareSkinningFrameId: number;
  29908. private _vertexArrayObjects;
  29909. private _updatable;
  29910. /** @hidden */
  29911. _positions: Nullable<Vector3[]>;
  29912. /**
  29913. * 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
  29914. */
  29915. get boundingBias(): Vector2;
  29916. /**
  29917. * 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
  29918. */
  29919. set boundingBias(value: Vector2);
  29920. /**
  29921. * Static function used to attach a new empty geometry to a mesh
  29922. * @param mesh defines the mesh to attach the geometry to
  29923. * @returns the new Geometry
  29924. */
  29925. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  29926. /** Get the list of meshes using this geometry */
  29927. get meshes(): Mesh[];
  29928. /**
  29929. * 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
  29930. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  29931. */
  29932. useBoundingInfoFromGeometry: boolean;
  29933. /**
  29934. * Creates a new geometry
  29935. * @param id defines the unique ID
  29936. * @param scene defines the hosting scene
  29937. * @param vertexData defines the VertexData used to get geometry data
  29938. * @param updatable defines if geometry must be updatable (false by default)
  29939. * @param mesh defines the mesh that will be associated with the geometry
  29940. */
  29941. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  29942. /**
  29943. * Gets the current extend of the geometry
  29944. */
  29945. get extend(): {
  29946. minimum: Vector3;
  29947. maximum: Vector3;
  29948. };
  29949. /**
  29950. * Gets the hosting scene
  29951. * @returns the hosting Scene
  29952. */
  29953. getScene(): Scene;
  29954. /**
  29955. * Gets the hosting engine
  29956. * @returns the hosting Engine
  29957. */
  29958. getEngine(): Engine;
  29959. /**
  29960. * Defines if the geometry is ready to use
  29961. * @returns true if the geometry is ready to be used
  29962. */
  29963. isReady(): boolean;
  29964. /**
  29965. * Gets a value indicating that the geometry should not be serialized
  29966. */
  29967. get doNotSerialize(): boolean;
  29968. /** @hidden */
  29969. _rebuild(): void;
  29970. /**
  29971. * Affects all geometry data in one call
  29972. * @param vertexData defines the geometry data
  29973. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  29974. */
  29975. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  29976. /**
  29977. * Set specific vertex data
  29978. * @param kind defines the data kind (Position, normal, etc...)
  29979. * @param data defines the vertex data to use
  29980. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  29981. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  29982. */
  29983. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  29984. /**
  29985. * Removes a specific vertex data
  29986. * @param kind defines the data kind (Position, normal, etc...)
  29987. */
  29988. removeVerticesData(kind: string): void;
  29989. /**
  29990. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  29991. * @param buffer defines the vertex buffer to use
  29992. * @param totalVertices defines the total number of vertices for position kind (could be null)
  29993. */
  29994. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  29995. /**
  29996. * Update a specific vertex buffer
  29997. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  29998. * It will do nothing if the buffer is not updatable
  29999. * @param kind defines the data kind (Position, normal, etc...)
  30000. * @param data defines the data to use
  30001. * @param offset defines the offset in the target buffer where to store the data
  30002. * @param useBytes set to true if the offset is in bytes
  30003. */
  30004. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30005. /**
  30006. * Update a specific vertex buffer
  30007. * This function will create a new buffer if the current one is not updatable
  30008. * @param kind defines the data kind (Position, normal, etc...)
  30009. * @param data defines the data to use
  30010. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30011. */
  30012. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30013. private _updateBoundingInfo;
  30014. /** @hidden */
  30015. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30016. /**
  30017. * Gets total number of vertices
  30018. * @returns the total number of vertices
  30019. */
  30020. getTotalVertices(): number;
  30021. /**
  30022. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30023. * @param kind defines the data kind (Position, normal, etc...)
  30024. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30025. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30026. * @returns a float array containing vertex data
  30027. */
  30028. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30029. /**
  30030. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30031. * @param kind defines the data kind (Position, normal, etc...)
  30032. * @returns true if the vertex buffer with the specified kind is updatable
  30033. */
  30034. isVertexBufferUpdatable(kind: string): boolean;
  30035. /**
  30036. * Gets a specific vertex buffer
  30037. * @param kind defines the data kind (Position, normal, etc...)
  30038. * @returns a VertexBuffer
  30039. */
  30040. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30041. /**
  30042. * Returns all vertex buffers
  30043. * @return an object holding all vertex buffers indexed by kind
  30044. */
  30045. getVertexBuffers(): Nullable<{
  30046. [key: string]: VertexBuffer;
  30047. }>;
  30048. /**
  30049. * Gets a boolean indicating if specific vertex buffer is present
  30050. * @param kind defines the data kind (Position, normal, etc...)
  30051. * @returns true if data is present
  30052. */
  30053. isVerticesDataPresent(kind: string): boolean;
  30054. /**
  30055. * Gets a list of all attached data kinds (Position, normal, etc...)
  30056. * @returns a list of string containing all kinds
  30057. */
  30058. getVerticesDataKinds(): string[];
  30059. /**
  30060. * Update index buffer
  30061. * @param indices defines the indices to store in the index buffer
  30062. * @param offset defines the offset in the target buffer where to store the data
  30063. * @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)
  30064. */
  30065. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30066. /**
  30067. * Creates a new index buffer
  30068. * @param indices defines the indices to store in the index buffer
  30069. * @param totalVertices defines the total number of vertices (could be null)
  30070. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30071. */
  30072. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30073. /**
  30074. * Return the total number of indices
  30075. * @returns the total number of indices
  30076. */
  30077. getTotalIndices(): number;
  30078. /**
  30079. * Gets the index buffer array
  30080. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30081. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30082. * @returns the index buffer array
  30083. */
  30084. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30085. /**
  30086. * Gets the index buffer
  30087. * @return the index buffer
  30088. */
  30089. getIndexBuffer(): Nullable<DataBuffer>;
  30090. /** @hidden */
  30091. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30092. /**
  30093. * Release the associated resources for a specific mesh
  30094. * @param mesh defines the source mesh
  30095. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30096. */
  30097. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30098. /**
  30099. * Apply current geometry to a given mesh
  30100. * @param mesh defines the mesh to apply geometry to
  30101. */
  30102. applyToMesh(mesh: Mesh): void;
  30103. private _updateExtend;
  30104. private _applyToMesh;
  30105. private notifyUpdate;
  30106. /**
  30107. * Load the geometry if it was flagged as delay loaded
  30108. * @param scene defines the hosting scene
  30109. * @param onLoaded defines a callback called when the geometry is loaded
  30110. */
  30111. load(scene: Scene, onLoaded?: () => void): void;
  30112. private _queueLoad;
  30113. /**
  30114. * Invert the geometry to move from a right handed system to a left handed one.
  30115. */
  30116. toLeftHanded(): void;
  30117. /** @hidden */
  30118. _resetPointsArrayCache(): void;
  30119. /** @hidden */
  30120. _generatePointsArray(): boolean;
  30121. /**
  30122. * Gets a value indicating if the geometry is disposed
  30123. * @returns true if the geometry was disposed
  30124. */
  30125. isDisposed(): boolean;
  30126. private _disposeVertexArrayObjects;
  30127. /**
  30128. * Free all associated resources
  30129. */
  30130. dispose(): void;
  30131. /**
  30132. * Clone the current geometry into a new geometry
  30133. * @param id defines the unique ID of the new geometry
  30134. * @returns a new geometry object
  30135. */
  30136. copy(id: string): Geometry;
  30137. /**
  30138. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30139. * @return a JSON representation of the current geometry data (without the vertices data)
  30140. */
  30141. serialize(): any;
  30142. private toNumberArray;
  30143. /**
  30144. * Serialize all vertices data into a JSON oject
  30145. * @returns a JSON representation of the current geometry data
  30146. */
  30147. serializeVerticeData(): any;
  30148. /**
  30149. * Extracts a clone of a mesh geometry
  30150. * @param mesh defines the source mesh
  30151. * @param id defines the unique ID of the new geometry object
  30152. * @returns the new geometry object
  30153. */
  30154. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30155. /**
  30156. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30157. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30158. * Be aware Math.random() could cause collisions, but:
  30159. * "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"
  30160. * @returns a string containing a new GUID
  30161. */
  30162. static RandomId(): string;
  30163. /** @hidden */
  30164. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30165. private static _CleanMatricesWeights;
  30166. /**
  30167. * Create a new geometry from persisted data (Using .babylon file format)
  30168. * @param parsedVertexData defines the persisted data
  30169. * @param scene defines the hosting scene
  30170. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30171. * @returns the new geometry object
  30172. */
  30173. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30174. }
  30175. }
  30176. declare module BABYLON {
  30177. /**
  30178. * Define an interface for all classes that will get and set the data on vertices
  30179. */
  30180. export interface IGetSetVerticesData {
  30181. /**
  30182. * Gets a boolean indicating if specific vertex data is present
  30183. * @param kind defines the vertex data kind to use
  30184. * @returns true is data kind is present
  30185. */
  30186. isVerticesDataPresent(kind: string): boolean;
  30187. /**
  30188. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30189. * @param kind defines the data kind (Position, normal, etc...)
  30190. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30191. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30192. * @returns a float array containing vertex data
  30193. */
  30194. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30195. /**
  30196. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30197. * @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.
  30198. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30199. * @returns the indices array or an empty array if the mesh has no geometry
  30200. */
  30201. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30202. /**
  30203. * Set specific vertex data
  30204. * @param kind defines the data kind (Position, normal, etc...)
  30205. * @param data defines the vertex data to use
  30206. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30207. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30208. */
  30209. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30210. /**
  30211. * Update a specific associated vertex buffer
  30212. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30213. * - VertexBuffer.PositionKind
  30214. * - VertexBuffer.UVKind
  30215. * - VertexBuffer.UV2Kind
  30216. * - VertexBuffer.UV3Kind
  30217. * - VertexBuffer.UV4Kind
  30218. * - VertexBuffer.UV5Kind
  30219. * - VertexBuffer.UV6Kind
  30220. * - VertexBuffer.ColorKind
  30221. * - VertexBuffer.MatricesIndicesKind
  30222. * - VertexBuffer.MatricesIndicesExtraKind
  30223. * - VertexBuffer.MatricesWeightsKind
  30224. * - VertexBuffer.MatricesWeightsExtraKind
  30225. * @param data defines the data source
  30226. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30227. * @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)
  30228. */
  30229. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30230. /**
  30231. * Creates a new index buffer
  30232. * @param indices defines the indices to store in the index buffer
  30233. * @param totalVertices defines the total number of vertices (could be null)
  30234. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30235. */
  30236. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30237. }
  30238. /**
  30239. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30240. */
  30241. export class VertexData {
  30242. /**
  30243. * Mesh side orientation : usually the external or front surface
  30244. */
  30245. static readonly FRONTSIDE: number;
  30246. /**
  30247. * Mesh side orientation : usually the internal or back surface
  30248. */
  30249. static readonly BACKSIDE: number;
  30250. /**
  30251. * Mesh side orientation : both internal and external or front and back surfaces
  30252. */
  30253. static readonly DOUBLESIDE: number;
  30254. /**
  30255. * Mesh side orientation : by default, `FRONTSIDE`
  30256. */
  30257. static readonly DEFAULTSIDE: number;
  30258. /**
  30259. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30260. */
  30261. positions: Nullable<FloatArray>;
  30262. /**
  30263. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30264. */
  30265. normals: Nullable<FloatArray>;
  30266. /**
  30267. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30268. */
  30269. tangents: Nullable<FloatArray>;
  30270. /**
  30271. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30272. */
  30273. uvs: Nullable<FloatArray>;
  30274. /**
  30275. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30276. */
  30277. uvs2: Nullable<FloatArray>;
  30278. /**
  30279. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30280. */
  30281. uvs3: Nullable<FloatArray>;
  30282. /**
  30283. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30284. */
  30285. uvs4: Nullable<FloatArray>;
  30286. /**
  30287. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30288. */
  30289. uvs5: Nullable<FloatArray>;
  30290. /**
  30291. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30292. */
  30293. uvs6: Nullable<FloatArray>;
  30294. /**
  30295. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30296. */
  30297. colors: Nullable<FloatArray>;
  30298. /**
  30299. * 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).
  30300. */
  30301. matricesIndices: Nullable<FloatArray>;
  30302. /**
  30303. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30304. */
  30305. matricesWeights: Nullable<FloatArray>;
  30306. /**
  30307. * An array extending the number of possible indices
  30308. */
  30309. matricesIndicesExtra: Nullable<FloatArray>;
  30310. /**
  30311. * An array extending the number of possible weights when the number of indices is extended
  30312. */
  30313. matricesWeightsExtra: Nullable<FloatArray>;
  30314. /**
  30315. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30316. */
  30317. indices: Nullable<IndicesArray>;
  30318. /**
  30319. * Uses the passed data array to set the set the values for the specified kind of data
  30320. * @param data a linear array of floating numbers
  30321. * @param kind the type of data that is being set, eg positions, colors etc
  30322. */
  30323. set(data: FloatArray, kind: string): void;
  30324. /**
  30325. * Associates the vertexData to the passed Mesh.
  30326. * Sets it as updatable or not (default `false`)
  30327. * @param mesh the mesh the vertexData is applied to
  30328. * @param updatable when used and having the value true allows new data to update the vertexData
  30329. * @returns the VertexData
  30330. */
  30331. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30332. /**
  30333. * Associates the vertexData to the passed Geometry.
  30334. * Sets it as updatable or not (default `false`)
  30335. * @param geometry the geometry the vertexData is applied to
  30336. * @param updatable when used and having the value true allows new data to update the vertexData
  30337. * @returns VertexData
  30338. */
  30339. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30340. /**
  30341. * Updates the associated mesh
  30342. * @param mesh the mesh to be updated
  30343. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30344. * @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
  30345. * @returns VertexData
  30346. */
  30347. updateMesh(mesh: Mesh): VertexData;
  30348. /**
  30349. * Updates the associated geometry
  30350. * @param geometry the geometry to be updated
  30351. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30352. * @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
  30353. * @returns VertexData.
  30354. */
  30355. updateGeometry(geometry: Geometry): VertexData;
  30356. private _applyTo;
  30357. private _update;
  30358. /**
  30359. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30360. * @param matrix the transforming matrix
  30361. * @returns the VertexData
  30362. */
  30363. transform(matrix: Matrix): VertexData;
  30364. /**
  30365. * Merges the passed VertexData into the current one
  30366. * @param other the VertexData to be merged into the current one
  30367. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30368. * @returns the modified VertexData
  30369. */
  30370. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30371. private _mergeElement;
  30372. private _validate;
  30373. /**
  30374. * Serializes the VertexData
  30375. * @returns a serialized object
  30376. */
  30377. serialize(): any;
  30378. /**
  30379. * Extracts the vertexData from a mesh
  30380. * @param mesh the mesh from which to extract the VertexData
  30381. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30382. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30383. * @returns the object VertexData associated to the passed mesh
  30384. */
  30385. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30386. /**
  30387. * Extracts the vertexData from the geometry
  30388. * @param geometry the geometry from which to extract the VertexData
  30389. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30390. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30391. * @returns the object VertexData associated to the passed mesh
  30392. */
  30393. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30394. private static _ExtractFrom;
  30395. /**
  30396. * Creates the VertexData for a Ribbon
  30397. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30398. * * pathArray array of paths, each of which an array of successive Vector3
  30399. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30400. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30401. * * 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
  30402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30403. * * 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)
  30404. * * 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)
  30405. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30406. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30407. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30408. * @returns the VertexData of the ribbon
  30409. */
  30410. static CreateRibbon(options: {
  30411. pathArray: Vector3[][];
  30412. closeArray?: boolean;
  30413. closePath?: boolean;
  30414. offset?: number;
  30415. sideOrientation?: number;
  30416. frontUVs?: Vector4;
  30417. backUVs?: Vector4;
  30418. invertUV?: boolean;
  30419. uvs?: Vector2[];
  30420. colors?: Color4[];
  30421. }): VertexData;
  30422. /**
  30423. * Creates the VertexData for a box
  30424. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30425. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30426. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30427. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30428. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30429. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30430. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30431. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30432. * * 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)
  30433. * * 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)
  30434. * @returns the VertexData of the box
  30435. */
  30436. static CreateBox(options: {
  30437. size?: number;
  30438. width?: number;
  30439. height?: number;
  30440. depth?: number;
  30441. faceUV?: Vector4[];
  30442. faceColors?: Color4[];
  30443. sideOrientation?: number;
  30444. frontUVs?: Vector4;
  30445. backUVs?: Vector4;
  30446. }): VertexData;
  30447. /**
  30448. * Creates the VertexData for a tiled box
  30449. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30450. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30451. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30452. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30453. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30454. * @returns the VertexData of the box
  30455. */
  30456. static CreateTiledBox(options: {
  30457. pattern?: number;
  30458. width?: number;
  30459. height?: number;
  30460. depth?: number;
  30461. tileSize?: number;
  30462. tileWidth?: number;
  30463. tileHeight?: number;
  30464. alignHorizontal?: number;
  30465. alignVertical?: number;
  30466. faceUV?: Vector4[];
  30467. faceColors?: Color4[];
  30468. sideOrientation?: number;
  30469. }): VertexData;
  30470. /**
  30471. * Creates the VertexData for a tiled plane
  30472. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30473. * * pattern a limited pattern arrangement depending on the number
  30474. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30475. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30476. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30478. * * 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)
  30479. * * 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)
  30480. * @returns the VertexData of the tiled plane
  30481. */
  30482. static CreateTiledPlane(options: {
  30483. pattern?: number;
  30484. tileSize?: number;
  30485. tileWidth?: number;
  30486. tileHeight?: number;
  30487. size?: number;
  30488. width?: number;
  30489. height?: number;
  30490. alignHorizontal?: number;
  30491. alignVertical?: number;
  30492. sideOrientation?: number;
  30493. frontUVs?: Vector4;
  30494. backUVs?: Vector4;
  30495. }): VertexData;
  30496. /**
  30497. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30498. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30499. * * segments sets the number of horizontal strips optional, default 32
  30500. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30501. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30502. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30503. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30504. * * 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
  30505. * * 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
  30506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30507. * * 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)
  30508. * * 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)
  30509. * @returns the VertexData of the ellipsoid
  30510. */
  30511. static CreateSphere(options: {
  30512. segments?: number;
  30513. diameter?: number;
  30514. diameterX?: number;
  30515. diameterY?: number;
  30516. diameterZ?: number;
  30517. arc?: number;
  30518. slice?: number;
  30519. sideOrientation?: number;
  30520. frontUVs?: Vector4;
  30521. backUVs?: Vector4;
  30522. }): VertexData;
  30523. /**
  30524. * Creates the VertexData for a cylinder, cone or prism
  30525. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30526. * * height sets the height (y direction) of the cylinder, optional, default 2
  30527. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30528. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30529. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30530. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30531. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30532. * * 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
  30533. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30534. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30535. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30536. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30537. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30538. * * 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)
  30539. * * 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)
  30540. * @returns the VertexData of the cylinder, cone or prism
  30541. */
  30542. static CreateCylinder(options: {
  30543. height?: number;
  30544. diameterTop?: number;
  30545. diameterBottom?: number;
  30546. diameter?: number;
  30547. tessellation?: number;
  30548. subdivisions?: number;
  30549. arc?: number;
  30550. faceColors?: Color4[];
  30551. faceUV?: Vector4[];
  30552. hasRings?: boolean;
  30553. enclose?: boolean;
  30554. sideOrientation?: number;
  30555. frontUVs?: Vector4;
  30556. backUVs?: Vector4;
  30557. }): VertexData;
  30558. /**
  30559. * Creates the VertexData for a torus
  30560. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30561. * * diameter the diameter of the torus, optional default 1
  30562. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30563. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30565. * * 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)
  30566. * * 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)
  30567. * @returns the VertexData of the torus
  30568. */
  30569. static CreateTorus(options: {
  30570. diameter?: number;
  30571. thickness?: number;
  30572. tessellation?: number;
  30573. sideOrientation?: number;
  30574. frontUVs?: Vector4;
  30575. backUVs?: Vector4;
  30576. }): VertexData;
  30577. /**
  30578. * Creates the VertexData of the LineSystem
  30579. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30580. * - lines an array of lines, each line being an array of successive Vector3
  30581. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30582. * @returns the VertexData of the LineSystem
  30583. */
  30584. static CreateLineSystem(options: {
  30585. lines: Vector3[][];
  30586. colors?: Nullable<Color4[][]>;
  30587. }): VertexData;
  30588. /**
  30589. * Create the VertexData for a DashedLines
  30590. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30591. * - points an array successive Vector3
  30592. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30593. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30594. * - dashNb the intended total number of dashes, optional, default 200
  30595. * @returns the VertexData for the DashedLines
  30596. */
  30597. static CreateDashedLines(options: {
  30598. points: Vector3[];
  30599. dashSize?: number;
  30600. gapSize?: number;
  30601. dashNb?: number;
  30602. }): VertexData;
  30603. /**
  30604. * Creates the VertexData for a Ground
  30605. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30606. * - width the width (x direction) of the ground, optional, default 1
  30607. * - height the height (z direction) of the ground, optional, default 1
  30608. * - subdivisions the number of subdivisions per side, optional, default 1
  30609. * @returns the VertexData of the Ground
  30610. */
  30611. static CreateGround(options: {
  30612. width?: number;
  30613. height?: number;
  30614. subdivisions?: number;
  30615. subdivisionsX?: number;
  30616. subdivisionsY?: number;
  30617. }): VertexData;
  30618. /**
  30619. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30620. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30621. * * xmin the ground minimum X coordinate, optional, default -1
  30622. * * zmin the ground minimum Z coordinate, optional, default -1
  30623. * * xmax the ground maximum X coordinate, optional, default 1
  30624. * * zmax the ground maximum Z coordinate, optional, default 1
  30625. * * 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}
  30626. * * 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}
  30627. * @returns the VertexData of the TiledGround
  30628. */
  30629. static CreateTiledGround(options: {
  30630. xmin: number;
  30631. zmin: number;
  30632. xmax: number;
  30633. zmax: number;
  30634. subdivisions?: {
  30635. w: number;
  30636. h: number;
  30637. };
  30638. precision?: {
  30639. w: number;
  30640. h: number;
  30641. };
  30642. }): VertexData;
  30643. /**
  30644. * Creates the VertexData of the Ground designed from a heightmap
  30645. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30646. * * width the width (x direction) of the ground
  30647. * * height the height (z direction) of the ground
  30648. * * subdivisions the number of subdivisions per side
  30649. * * minHeight the minimum altitude on the ground, optional, default 0
  30650. * * maxHeight the maximum altitude on the ground, optional default 1
  30651. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30652. * * buffer the array holding the image color data
  30653. * * bufferWidth the width of image
  30654. * * bufferHeight the height of image
  30655. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30656. * @returns the VertexData of the Ground designed from a heightmap
  30657. */
  30658. static CreateGroundFromHeightMap(options: {
  30659. width: number;
  30660. height: number;
  30661. subdivisions: number;
  30662. minHeight: number;
  30663. maxHeight: number;
  30664. colorFilter: Color3;
  30665. buffer: Uint8Array;
  30666. bufferWidth: number;
  30667. bufferHeight: number;
  30668. alphaFilter: number;
  30669. }): VertexData;
  30670. /**
  30671. * Creates the VertexData for a Plane
  30672. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30673. * * size sets the width and height of the plane to the value of size, optional default 1
  30674. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30675. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30676. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30677. * * 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)
  30678. * * 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)
  30679. * @returns the VertexData of the box
  30680. */
  30681. static CreatePlane(options: {
  30682. size?: number;
  30683. width?: number;
  30684. height?: number;
  30685. sideOrientation?: number;
  30686. frontUVs?: Vector4;
  30687. backUVs?: Vector4;
  30688. }): VertexData;
  30689. /**
  30690. * Creates the VertexData of the Disc or regular Polygon
  30691. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30692. * * radius the radius of the disc, optional default 0.5
  30693. * * tessellation the number of polygon sides, optional, default 64
  30694. * * 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
  30695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30696. * * 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)
  30697. * * 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)
  30698. * @returns the VertexData of the box
  30699. */
  30700. static CreateDisc(options: {
  30701. radius?: number;
  30702. tessellation?: number;
  30703. arc?: number;
  30704. sideOrientation?: number;
  30705. frontUVs?: Vector4;
  30706. backUVs?: Vector4;
  30707. }): VertexData;
  30708. /**
  30709. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30710. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30711. * @param polygon a mesh built from polygonTriangulation.build()
  30712. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30713. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30714. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30715. * @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)
  30716. * @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)
  30717. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30718. * @returns the VertexData of the Polygon
  30719. */
  30720. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30721. /**
  30722. * Creates the VertexData of the IcoSphere
  30723. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30724. * * radius the radius of the IcoSphere, optional default 1
  30725. * * radiusX allows stretching in the x direction, optional, default radius
  30726. * * radiusY allows stretching in the y direction, optional, default radius
  30727. * * radiusZ allows stretching in the z direction, optional, default radius
  30728. * * flat when true creates a flat shaded mesh, optional, default true
  30729. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30731. * * 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)
  30732. * * 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)
  30733. * @returns the VertexData of the IcoSphere
  30734. */
  30735. static CreateIcoSphere(options: {
  30736. radius?: number;
  30737. radiusX?: number;
  30738. radiusY?: number;
  30739. radiusZ?: number;
  30740. flat?: boolean;
  30741. subdivisions?: number;
  30742. sideOrientation?: number;
  30743. frontUVs?: Vector4;
  30744. backUVs?: Vector4;
  30745. }): VertexData;
  30746. /**
  30747. * Creates the VertexData for a Polyhedron
  30748. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  30749. * * type provided types are:
  30750. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  30751. * * 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)
  30752. * * size the size of the IcoSphere, optional default 1
  30753. * * sizeX allows stretching in the x direction, optional, default size
  30754. * * sizeY allows stretching in the y direction, optional, default size
  30755. * * sizeZ allows stretching in the z direction, optional, default size
  30756. * * 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
  30757. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30758. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30759. * * flat when true creates a flat shaded mesh, optional, default true
  30760. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30762. * * 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)
  30763. * * 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)
  30764. * @returns the VertexData of the Polyhedron
  30765. */
  30766. static CreatePolyhedron(options: {
  30767. type?: number;
  30768. size?: number;
  30769. sizeX?: number;
  30770. sizeY?: number;
  30771. sizeZ?: number;
  30772. custom?: any;
  30773. faceUV?: Vector4[];
  30774. faceColors?: Color4[];
  30775. flat?: boolean;
  30776. sideOrientation?: number;
  30777. frontUVs?: Vector4;
  30778. backUVs?: Vector4;
  30779. }): VertexData;
  30780. /**
  30781. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  30782. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  30783. * @returns the VertexData of the Capsule
  30784. */
  30785. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  30786. /**
  30787. * Creates the VertexData for a TorusKnot
  30788. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  30789. * * radius the radius of the torus knot, optional, default 2
  30790. * * tube the thickness of the tube, optional, default 0.5
  30791. * * radialSegments the number of sides on each tube segments, optional, default 32
  30792. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  30793. * * p the number of windings around the z axis, optional, default 2
  30794. * * q the number of windings around the x axis, optional, default 3
  30795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30796. * * 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)
  30797. * * 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)
  30798. * @returns the VertexData of the Torus Knot
  30799. */
  30800. static CreateTorusKnot(options: {
  30801. radius?: number;
  30802. tube?: number;
  30803. radialSegments?: number;
  30804. tubularSegments?: number;
  30805. p?: number;
  30806. q?: number;
  30807. sideOrientation?: number;
  30808. frontUVs?: Vector4;
  30809. backUVs?: Vector4;
  30810. }): VertexData;
  30811. /**
  30812. * Compute normals for given positions and indices
  30813. * @param positions an array of vertex positions, [...., x, y, z, ......]
  30814. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  30815. * @param normals an array of vertex normals, [...., x, y, z, ......]
  30816. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  30817. * * facetNormals : optional array of facet normals (vector3)
  30818. * * facetPositions : optional array of facet positions (vector3)
  30819. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  30820. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  30821. * * bInfo : optional bounding info, required for facetPartitioning computation
  30822. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  30823. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  30824. * * useRightHandedSystem: optional boolean to for right handed system computation
  30825. * * depthSort : optional boolean to enable the facet depth sort computation
  30826. * * distanceTo : optional Vector3 to compute the facet depth from this location
  30827. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  30828. */
  30829. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  30830. facetNormals?: any;
  30831. facetPositions?: any;
  30832. facetPartitioning?: any;
  30833. ratio?: number;
  30834. bInfo?: any;
  30835. bbSize?: Vector3;
  30836. subDiv?: any;
  30837. useRightHandedSystem?: boolean;
  30838. depthSort?: boolean;
  30839. distanceTo?: Vector3;
  30840. depthSortedFacets?: any;
  30841. }): void;
  30842. /** @hidden */
  30843. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  30844. /**
  30845. * Applies VertexData created from the imported parameters to the geometry
  30846. * @param parsedVertexData the parsed data from an imported file
  30847. * @param geometry the geometry to apply the VertexData to
  30848. */
  30849. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  30850. }
  30851. }
  30852. declare module BABYLON {
  30853. /**
  30854. * Defines a target to use with MorphTargetManager
  30855. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30856. */
  30857. export class MorphTarget implements IAnimatable {
  30858. /** defines the name of the target */
  30859. name: string;
  30860. /**
  30861. * Gets or sets the list of animations
  30862. */
  30863. animations: Animation[];
  30864. private _scene;
  30865. private _positions;
  30866. private _normals;
  30867. private _tangents;
  30868. private _uvs;
  30869. private _influence;
  30870. private _uniqueId;
  30871. /**
  30872. * Observable raised when the influence changes
  30873. */
  30874. onInfluenceChanged: Observable<boolean>;
  30875. /** @hidden */
  30876. _onDataLayoutChanged: Observable<void>;
  30877. /**
  30878. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30879. */
  30880. get influence(): number;
  30881. set influence(influence: number);
  30882. /**
  30883. * Gets or sets the id of the morph Target
  30884. */
  30885. id: string;
  30886. private _animationPropertiesOverride;
  30887. /**
  30888. * Gets or sets the animation properties override
  30889. */
  30890. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30891. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30892. /**
  30893. * Creates a new MorphTarget
  30894. * @param name defines the name of the target
  30895. * @param influence defines the influence to use
  30896. * @param scene defines the scene the morphtarget belongs to
  30897. */
  30898. constructor(
  30899. /** defines the name of the target */
  30900. name: string, influence?: number, scene?: Nullable<Scene>);
  30901. /**
  30902. * Gets the unique ID of this manager
  30903. */
  30904. get uniqueId(): number;
  30905. /**
  30906. * Gets a boolean defining if the target contains position data
  30907. */
  30908. get hasPositions(): boolean;
  30909. /**
  30910. * Gets a boolean defining if the target contains normal data
  30911. */
  30912. get hasNormals(): boolean;
  30913. /**
  30914. * Gets a boolean defining if the target contains tangent data
  30915. */
  30916. get hasTangents(): boolean;
  30917. /**
  30918. * Gets a boolean defining if the target contains texture coordinates data
  30919. */
  30920. get hasUVs(): boolean;
  30921. /**
  30922. * Affects position data to this target
  30923. * @param data defines the position data to use
  30924. */
  30925. setPositions(data: Nullable<FloatArray>): void;
  30926. /**
  30927. * Gets the position data stored in this target
  30928. * @returns a FloatArray containing the position data (or null if not present)
  30929. */
  30930. getPositions(): Nullable<FloatArray>;
  30931. /**
  30932. * Affects normal data to this target
  30933. * @param data defines the normal data to use
  30934. */
  30935. setNormals(data: Nullable<FloatArray>): void;
  30936. /**
  30937. * Gets the normal data stored in this target
  30938. * @returns a FloatArray containing the normal data (or null if not present)
  30939. */
  30940. getNormals(): Nullable<FloatArray>;
  30941. /**
  30942. * Affects tangent data to this target
  30943. * @param data defines the tangent data to use
  30944. */
  30945. setTangents(data: Nullable<FloatArray>): void;
  30946. /**
  30947. * Gets the tangent data stored in this target
  30948. * @returns a FloatArray containing the tangent data (or null if not present)
  30949. */
  30950. getTangents(): Nullable<FloatArray>;
  30951. /**
  30952. * Affects texture coordinates data to this target
  30953. * @param data defines the texture coordinates data to use
  30954. */
  30955. setUVs(data: Nullable<FloatArray>): void;
  30956. /**
  30957. * Gets the texture coordinates data stored in this target
  30958. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30959. */
  30960. getUVs(): Nullable<FloatArray>;
  30961. /**
  30962. * Clone the current target
  30963. * @returns a new MorphTarget
  30964. */
  30965. clone(): MorphTarget;
  30966. /**
  30967. * Serializes the current target into a Serialization object
  30968. * @returns the serialized object
  30969. */
  30970. serialize(): any;
  30971. /**
  30972. * Returns the string "MorphTarget"
  30973. * @returns "MorphTarget"
  30974. */
  30975. getClassName(): string;
  30976. /**
  30977. * Creates a new target from serialized data
  30978. * @param serializationObject defines the serialized data to use
  30979. * @returns a new MorphTarget
  30980. */
  30981. static Parse(serializationObject: any): MorphTarget;
  30982. /**
  30983. * Creates a MorphTarget from mesh data
  30984. * @param mesh defines the source mesh
  30985. * @param name defines the name to use for the new target
  30986. * @param influence defines the influence to attach to the target
  30987. * @returns a new MorphTarget
  30988. */
  30989. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30990. }
  30991. }
  30992. declare module BABYLON {
  30993. /**
  30994. * This class is used to deform meshes using morphing between different targets
  30995. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30996. */
  30997. export class MorphTargetManager {
  30998. private _targets;
  30999. private _targetInfluenceChangedObservers;
  31000. private _targetDataLayoutChangedObservers;
  31001. private _activeTargets;
  31002. private _scene;
  31003. private _influences;
  31004. private _supportsNormals;
  31005. private _supportsTangents;
  31006. private _supportsUVs;
  31007. private _vertexCount;
  31008. private _uniqueId;
  31009. private _tempInfluences;
  31010. /**
  31011. * Gets or sets a boolean indicating if normals must be morphed
  31012. */
  31013. enableNormalMorphing: boolean;
  31014. /**
  31015. * Gets or sets a boolean indicating if tangents must be morphed
  31016. */
  31017. enableTangentMorphing: boolean;
  31018. /**
  31019. * Gets or sets a boolean indicating if UV must be morphed
  31020. */
  31021. enableUVMorphing: boolean;
  31022. /**
  31023. * Creates a new MorphTargetManager
  31024. * @param scene defines the current scene
  31025. */
  31026. constructor(scene?: Nullable<Scene>);
  31027. /**
  31028. * Gets the unique ID of this manager
  31029. */
  31030. get uniqueId(): number;
  31031. /**
  31032. * Gets the number of vertices handled by this manager
  31033. */
  31034. get vertexCount(): number;
  31035. /**
  31036. * Gets a boolean indicating if this manager supports morphing of normals
  31037. */
  31038. get supportsNormals(): boolean;
  31039. /**
  31040. * Gets a boolean indicating if this manager supports morphing of tangents
  31041. */
  31042. get supportsTangents(): boolean;
  31043. /**
  31044. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31045. */
  31046. get supportsUVs(): boolean;
  31047. /**
  31048. * Gets the number of targets stored in this manager
  31049. */
  31050. get numTargets(): number;
  31051. /**
  31052. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31053. */
  31054. get numInfluencers(): number;
  31055. /**
  31056. * Gets the list of influences (one per target)
  31057. */
  31058. get influences(): Float32Array;
  31059. /**
  31060. * Gets the active target at specified index. An active target is a target with an influence > 0
  31061. * @param index defines the index to check
  31062. * @returns the requested target
  31063. */
  31064. getActiveTarget(index: number): MorphTarget;
  31065. /**
  31066. * Gets the target at specified index
  31067. * @param index defines the index to check
  31068. * @returns the requested target
  31069. */
  31070. getTarget(index: number): MorphTarget;
  31071. /**
  31072. * Add a new target to this manager
  31073. * @param target defines the target to add
  31074. */
  31075. addTarget(target: MorphTarget): void;
  31076. /**
  31077. * Removes a target from the manager
  31078. * @param target defines the target to remove
  31079. */
  31080. removeTarget(target: MorphTarget): void;
  31081. /**
  31082. * Clone the current manager
  31083. * @returns a new MorphTargetManager
  31084. */
  31085. clone(): MorphTargetManager;
  31086. /**
  31087. * Serializes the current manager into a Serialization object
  31088. * @returns the serialized object
  31089. */
  31090. serialize(): any;
  31091. private _syncActiveTargets;
  31092. /**
  31093. * Syncrhonize the targets with all the meshes using this morph target manager
  31094. */
  31095. synchronize(): void;
  31096. /**
  31097. * Creates a new MorphTargetManager from serialized data
  31098. * @param serializationObject defines the serialized data
  31099. * @param scene defines the hosting scene
  31100. * @returns the new MorphTargetManager
  31101. */
  31102. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31103. }
  31104. }
  31105. declare module BABYLON {
  31106. /**
  31107. * Class used to represent a specific level of detail of a mesh
  31108. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31109. */
  31110. export class MeshLODLevel {
  31111. /** Defines the distance where this level should start being displayed */
  31112. distance: number;
  31113. /** Defines the mesh to use to render this level */
  31114. mesh: Nullable<Mesh>;
  31115. /**
  31116. * Creates a new LOD level
  31117. * @param distance defines the distance where this level should star being displayed
  31118. * @param mesh defines the mesh to use to render this level
  31119. */
  31120. constructor(
  31121. /** Defines the distance where this level should start being displayed */
  31122. distance: number,
  31123. /** Defines the mesh to use to render this level */
  31124. mesh: Nullable<Mesh>);
  31125. }
  31126. }
  31127. declare module BABYLON {
  31128. /**
  31129. * Helper class used to generate a canvas to manipulate images
  31130. */
  31131. export class CanvasGenerator {
  31132. /**
  31133. * Create a new canvas (or offscreen canvas depending on the context)
  31134. * @param width defines the expected width
  31135. * @param height defines the expected height
  31136. * @return a new canvas or offscreen canvas
  31137. */
  31138. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31139. }
  31140. }
  31141. declare module BABYLON {
  31142. /**
  31143. * Mesh representing the gorund
  31144. */
  31145. export class GroundMesh extends Mesh {
  31146. /** If octree should be generated */
  31147. generateOctree: boolean;
  31148. private _heightQuads;
  31149. /** @hidden */
  31150. _subdivisionsX: number;
  31151. /** @hidden */
  31152. _subdivisionsY: number;
  31153. /** @hidden */
  31154. _width: number;
  31155. /** @hidden */
  31156. _height: number;
  31157. /** @hidden */
  31158. _minX: number;
  31159. /** @hidden */
  31160. _maxX: number;
  31161. /** @hidden */
  31162. _minZ: number;
  31163. /** @hidden */
  31164. _maxZ: number;
  31165. constructor(name: string, scene: Scene);
  31166. /**
  31167. * "GroundMesh"
  31168. * @returns "GroundMesh"
  31169. */
  31170. getClassName(): string;
  31171. /**
  31172. * The minimum of x and y subdivisions
  31173. */
  31174. get subdivisions(): number;
  31175. /**
  31176. * X subdivisions
  31177. */
  31178. get subdivisionsX(): number;
  31179. /**
  31180. * Y subdivisions
  31181. */
  31182. get subdivisionsY(): number;
  31183. /**
  31184. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31185. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31186. * @param chunksCount the number of subdivisions for x and y
  31187. * @param octreeBlocksSize (Default: 32)
  31188. */
  31189. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31190. /**
  31191. * Returns a height (y) value in the Worl system :
  31192. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31193. * @param x x coordinate
  31194. * @param z z coordinate
  31195. * @returns the ground y position if (x, z) are outside the ground surface.
  31196. */
  31197. getHeightAtCoordinates(x: number, z: number): number;
  31198. /**
  31199. * Returns a normalized vector (Vector3) orthogonal to the ground
  31200. * at the ground coordinates (x, z) expressed in the World system.
  31201. * @param x x coordinate
  31202. * @param z z coordinate
  31203. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31204. */
  31205. getNormalAtCoordinates(x: number, z: number): Vector3;
  31206. /**
  31207. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31208. * at the ground coordinates (x, z) expressed in the World system.
  31209. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31210. * @param x x coordinate
  31211. * @param z z coordinate
  31212. * @param ref vector to store the result
  31213. * @returns the GroundMesh.
  31214. */
  31215. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31216. /**
  31217. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31218. * if the ground has been updated.
  31219. * This can be used in the render loop.
  31220. * @returns the GroundMesh.
  31221. */
  31222. updateCoordinateHeights(): GroundMesh;
  31223. private _getFacetAt;
  31224. private _initHeightQuads;
  31225. private _computeHeightQuads;
  31226. /**
  31227. * Serializes this ground mesh
  31228. * @param serializationObject object to write serialization to
  31229. */
  31230. serialize(serializationObject: any): void;
  31231. /**
  31232. * Parses a serialized ground mesh
  31233. * @param parsedMesh the serialized mesh
  31234. * @param scene the scene to create the ground mesh in
  31235. * @returns the created ground mesh
  31236. */
  31237. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31238. }
  31239. }
  31240. declare module BABYLON {
  31241. /**
  31242. * Interface for Physics-Joint data
  31243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31244. */
  31245. export interface PhysicsJointData {
  31246. /**
  31247. * The main pivot of the joint
  31248. */
  31249. mainPivot?: Vector3;
  31250. /**
  31251. * The connected pivot of the joint
  31252. */
  31253. connectedPivot?: Vector3;
  31254. /**
  31255. * The main axis of the joint
  31256. */
  31257. mainAxis?: Vector3;
  31258. /**
  31259. * The connected axis of the joint
  31260. */
  31261. connectedAxis?: Vector3;
  31262. /**
  31263. * The collision of the joint
  31264. */
  31265. collision?: boolean;
  31266. /**
  31267. * Native Oimo/Cannon/Energy data
  31268. */
  31269. nativeParams?: any;
  31270. }
  31271. /**
  31272. * This is a holder class for the physics joint created by the physics plugin
  31273. * It holds a set of functions to control the underlying joint
  31274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31275. */
  31276. export class PhysicsJoint {
  31277. /**
  31278. * The type of the physics joint
  31279. */
  31280. type: number;
  31281. /**
  31282. * The data for the physics joint
  31283. */
  31284. jointData: PhysicsJointData;
  31285. private _physicsJoint;
  31286. protected _physicsPlugin: IPhysicsEnginePlugin;
  31287. /**
  31288. * Initializes the physics joint
  31289. * @param type The type of the physics joint
  31290. * @param jointData The data for the physics joint
  31291. */
  31292. constructor(
  31293. /**
  31294. * The type of the physics joint
  31295. */
  31296. type: number,
  31297. /**
  31298. * The data for the physics joint
  31299. */
  31300. jointData: PhysicsJointData);
  31301. /**
  31302. * Gets the physics joint
  31303. */
  31304. get physicsJoint(): any;
  31305. /**
  31306. * Sets the physics joint
  31307. */
  31308. set physicsJoint(newJoint: any);
  31309. /**
  31310. * Sets the physics plugin
  31311. */
  31312. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31313. /**
  31314. * Execute a function that is physics-plugin specific.
  31315. * @param {Function} func the function that will be executed.
  31316. * It accepts two parameters: the physics world and the physics joint
  31317. */
  31318. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31319. /**
  31320. * Distance-Joint type
  31321. */
  31322. static DistanceJoint: number;
  31323. /**
  31324. * Hinge-Joint type
  31325. */
  31326. static HingeJoint: number;
  31327. /**
  31328. * Ball-and-Socket joint type
  31329. */
  31330. static BallAndSocketJoint: number;
  31331. /**
  31332. * Wheel-Joint type
  31333. */
  31334. static WheelJoint: number;
  31335. /**
  31336. * Slider-Joint type
  31337. */
  31338. static SliderJoint: number;
  31339. /**
  31340. * Prismatic-Joint type
  31341. */
  31342. static PrismaticJoint: number;
  31343. /**
  31344. * Universal-Joint type
  31345. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31346. */
  31347. static UniversalJoint: number;
  31348. /**
  31349. * Hinge-Joint 2 type
  31350. */
  31351. static Hinge2Joint: number;
  31352. /**
  31353. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31354. */
  31355. static PointToPointJoint: number;
  31356. /**
  31357. * Spring-Joint type
  31358. */
  31359. static SpringJoint: number;
  31360. /**
  31361. * Lock-Joint type
  31362. */
  31363. static LockJoint: number;
  31364. }
  31365. /**
  31366. * A class representing a physics distance joint
  31367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31368. */
  31369. export class DistanceJoint extends PhysicsJoint {
  31370. /**
  31371. *
  31372. * @param jointData The data for the Distance-Joint
  31373. */
  31374. constructor(jointData: DistanceJointData);
  31375. /**
  31376. * Update the predefined distance.
  31377. * @param maxDistance The maximum preferred distance
  31378. * @param minDistance The minimum preferred distance
  31379. */
  31380. updateDistance(maxDistance: number, minDistance?: number): void;
  31381. }
  31382. /**
  31383. * Represents a Motor-Enabled Joint
  31384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31385. */
  31386. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31387. /**
  31388. * Initializes the Motor-Enabled Joint
  31389. * @param type The type of the joint
  31390. * @param jointData The physica joint data for the joint
  31391. */
  31392. constructor(type: number, jointData: PhysicsJointData);
  31393. /**
  31394. * Set the motor values.
  31395. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31396. * @param force the force to apply
  31397. * @param maxForce max force for this motor.
  31398. */
  31399. setMotor(force?: number, maxForce?: number): void;
  31400. /**
  31401. * Set the motor's limits.
  31402. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31403. * @param upperLimit The upper limit of the motor
  31404. * @param lowerLimit The lower limit of the motor
  31405. */
  31406. setLimit(upperLimit: number, lowerLimit?: number): void;
  31407. }
  31408. /**
  31409. * This class represents a single physics Hinge-Joint
  31410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31411. */
  31412. export class HingeJoint extends MotorEnabledJoint {
  31413. /**
  31414. * Initializes the Hinge-Joint
  31415. * @param jointData The joint data for the Hinge-Joint
  31416. */
  31417. constructor(jointData: PhysicsJointData);
  31418. /**
  31419. * Set the motor values.
  31420. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31421. * @param {number} force the force to apply
  31422. * @param {number} maxForce max force for this motor.
  31423. */
  31424. setMotor(force?: number, maxForce?: number): void;
  31425. /**
  31426. * Set the motor's limits.
  31427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31428. * @param upperLimit The upper limit of the motor
  31429. * @param lowerLimit The lower limit of the motor
  31430. */
  31431. setLimit(upperLimit: number, lowerLimit?: number): void;
  31432. }
  31433. /**
  31434. * This class represents a dual hinge physics joint (same as wheel joint)
  31435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31436. */
  31437. export class Hinge2Joint extends MotorEnabledJoint {
  31438. /**
  31439. * Initializes the Hinge2-Joint
  31440. * @param jointData The joint data for the Hinge2-Joint
  31441. */
  31442. constructor(jointData: PhysicsJointData);
  31443. /**
  31444. * Set the motor values.
  31445. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31446. * @param {number} targetSpeed the speed the motor is to reach
  31447. * @param {number} maxForce max force for this motor.
  31448. * @param {motorIndex} the motor's index, 0 or 1.
  31449. */
  31450. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31451. /**
  31452. * Set the motor limits.
  31453. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31454. * @param {number} upperLimit the upper limit
  31455. * @param {number} lowerLimit lower limit
  31456. * @param {motorIndex} the motor's index, 0 or 1.
  31457. */
  31458. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31459. }
  31460. /**
  31461. * Interface for a motor enabled joint
  31462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31463. */
  31464. export interface IMotorEnabledJoint {
  31465. /**
  31466. * Physics joint
  31467. */
  31468. physicsJoint: any;
  31469. /**
  31470. * Sets the motor of the motor-enabled joint
  31471. * @param force The force of the motor
  31472. * @param maxForce The maximum force of the motor
  31473. * @param motorIndex The index of the motor
  31474. */
  31475. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31476. /**
  31477. * Sets the limit of the motor
  31478. * @param upperLimit The upper limit of the motor
  31479. * @param lowerLimit The lower limit of the motor
  31480. * @param motorIndex The index of the motor
  31481. */
  31482. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31483. }
  31484. /**
  31485. * Joint data for a Distance-Joint
  31486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31487. */
  31488. export interface DistanceJointData extends PhysicsJointData {
  31489. /**
  31490. * Max distance the 2 joint objects can be apart
  31491. */
  31492. maxDistance: number;
  31493. }
  31494. /**
  31495. * Joint data from a spring joint
  31496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31497. */
  31498. export interface SpringJointData extends PhysicsJointData {
  31499. /**
  31500. * Length of the spring
  31501. */
  31502. length: number;
  31503. /**
  31504. * Stiffness of the spring
  31505. */
  31506. stiffness: number;
  31507. /**
  31508. * Damping of the spring
  31509. */
  31510. damping: number;
  31511. /** this callback will be called when applying the force to the impostors. */
  31512. forceApplicationCallback: () => void;
  31513. }
  31514. }
  31515. declare module BABYLON {
  31516. /**
  31517. * Holds the data for the raycast result
  31518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31519. */
  31520. export class PhysicsRaycastResult {
  31521. private _hasHit;
  31522. private _hitDistance;
  31523. private _hitNormalWorld;
  31524. private _hitPointWorld;
  31525. private _rayFromWorld;
  31526. private _rayToWorld;
  31527. /**
  31528. * Gets if there was a hit
  31529. */
  31530. get hasHit(): boolean;
  31531. /**
  31532. * Gets the distance from the hit
  31533. */
  31534. get hitDistance(): number;
  31535. /**
  31536. * Gets the hit normal/direction in the world
  31537. */
  31538. get hitNormalWorld(): Vector3;
  31539. /**
  31540. * Gets the hit point in the world
  31541. */
  31542. get hitPointWorld(): Vector3;
  31543. /**
  31544. * Gets the ray "start point" of the ray in the world
  31545. */
  31546. get rayFromWorld(): Vector3;
  31547. /**
  31548. * Gets the ray "end point" of the ray in the world
  31549. */
  31550. get rayToWorld(): Vector3;
  31551. /**
  31552. * Sets the hit data (normal & point in world space)
  31553. * @param hitNormalWorld defines the normal in world space
  31554. * @param hitPointWorld defines the point in world space
  31555. */
  31556. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31557. /**
  31558. * Sets the distance from the start point to the hit point
  31559. * @param distance
  31560. */
  31561. setHitDistance(distance: number): void;
  31562. /**
  31563. * Calculates the distance manually
  31564. */
  31565. calculateHitDistance(): void;
  31566. /**
  31567. * Resets all the values to default
  31568. * @param from The from point on world space
  31569. * @param to The to point on world space
  31570. */
  31571. reset(from?: Vector3, to?: Vector3): void;
  31572. }
  31573. /**
  31574. * Interface for the size containing width and height
  31575. */
  31576. interface IXYZ {
  31577. /**
  31578. * X
  31579. */
  31580. x: number;
  31581. /**
  31582. * Y
  31583. */
  31584. y: number;
  31585. /**
  31586. * Z
  31587. */
  31588. z: number;
  31589. }
  31590. }
  31591. declare module BABYLON {
  31592. /**
  31593. * Interface used to describe a physics joint
  31594. */
  31595. export interface PhysicsImpostorJoint {
  31596. /** Defines the main impostor to which the joint is linked */
  31597. mainImpostor: PhysicsImpostor;
  31598. /** Defines the impostor that is connected to the main impostor using this joint */
  31599. connectedImpostor: PhysicsImpostor;
  31600. /** Defines the joint itself */
  31601. joint: PhysicsJoint;
  31602. }
  31603. /** @hidden */
  31604. export interface IPhysicsEnginePlugin {
  31605. world: any;
  31606. name: string;
  31607. setGravity(gravity: Vector3): void;
  31608. setTimeStep(timeStep: number): void;
  31609. getTimeStep(): number;
  31610. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31611. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31612. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31613. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31614. removePhysicsBody(impostor: PhysicsImpostor): void;
  31615. generateJoint(joint: PhysicsImpostorJoint): void;
  31616. removeJoint(joint: PhysicsImpostorJoint): void;
  31617. isSupported(): boolean;
  31618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31619. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31620. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31621. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31622. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31623. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31624. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31625. getBodyMass(impostor: PhysicsImpostor): number;
  31626. getBodyFriction(impostor: PhysicsImpostor): number;
  31627. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31628. getBodyRestitution(impostor: PhysicsImpostor): number;
  31629. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31630. getBodyPressure?(impostor: PhysicsImpostor): number;
  31631. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31632. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31633. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31634. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31635. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31636. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31637. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31638. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31639. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31640. sleepBody(impostor: PhysicsImpostor): void;
  31641. wakeUpBody(impostor: PhysicsImpostor): void;
  31642. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31643. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31644. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31646. getRadius(impostor: PhysicsImpostor): number;
  31647. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31648. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31649. dispose(): void;
  31650. }
  31651. /**
  31652. * Interface used to define a physics engine
  31653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31654. */
  31655. export interface IPhysicsEngine {
  31656. /**
  31657. * Gets the gravity vector used by the simulation
  31658. */
  31659. gravity: Vector3;
  31660. /**
  31661. * Sets the gravity vector used by the simulation
  31662. * @param gravity defines the gravity vector to use
  31663. */
  31664. setGravity(gravity: Vector3): void;
  31665. /**
  31666. * Set the time step of the physics engine.
  31667. * Default is 1/60.
  31668. * To slow it down, enter 1/600 for example.
  31669. * To speed it up, 1/30
  31670. * @param newTimeStep the new timestep to apply to this world.
  31671. */
  31672. setTimeStep(newTimeStep: number): void;
  31673. /**
  31674. * Get the time step of the physics engine.
  31675. * @returns the current time step
  31676. */
  31677. getTimeStep(): number;
  31678. /**
  31679. * Set the sub time step of the physics engine.
  31680. * Default is 0 meaning there is no sub steps
  31681. * To increase physics resolution precision, set a small value (like 1 ms)
  31682. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31683. */
  31684. setSubTimeStep(subTimeStep: number): void;
  31685. /**
  31686. * Get the sub time step of the physics engine.
  31687. * @returns the current sub time step
  31688. */
  31689. getSubTimeStep(): number;
  31690. /**
  31691. * Release all resources
  31692. */
  31693. dispose(): void;
  31694. /**
  31695. * Gets the name of the current physics plugin
  31696. * @returns the name of the plugin
  31697. */
  31698. getPhysicsPluginName(): string;
  31699. /**
  31700. * Adding a new impostor for the impostor tracking.
  31701. * This will be done by the impostor itself.
  31702. * @param impostor the impostor to add
  31703. */
  31704. addImpostor(impostor: PhysicsImpostor): void;
  31705. /**
  31706. * Remove an impostor from the engine.
  31707. * This impostor and its mesh will not longer be updated by the physics engine.
  31708. * @param impostor the impostor to remove
  31709. */
  31710. removeImpostor(impostor: PhysicsImpostor): void;
  31711. /**
  31712. * Add a joint to the physics engine
  31713. * @param mainImpostor defines the main impostor to which the joint is added.
  31714. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31715. * @param joint defines the joint that will connect both impostors.
  31716. */
  31717. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31718. /**
  31719. * Removes a joint from the simulation
  31720. * @param mainImpostor defines the impostor used with the joint
  31721. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31722. * @param joint defines the joint to remove
  31723. */
  31724. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31725. /**
  31726. * Gets the current plugin used to run the simulation
  31727. * @returns current plugin
  31728. */
  31729. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31730. /**
  31731. * Gets the list of physic impostors
  31732. * @returns an array of PhysicsImpostor
  31733. */
  31734. getImpostors(): Array<PhysicsImpostor>;
  31735. /**
  31736. * Gets the impostor for a physics enabled object
  31737. * @param object defines the object impersonated by the impostor
  31738. * @returns the PhysicsImpostor or null if not found
  31739. */
  31740. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31741. /**
  31742. * Gets the impostor for a physics body object
  31743. * @param body defines physics body used by the impostor
  31744. * @returns the PhysicsImpostor or null if not found
  31745. */
  31746. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31747. /**
  31748. * Does a raycast in the physics world
  31749. * @param from when should the ray start?
  31750. * @param to when should the ray end?
  31751. * @returns PhysicsRaycastResult
  31752. */
  31753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31754. /**
  31755. * Called by the scene. No need to call it.
  31756. * @param delta defines the timespam between frames
  31757. */
  31758. _step(delta: number): void;
  31759. }
  31760. }
  31761. declare module BABYLON {
  31762. /**
  31763. * The interface for the physics imposter parameters
  31764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31765. */
  31766. export interface PhysicsImpostorParameters {
  31767. /**
  31768. * The mass of the physics imposter
  31769. */
  31770. mass: number;
  31771. /**
  31772. * The friction of the physics imposter
  31773. */
  31774. friction?: number;
  31775. /**
  31776. * The coefficient of restitution of the physics imposter
  31777. */
  31778. restitution?: number;
  31779. /**
  31780. * The native options of the physics imposter
  31781. */
  31782. nativeOptions?: any;
  31783. /**
  31784. * Specifies if the parent should be ignored
  31785. */
  31786. ignoreParent?: boolean;
  31787. /**
  31788. * Specifies if bi-directional transformations should be disabled
  31789. */
  31790. disableBidirectionalTransformation?: boolean;
  31791. /**
  31792. * The pressure inside the physics imposter, soft object only
  31793. */
  31794. pressure?: number;
  31795. /**
  31796. * The stiffness the physics imposter, soft object only
  31797. */
  31798. stiffness?: number;
  31799. /**
  31800. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31801. */
  31802. velocityIterations?: number;
  31803. /**
  31804. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31805. */
  31806. positionIterations?: number;
  31807. /**
  31808. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31809. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31810. * Add to fix multiple points
  31811. */
  31812. fixedPoints?: number;
  31813. /**
  31814. * The collision margin around a soft object
  31815. */
  31816. margin?: number;
  31817. /**
  31818. * The collision margin around a soft object
  31819. */
  31820. damping?: number;
  31821. /**
  31822. * The path for a rope based on an extrusion
  31823. */
  31824. path?: any;
  31825. /**
  31826. * The shape of an extrusion used for a rope based on an extrusion
  31827. */
  31828. shape?: any;
  31829. }
  31830. /**
  31831. * Interface for a physics-enabled object
  31832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31833. */
  31834. export interface IPhysicsEnabledObject {
  31835. /**
  31836. * The position of the physics-enabled object
  31837. */
  31838. position: Vector3;
  31839. /**
  31840. * The rotation of the physics-enabled object
  31841. */
  31842. rotationQuaternion: Nullable<Quaternion>;
  31843. /**
  31844. * The scale of the physics-enabled object
  31845. */
  31846. scaling: Vector3;
  31847. /**
  31848. * The rotation of the physics-enabled object
  31849. */
  31850. rotation?: Vector3;
  31851. /**
  31852. * The parent of the physics-enabled object
  31853. */
  31854. parent?: any;
  31855. /**
  31856. * The bounding info of the physics-enabled object
  31857. * @returns The bounding info of the physics-enabled object
  31858. */
  31859. getBoundingInfo(): BoundingInfo;
  31860. /**
  31861. * Computes the world matrix
  31862. * @param force Specifies if the world matrix should be computed by force
  31863. * @returns A world matrix
  31864. */
  31865. computeWorldMatrix(force: boolean): Matrix;
  31866. /**
  31867. * Gets the world matrix
  31868. * @returns A world matrix
  31869. */
  31870. getWorldMatrix?(): Matrix;
  31871. /**
  31872. * Gets the child meshes
  31873. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31874. * @returns An array of abstract meshes
  31875. */
  31876. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31877. /**
  31878. * Gets the vertex data
  31879. * @param kind The type of vertex data
  31880. * @returns A nullable array of numbers, or a float32 array
  31881. */
  31882. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31883. /**
  31884. * Gets the indices from the mesh
  31885. * @returns A nullable array of index arrays
  31886. */
  31887. getIndices?(): Nullable<IndicesArray>;
  31888. /**
  31889. * Gets the scene from the mesh
  31890. * @returns the indices array or null
  31891. */
  31892. getScene?(): Scene;
  31893. /**
  31894. * Gets the absolute position from the mesh
  31895. * @returns the absolute position
  31896. */
  31897. getAbsolutePosition(): Vector3;
  31898. /**
  31899. * Gets the absolute pivot point from the mesh
  31900. * @returns the absolute pivot point
  31901. */
  31902. getAbsolutePivotPoint(): Vector3;
  31903. /**
  31904. * Rotates the mesh
  31905. * @param axis The axis of rotation
  31906. * @param amount The amount of rotation
  31907. * @param space The space of the rotation
  31908. * @returns The rotation transform node
  31909. */
  31910. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31911. /**
  31912. * Translates the mesh
  31913. * @param axis The axis of translation
  31914. * @param distance The distance of translation
  31915. * @param space The space of the translation
  31916. * @returns The transform node
  31917. */
  31918. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31919. /**
  31920. * Sets the absolute position of the mesh
  31921. * @param absolutePosition The absolute position of the mesh
  31922. * @returns The transform node
  31923. */
  31924. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31925. /**
  31926. * Gets the class name of the mesh
  31927. * @returns The class name
  31928. */
  31929. getClassName(): string;
  31930. }
  31931. /**
  31932. * Represents a physics imposter
  31933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31934. */
  31935. export class PhysicsImpostor {
  31936. /**
  31937. * The physics-enabled object used as the physics imposter
  31938. */
  31939. object: IPhysicsEnabledObject;
  31940. /**
  31941. * The type of the physics imposter
  31942. */
  31943. type: number;
  31944. private _options;
  31945. private _scene?;
  31946. /**
  31947. * The default object size of the imposter
  31948. */
  31949. static DEFAULT_OBJECT_SIZE: Vector3;
  31950. /**
  31951. * The identity quaternion of the imposter
  31952. */
  31953. static IDENTITY_QUATERNION: Quaternion;
  31954. /** @hidden */
  31955. _pluginData: any;
  31956. private _physicsEngine;
  31957. private _physicsBody;
  31958. private _bodyUpdateRequired;
  31959. private _onBeforePhysicsStepCallbacks;
  31960. private _onAfterPhysicsStepCallbacks;
  31961. /** @hidden */
  31962. _onPhysicsCollideCallbacks: Array<{
  31963. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31964. otherImpostors: Array<PhysicsImpostor>;
  31965. }>;
  31966. private _deltaPosition;
  31967. private _deltaRotation;
  31968. private _deltaRotationConjugated;
  31969. /** @hidden */
  31970. _isFromLine: boolean;
  31971. private _parent;
  31972. private _isDisposed;
  31973. private static _tmpVecs;
  31974. private static _tmpQuat;
  31975. /**
  31976. * Specifies if the physics imposter is disposed
  31977. */
  31978. get isDisposed(): boolean;
  31979. /**
  31980. * Gets the mass of the physics imposter
  31981. */
  31982. get mass(): number;
  31983. set mass(value: number);
  31984. /**
  31985. * Gets the coefficient of friction
  31986. */
  31987. get friction(): number;
  31988. /**
  31989. * Sets the coefficient of friction
  31990. */
  31991. set friction(value: number);
  31992. /**
  31993. * Gets the coefficient of restitution
  31994. */
  31995. get restitution(): number;
  31996. /**
  31997. * Sets the coefficient of restitution
  31998. */
  31999. set restitution(value: number);
  32000. /**
  32001. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32002. */
  32003. get pressure(): number;
  32004. /**
  32005. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32006. */
  32007. set pressure(value: number);
  32008. /**
  32009. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32010. */
  32011. get stiffness(): number;
  32012. /**
  32013. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32014. */
  32015. set stiffness(value: number);
  32016. /**
  32017. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32018. */
  32019. get velocityIterations(): number;
  32020. /**
  32021. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32022. */
  32023. set velocityIterations(value: number);
  32024. /**
  32025. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32026. */
  32027. get positionIterations(): number;
  32028. /**
  32029. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32030. */
  32031. set positionIterations(value: number);
  32032. /**
  32033. * The unique id of the physics imposter
  32034. * set by the physics engine when adding this impostor to the array
  32035. */
  32036. uniqueId: number;
  32037. /**
  32038. * @hidden
  32039. */
  32040. soft: boolean;
  32041. /**
  32042. * @hidden
  32043. */
  32044. segments: number;
  32045. private _joints;
  32046. /**
  32047. * Initializes the physics imposter
  32048. * @param object The physics-enabled object used as the physics imposter
  32049. * @param type The type of the physics imposter
  32050. * @param _options The options for the physics imposter
  32051. * @param _scene The Babylon scene
  32052. */
  32053. constructor(
  32054. /**
  32055. * The physics-enabled object used as the physics imposter
  32056. */
  32057. object: IPhysicsEnabledObject,
  32058. /**
  32059. * The type of the physics imposter
  32060. */
  32061. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32062. /**
  32063. * This function will completly initialize this impostor.
  32064. * It will create a new body - but only if this mesh has no parent.
  32065. * If it has, this impostor will not be used other than to define the impostor
  32066. * of the child mesh.
  32067. * @hidden
  32068. */
  32069. _init(): void;
  32070. private _getPhysicsParent;
  32071. /**
  32072. * Should a new body be generated.
  32073. * @returns boolean specifying if body initialization is required
  32074. */
  32075. isBodyInitRequired(): boolean;
  32076. /**
  32077. * Sets the updated scaling
  32078. * @param updated Specifies if the scaling is updated
  32079. */
  32080. setScalingUpdated(): void;
  32081. /**
  32082. * Force a regeneration of this or the parent's impostor's body.
  32083. * Use under cautious - This will remove all joints already implemented.
  32084. */
  32085. forceUpdate(): void;
  32086. /**
  32087. * Gets the body that holds this impostor. Either its own, or its parent.
  32088. */
  32089. get physicsBody(): any;
  32090. /**
  32091. * Get the parent of the physics imposter
  32092. * @returns Physics imposter or null
  32093. */
  32094. get parent(): Nullable<PhysicsImpostor>;
  32095. /**
  32096. * Sets the parent of the physics imposter
  32097. */
  32098. set parent(value: Nullable<PhysicsImpostor>);
  32099. /**
  32100. * Set the physics body. Used mainly by the physics engine/plugin
  32101. */
  32102. set physicsBody(physicsBody: any);
  32103. /**
  32104. * Resets the update flags
  32105. */
  32106. resetUpdateFlags(): void;
  32107. /**
  32108. * Gets the object extend size
  32109. * @returns the object extend size
  32110. */
  32111. getObjectExtendSize(): Vector3;
  32112. /**
  32113. * Gets the object center
  32114. * @returns The object center
  32115. */
  32116. getObjectCenter(): Vector3;
  32117. /**
  32118. * Get a specific parameter from the options parameters
  32119. * @param paramName The object parameter name
  32120. * @returns The object parameter
  32121. */
  32122. getParam(paramName: string): any;
  32123. /**
  32124. * Sets a specific parameter in the options given to the physics plugin
  32125. * @param paramName The parameter name
  32126. * @param value The value of the parameter
  32127. */
  32128. setParam(paramName: string, value: number): void;
  32129. /**
  32130. * Specifically change the body's mass option. Won't recreate the physics body object
  32131. * @param mass The mass of the physics imposter
  32132. */
  32133. setMass(mass: number): void;
  32134. /**
  32135. * Gets the linear velocity
  32136. * @returns linear velocity or null
  32137. */
  32138. getLinearVelocity(): Nullable<Vector3>;
  32139. /**
  32140. * Sets the linear velocity
  32141. * @param velocity linear velocity or null
  32142. */
  32143. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32144. /**
  32145. * Gets the angular velocity
  32146. * @returns angular velocity or null
  32147. */
  32148. getAngularVelocity(): Nullable<Vector3>;
  32149. /**
  32150. * Sets the angular velocity
  32151. * @param velocity The velocity or null
  32152. */
  32153. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32154. /**
  32155. * Execute a function with the physics plugin native code
  32156. * Provide a function the will have two variables - the world object and the physics body object
  32157. * @param func The function to execute with the physics plugin native code
  32158. */
  32159. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32160. /**
  32161. * Register a function that will be executed before the physics world is stepping forward
  32162. * @param func The function to execute before the physics world is stepped forward
  32163. */
  32164. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32165. /**
  32166. * Unregister a function that will be executed before the physics world is stepping forward
  32167. * @param func The function to execute before the physics world is stepped forward
  32168. */
  32169. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32170. /**
  32171. * Register a function that will be executed after the physics step
  32172. * @param func The function to execute after physics step
  32173. */
  32174. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32175. /**
  32176. * Unregisters a function that will be executed after the physics step
  32177. * @param func The function to execute after physics step
  32178. */
  32179. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32180. /**
  32181. * register a function that will be executed when this impostor collides against a different body
  32182. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32183. * @param func Callback that is executed on collision
  32184. */
  32185. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32186. /**
  32187. * Unregisters the physics imposter on contact
  32188. * @param collideAgainst The physics object to collide against
  32189. * @param func Callback to execute on collision
  32190. */
  32191. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32192. private _tmpQuat;
  32193. private _tmpQuat2;
  32194. /**
  32195. * Get the parent rotation
  32196. * @returns The parent rotation
  32197. */
  32198. getParentsRotation(): Quaternion;
  32199. /**
  32200. * this function is executed by the physics engine.
  32201. */
  32202. beforeStep: () => void;
  32203. /**
  32204. * this function is executed by the physics engine
  32205. */
  32206. afterStep: () => void;
  32207. /**
  32208. * Legacy collision detection event support
  32209. */
  32210. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32211. /**
  32212. * event and body object due to cannon's event-based architecture.
  32213. */
  32214. onCollide: (e: {
  32215. body: any;
  32216. point: Nullable<Vector3>;
  32217. }) => void;
  32218. /**
  32219. * Apply a force
  32220. * @param force The force to apply
  32221. * @param contactPoint The contact point for the force
  32222. * @returns The physics imposter
  32223. */
  32224. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32225. /**
  32226. * Apply an impulse
  32227. * @param force The impulse force
  32228. * @param contactPoint The contact point for the impulse force
  32229. * @returns The physics imposter
  32230. */
  32231. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32232. /**
  32233. * A help function to create a joint
  32234. * @param otherImpostor A physics imposter used to create a joint
  32235. * @param jointType The type of joint
  32236. * @param jointData The data for the joint
  32237. * @returns The physics imposter
  32238. */
  32239. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32240. /**
  32241. * Add a joint to this impostor with a different impostor
  32242. * @param otherImpostor A physics imposter used to add a joint
  32243. * @param joint The joint to add
  32244. * @returns The physics imposter
  32245. */
  32246. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32247. /**
  32248. * Add an anchor to a cloth impostor
  32249. * @param otherImpostor rigid impostor to anchor to
  32250. * @param width ratio across width from 0 to 1
  32251. * @param height ratio up height from 0 to 1
  32252. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32253. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32254. * @returns impostor the soft imposter
  32255. */
  32256. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32257. /**
  32258. * Add a hook to a rope impostor
  32259. * @param otherImpostor rigid impostor to anchor to
  32260. * @param length ratio across rope from 0 to 1
  32261. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32262. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32263. * @returns impostor the rope imposter
  32264. */
  32265. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32266. /**
  32267. * Will keep this body still, in a sleep mode.
  32268. * @returns the physics imposter
  32269. */
  32270. sleep(): PhysicsImpostor;
  32271. /**
  32272. * Wake the body up.
  32273. * @returns The physics imposter
  32274. */
  32275. wakeUp(): PhysicsImpostor;
  32276. /**
  32277. * Clones the physics imposter
  32278. * @param newObject The physics imposter clones to this physics-enabled object
  32279. * @returns A nullable physics imposter
  32280. */
  32281. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32282. /**
  32283. * Disposes the physics imposter
  32284. */
  32285. dispose(): void;
  32286. /**
  32287. * Sets the delta position
  32288. * @param position The delta position amount
  32289. */
  32290. setDeltaPosition(position: Vector3): void;
  32291. /**
  32292. * Sets the delta rotation
  32293. * @param rotation The delta rotation amount
  32294. */
  32295. setDeltaRotation(rotation: Quaternion): void;
  32296. /**
  32297. * Gets the box size of the physics imposter and stores the result in the input parameter
  32298. * @param result Stores the box size
  32299. * @returns The physics imposter
  32300. */
  32301. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32302. /**
  32303. * Gets the radius of the physics imposter
  32304. * @returns Radius of the physics imposter
  32305. */
  32306. getRadius(): number;
  32307. /**
  32308. * Sync a bone with this impostor
  32309. * @param bone The bone to sync to the impostor.
  32310. * @param boneMesh The mesh that the bone is influencing.
  32311. * @param jointPivot The pivot of the joint / bone in local space.
  32312. * @param distToJoint Optional distance from the impostor to the joint.
  32313. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32314. */
  32315. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32316. /**
  32317. * Sync impostor to a bone
  32318. * @param bone The bone that the impostor will be synced to.
  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. * @param boneAxis Optional vector3 axis the bone is aligned with
  32324. */
  32325. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32326. /**
  32327. * No-Imposter type
  32328. */
  32329. static NoImpostor: number;
  32330. /**
  32331. * Sphere-Imposter type
  32332. */
  32333. static SphereImpostor: number;
  32334. /**
  32335. * Box-Imposter type
  32336. */
  32337. static BoxImpostor: number;
  32338. /**
  32339. * Plane-Imposter type
  32340. */
  32341. static PlaneImpostor: number;
  32342. /**
  32343. * Mesh-imposter type
  32344. */
  32345. static MeshImpostor: number;
  32346. /**
  32347. * Capsule-Impostor type (Ammo.js plugin only)
  32348. */
  32349. static CapsuleImpostor: number;
  32350. /**
  32351. * Cylinder-Imposter type
  32352. */
  32353. static CylinderImpostor: number;
  32354. /**
  32355. * Particle-Imposter type
  32356. */
  32357. static ParticleImpostor: number;
  32358. /**
  32359. * Heightmap-Imposter type
  32360. */
  32361. static HeightmapImpostor: number;
  32362. /**
  32363. * ConvexHull-Impostor type (Ammo.js plugin only)
  32364. */
  32365. static ConvexHullImpostor: number;
  32366. /**
  32367. * Custom-Imposter type (Ammo.js plugin only)
  32368. */
  32369. static CustomImpostor: number;
  32370. /**
  32371. * Rope-Imposter type
  32372. */
  32373. static RopeImpostor: number;
  32374. /**
  32375. * Cloth-Imposter type
  32376. */
  32377. static ClothImpostor: number;
  32378. /**
  32379. * Softbody-Imposter type
  32380. */
  32381. static SoftbodyImpostor: number;
  32382. }
  32383. }
  32384. declare module BABYLON {
  32385. /**
  32386. * @hidden
  32387. **/
  32388. export class _CreationDataStorage {
  32389. closePath?: boolean;
  32390. closeArray?: boolean;
  32391. idx: number[];
  32392. dashSize: number;
  32393. gapSize: number;
  32394. path3D: Path3D;
  32395. pathArray: Vector3[][];
  32396. arc: number;
  32397. radius: number;
  32398. cap: number;
  32399. tessellation: number;
  32400. }
  32401. /**
  32402. * @hidden
  32403. **/
  32404. class _InstanceDataStorage {
  32405. visibleInstances: any;
  32406. batchCache: _InstancesBatch;
  32407. instancesBufferSize: number;
  32408. instancesBuffer: Nullable<Buffer>;
  32409. instancesData: Float32Array;
  32410. overridenInstanceCount: number;
  32411. isFrozen: boolean;
  32412. previousBatch: Nullable<_InstancesBatch>;
  32413. hardwareInstancedRendering: boolean;
  32414. sideOrientation: number;
  32415. manualUpdate: boolean;
  32416. previousRenderId: number;
  32417. }
  32418. /**
  32419. * @hidden
  32420. **/
  32421. export class _InstancesBatch {
  32422. mustReturn: boolean;
  32423. visibleInstances: Nullable<InstancedMesh[]>[];
  32424. renderSelf: boolean[];
  32425. hardwareInstancedRendering: boolean[];
  32426. }
  32427. /**
  32428. * @hidden
  32429. **/
  32430. class _ThinInstanceDataStorage {
  32431. instancesCount: number;
  32432. matrixBuffer: Nullable<Buffer>;
  32433. matrixBufferSize: number;
  32434. matrixData: Nullable<Float32Array>;
  32435. boundingVectors: Array<Vector3>;
  32436. worldMatrices: Nullable<Matrix[]>;
  32437. }
  32438. /**
  32439. * Class used to represent renderable models
  32440. */
  32441. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32442. /**
  32443. * Mesh side orientation : usually the external or front surface
  32444. */
  32445. static readonly FRONTSIDE: number;
  32446. /**
  32447. * Mesh side orientation : usually the internal or back surface
  32448. */
  32449. static readonly BACKSIDE: number;
  32450. /**
  32451. * Mesh side orientation : both internal and external or front and back surfaces
  32452. */
  32453. static readonly DOUBLESIDE: number;
  32454. /**
  32455. * Mesh side orientation : by default, `FRONTSIDE`
  32456. */
  32457. static readonly DEFAULTSIDE: number;
  32458. /**
  32459. * Mesh cap setting : no cap
  32460. */
  32461. static readonly NO_CAP: number;
  32462. /**
  32463. * Mesh cap setting : one cap at the beginning of the mesh
  32464. */
  32465. static readonly CAP_START: number;
  32466. /**
  32467. * Mesh cap setting : one cap at the end of the mesh
  32468. */
  32469. static readonly CAP_END: number;
  32470. /**
  32471. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32472. */
  32473. static readonly CAP_ALL: number;
  32474. /**
  32475. * Mesh pattern setting : no flip or rotate
  32476. */
  32477. static readonly NO_FLIP: number;
  32478. /**
  32479. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32480. */
  32481. static readonly FLIP_TILE: number;
  32482. /**
  32483. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32484. */
  32485. static readonly ROTATE_TILE: number;
  32486. /**
  32487. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32488. */
  32489. static readonly FLIP_ROW: number;
  32490. /**
  32491. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32492. */
  32493. static readonly ROTATE_ROW: number;
  32494. /**
  32495. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32496. */
  32497. static readonly FLIP_N_ROTATE_TILE: number;
  32498. /**
  32499. * Mesh pattern setting : rotate pattern and rotate
  32500. */
  32501. static readonly FLIP_N_ROTATE_ROW: number;
  32502. /**
  32503. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32504. */
  32505. static readonly CENTER: number;
  32506. /**
  32507. * Mesh tile positioning : part tiles on left
  32508. */
  32509. static readonly LEFT: number;
  32510. /**
  32511. * Mesh tile positioning : part tiles on right
  32512. */
  32513. static readonly RIGHT: number;
  32514. /**
  32515. * Mesh tile positioning : part tiles on top
  32516. */
  32517. static readonly TOP: number;
  32518. /**
  32519. * Mesh tile positioning : part tiles on bottom
  32520. */
  32521. static readonly BOTTOM: number;
  32522. /**
  32523. * Gets the default side orientation.
  32524. * @param orientation the orientation to value to attempt to get
  32525. * @returns the default orientation
  32526. * @hidden
  32527. */
  32528. static _GetDefaultSideOrientation(orientation?: number): number;
  32529. private _internalMeshDataInfo;
  32530. get computeBonesUsingShaders(): boolean;
  32531. set computeBonesUsingShaders(value: boolean);
  32532. /**
  32533. * An event triggered before rendering the mesh
  32534. */
  32535. get onBeforeRenderObservable(): Observable<Mesh>;
  32536. /**
  32537. * An event triggered before binding the mesh
  32538. */
  32539. get onBeforeBindObservable(): Observable<Mesh>;
  32540. /**
  32541. * An event triggered after rendering the mesh
  32542. */
  32543. get onAfterRenderObservable(): Observable<Mesh>;
  32544. /**
  32545. * An event triggered before drawing the mesh
  32546. */
  32547. get onBeforeDrawObservable(): Observable<Mesh>;
  32548. private _onBeforeDrawObserver;
  32549. /**
  32550. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32551. */
  32552. set onBeforeDraw(callback: () => void);
  32553. get hasInstances(): boolean;
  32554. get hasThinInstances(): boolean;
  32555. /**
  32556. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32557. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32558. */
  32559. delayLoadState: number;
  32560. /**
  32561. * Gets the list of instances created from this mesh
  32562. * it is not supposed to be modified manually.
  32563. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32564. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32565. */
  32566. instances: InstancedMesh[];
  32567. /**
  32568. * Gets the file containing delay loading data for this mesh
  32569. */
  32570. delayLoadingFile: string;
  32571. /** @hidden */
  32572. _binaryInfo: any;
  32573. /**
  32574. * User defined function used to change how LOD level selection is done
  32575. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32576. */
  32577. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32578. /**
  32579. * Gets or sets the morph target manager
  32580. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32581. */
  32582. get morphTargetManager(): Nullable<MorphTargetManager>;
  32583. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32584. /** @hidden */
  32585. _creationDataStorage: Nullable<_CreationDataStorage>;
  32586. /** @hidden */
  32587. _geometry: Nullable<Geometry>;
  32588. /** @hidden */
  32589. _delayInfo: Array<string>;
  32590. /** @hidden */
  32591. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32592. /** @hidden */
  32593. _instanceDataStorage: _InstanceDataStorage;
  32594. /** @hidden */
  32595. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32596. private _effectiveMaterial;
  32597. /** @hidden */
  32598. _shouldGenerateFlatShading: boolean;
  32599. /** @hidden */
  32600. _originalBuilderSideOrientation: number;
  32601. /**
  32602. * Use this property to change the original side orientation defined at construction time
  32603. */
  32604. overrideMaterialSideOrientation: Nullable<number>;
  32605. /**
  32606. * Gets the source mesh (the one used to clone this one from)
  32607. */
  32608. get source(): Nullable<Mesh>;
  32609. /**
  32610. * Gets the list of clones of this mesh
  32611. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32612. * Note that useClonedMeshMap=true is the default setting
  32613. */
  32614. get cloneMeshMap(): Nullable<{
  32615. [id: string]: Mesh | undefined;
  32616. }>;
  32617. /**
  32618. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32619. */
  32620. get isUnIndexed(): boolean;
  32621. set isUnIndexed(value: boolean);
  32622. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32623. get worldMatrixInstancedBuffer(): Float32Array;
  32624. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32625. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32626. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32627. /**
  32628. * @constructor
  32629. * @param name The value used by scene.getMeshByName() to do a lookup.
  32630. * @param scene The scene to add this mesh to.
  32631. * @param parent The parent of this mesh, if it has one
  32632. * @param source An optional Mesh from which geometry is shared, cloned.
  32633. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32634. * When false, achieved by calling a clone(), also passing False.
  32635. * This will make creation of children, recursive.
  32636. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32637. */
  32638. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32639. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32640. doNotInstantiate: boolean;
  32641. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32642. /**
  32643. * Gets the class name
  32644. * @returns the string "Mesh".
  32645. */
  32646. getClassName(): string;
  32647. /** @hidden */
  32648. get _isMesh(): boolean;
  32649. /**
  32650. * Returns a description of this mesh
  32651. * @param fullDetails define if full details about this mesh must be used
  32652. * @returns a descriptive string representing this mesh
  32653. */
  32654. toString(fullDetails?: boolean): string;
  32655. /** @hidden */
  32656. _unBindEffect(): void;
  32657. /**
  32658. * Gets a boolean indicating if this mesh has LOD
  32659. */
  32660. get hasLODLevels(): boolean;
  32661. /**
  32662. * Gets the list of MeshLODLevel associated with the current mesh
  32663. * @returns an array of MeshLODLevel
  32664. */
  32665. getLODLevels(): MeshLODLevel[];
  32666. private _sortLODLevels;
  32667. /**
  32668. * Add a mesh as LOD level triggered at the given distance.
  32669. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32670. * @param distance The distance from the center of the object to show this level
  32671. * @param mesh The mesh to be added as LOD level (can be null)
  32672. * @return This mesh (for chaining)
  32673. */
  32674. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32675. /**
  32676. * Returns the LOD level mesh at the passed distance or null if not found.
  32677. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32678. * @param distance The distance from the center of the object to show this level
  32679. * @returns a Mesh or `null`
  32680. */
  32681. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32682. /**
  32683. * Remove a mesh from the LOD array
  32684. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32685. * @param mesh defines the mesh to be removed
  32686. * @return This mesh (for chaining)
  32687. */
  32688. removeLODLevel(mesh: Mesh): Mesh;
  32689. /**
  32690. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32691. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32692. * @param camera defines the camera to use to compute distance
  32693. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32694. * @return This mesh (for chaining)
  32695. */
  32696. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32697. /**
  32698. * Gets the mesh internal Geometry object
  32699. */
  32700. get geometry(): Nullable<Geometry>;
  32701. /**
  32702. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32703. * @returns the total number of vertices
  32704. */
  32705. getTotalVertices(): number;
  32706. /**
  32707. * Returns the content of an associated vertex buffer
  32708. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32709. * - VertexBuffer.PositionKind
  32710. * - VertexBuffer.UVKind
  32711. * - VertexBuffer.UV2Kind
  32712. * - VertexBuffer.UV3Kind
  32713. * - VertexBuffer.UV4Kind
  32714. * - VertexBuffer.UV5Kind
  32715. * - VertexBuffer.UV6Kind
  32716. * - VertexBuffer.ColorKind
  32717. * - VertexBuffer.MatricesIndicesKind
  32718. * - VertexBuffer.MatricesIndicesExtraKind
  32719. * - VertexBuffer.MatricesWeightsKind
  32720. * - VertexBuffer.MatricesWeightsExtraKind
  32721. * @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
  32722. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32723. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32724. */
  32725. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32726. /**
  32727. * Returns the mesh VertexBuffer object from the requested `kind`
  32728. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32729. * - VertexBuffer.PositionKind
  32730. * - VertexBuffer.NormalKind
  32731. * - VertexBuffer.UVKind
  32732. * - VertexBuffer.UV2Kind
  32733. * - VertexBuffer.UV3Kind
  32734. * - VertexBuffer.UV4Kind
  32735. * - VertexBuffer.UV5Kind
  32736. * - VertexBuffer.UV6Kind
  32737. * - VertexBuffer.ColorKind
  32738. * - VertexBuffer.MatricesIndicesKind
  32739. * - VertexBuffer.MatricesIndicesExtraKind
  32740. * - VertexBuffer.MatricesWeightsKind
  32741. * - VertexBuffer.MatricesWeightsExtraKind
  32742. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32743. */
  32744. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32745. /**
  32746. * Tests if a specific vertex buffer is associated with this mesh
  32747. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32748. * - VertexBuffer.PositionKind
  32749. * - VertexBuffer.NormalKind
  32750. * - VertexBuffer.UVKind
  32751. * - VertexBuffer.UV2Kind
  32752. * - VertexBuffer.UV3Kind
  32753. * - VertexBuffer.UV4Kind
  32754. * - VertexBuffer.UV5Kind
  32755. * - VertexBuffer.UV6Kind
  32756. * - VertexBuffer.ColorKind
  32757. * - VertexBuffer.MatricesIndicesKind
  32758. * - VertexBuffer.MatricesIndicesExtraKind
  32759. * - VertexBuffer.MatricesWeightsKind
  32760. * - VertexBuffer.MatricesWeightsExtraKind
  32761. * @returns a boolean
  32762. */
  32763. isVerticesDataPresent(kind: string): boolean;
  32764. /**
  32765. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32766. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32767. * - VertexBuffer.PositionKind
  32768. * - VertexBuffer.UVKind
  32769. * - VertexBuffer.UV2Kind
  32770. * - VertexBuffer.UV3Kind
  32771. * - VertexBuffer.UV4Kind
  32772. * - VertexBuffer.UV5Kind
  32773. * - VertexBuffer.UV6Kind
  32774. * - VertexBuffer.ColorKind
  32775. * - VertexBuffer.MatricesIndicesKind
  32776. * - VertexBuffer.MatricesIndicesExtraKind
  32777. * - VertexBuffer.MatricesWeightsKind
  32778. * - VertexBuffer.MatricesWeightsExtraKind
  32779. * @returns a boolean
  32780. */
  32781. isVertexBufferUpdatable(kind: string): boolean;
  32782. /**
  32783. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32784. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32785. * - VertexBuffer.PositionKind
  32786. * - VertexBuffer.NormalKind
  32787. * - VertexBuffer.UVKind
  32788. * - VertexBuffer.UV2Kind
  32789. * - VertexBuffer.UV3Kind
  32790. * - VertexBuffer.UV4Kind
  32791. * - VertexBuffer.UV5Kind
  32792. * - VertexBuffer.UV6Kind
  32793. * - VertexBuffer.ColorKind
  32794. * - VertexBuffer.MatricesIndicesKind
  32795. * - VertexBuffer.MatricesIndicesExtraKind
  32796. * - VertexBuffer.MatricesWeightsKind
  32797. * - VertexBuffer.MatricesWeightsExtraKind
  32798. * @returns an array of strings
  32799. */
  32800. getVerticesDataKinds(): string[];
  32801. /**
  32802. * Returns a positive integer : the total number of indices in this mesh geometry.
  32803. * @returns the numner of indices or zero if the mesh has no geometry.
  32804. */
  32805. getTotalIndices(): number;
  32806. /**
  32807. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32808. * @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.
  32809. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32810. * @returns the indices array or an empty array if the mesh has no geometry
  32811. */
  32812. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32813. get isBlocked(): boolean;
  32814. /**
  32815. * Determine if the current mesh is ready to be rendered
  32816. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32817. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32818. * @returns true if all associated assets are ready (material, textures, shaders)
  32819. */
  32820. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32821. /**
  32822. * 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.
  32823. */
  32824. get areNormalsFrozen(): boolean;
  32825. /**
  32826. * 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.
  32827. * @returns the current mesh
  32828. */
  32829. freezeNormals(): Mesh;
  32830. /**
  32831. * 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
  32832. * @returns the current mesh
  32833. */
  32834. unfreezeNormals(): Mesh;
  32835. /**
  32836. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32837. */
  32838. set overridenInstanceCount(count: number);
  32839. /** @hidden */
  32840. _preActivate(): Mesh;
  32841. /** @hidden */
  32842. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32843. /** @hidden */
  32844. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32845. protected _afterComputeWorldMatrix(): void;
  32846. /** @hidden */
  32847. _postActivate(): void;
  32848. /**
  32849. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32850. * This means the mesh underlying bounding box and sphere are recomputed.
  32851. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32852. * @returns the current mesh
  32853. */
  32854. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32855. /** @hidden */
  32856. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32857. /**
  32858. * This function will subdivide the mesh into multiple submeshes
  32859. * @param count defines the expected number of submeshes
  32860. */
  32861. subdivide(count: number): void;
  32862. /**
  32863. * Copy a FloatArray into a specific associated vertex buffer
  32864. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32865. * - VertexBuffer.PositionKind
  32866. * - VertexBuffer.UVKind
  32867. * - VertexBuffer.UV2Kind
  32868. * - VertexBuffer.UV3Kind
  32869. * - VertexBuffer.UV4Kind
  32870. * - VertexBuffer.UV5Kind
  32871. * - VertexBuffer.UV6Kind
  32872. * - VertexBuffer.ColorKind
  32873. * - VertexBuffer.MatricesIndicesKind
  32874. * - VertexBuffer.MatricesIndicesExtraKind
  32875. * - VertexBuffer.MatricesWeightsKind
  32876. * - VertexBuffer.MatricesWeightsExtraKind
  32877. * @param data defines the data source
  32878. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32879. * @param stride defines the data stride size (can be null)
  32880. * @returns the current mesh
  32881. */
  32882. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32883. /**
  32884. * Delete a vertex buffer associated with this mesh
  32885. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32886. * - VertexBuffer.PositionKind
  32887. * - VertexBuffer.UVKind
  32888. * - VertexBuffer.UV2Kind
  32889. * - VertexBuffer.UV3Kind
  32890. * - VertexBuffer.UV4Kind
  32891. * - VertexBuffer.UV5Kind
  32892. * - VertexBuffer.UV6Kind
  32893. * - VertexBuffer.ColorKind
  32894. * - VertexBuffer.MatricesIndicesKind
  32895. * - VertexBuffer.MatricesIndicesExtraKind
  32896. * - VertexBuffer.MatricesWeightsKind
  32897. * - VertexBuffer.MatricesWeightsExtraKind
  32898. */
  32899. removeVerticesData(kind: string): void;
  32900. /**
  32901. * Flags an associated vertex buffer as updatable
  32902. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32903. * - VertexBuffer.PositionKind
  32904. * - VertexBuffer.UVKind
  32905. * - VertexBuffer.UV2Kind
  32906. * - VertexBuffer.UV3Kind
  32907. * - VertexBuffer.UV4Kind
  32908. * - VertexBuffer.UV5Kind
  32909. * - VertexBuffer.UV6Kind
  32910. * - VertexBuffer.ColorKind
  32911. * - VertexBuffer.MatricesIndicesKind
  32912. * - VertexBuffer.MatricesIndicesExtraKind
  32913. * - VertexBuffer.MatricesWeightsKind
  32914. * - VertexBuffer.MatricesWeightsExtraKind
  32915. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32916. */
  32917. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32918. /**
  32919. * Sets the mesh global Vertex Buffer
  32920. * @param buffer defines the buffer to use
  32921. * @returns the current mesh
  32922. */
  32923. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32924. /**
  32925. * Update a specific associated vertex buffer
  32926. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32927. * - VertexBuffer.PositionKind
  32928. * - VertexBuffer.UVKind
  32929. * - VertexBuffer.UV2Kind
  32930. * - VertexBuffer.UV3Kind
  32931. * - VertexBuffer.UV4Kind
  32932. * - VertexBuffer.UV5Kind
  32933. * - VertexBuffer.UV6Kind
  32934. * - VertexBuffer.ColorKind
  32935. * - VertexBuffer.MatricesIndicesKind
  32936. * - VertexBuffer.MatricesIndicesExtraKind
  32937. * - VertexBuffer.MatricesWeightsKind
  32938. * - VertexBuffer.MatricesWeightsExtraKind
  32939. * @param data defines the data source
  32940. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32941. * @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)
  32942. * @returns the current mesh
  32943. */
  32944. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32945. /**
  32946. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32947. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32948. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32949. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32950. * @returns the current mesh
  32951. */
  32952. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32953. /**
  32954. * Creates a un-shared specific occurence of the geometry for the mesh.
  32955. * @returns the current mesh
  32956. */
  32957. makeGeometryUnique(): Mesh;
  32958. /**
  32959. * Set the index buffer of this mesh
  32960. * @param indices defines the source data
  32961. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32962. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32963. * @returns the current mesh
  32964. */
  32965. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32966. /**
  32967. * Update the current index buffer
  32968. * @param indices defines the source data
  32969. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32970. * @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)
  32971. * @returns the current mesh
  32972. */
  32973. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32974. /**
  32975. * Invert the geometry to move from a right handed system to a left handed one.
  32976. * @returns the current mesh
  32977. */
  32978. toLeftHanded(): Mesh;
  32979. /** @hidden */
  32980. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32981. /** @hidden */
  32982. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32983. /**
  32984. * Registers for this mesh a javascript function called just before the rendering process
  32985. * @param func defines the function to call before rendering this mesh
  32986. * @returns the current mesh
  32987. */
  32988. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32989. /**
  32990. * Disposes a previously registered javascript function called before the rendering
  32991. * @param func defines the function to remove
  32992. * @returns the current mesh
  32993. */
  32994. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32995. /**
  32996. * Registers for this mesh a javascript function called just after the rendering is complete
  32997. * @param func defines the function to call after rendering this mesh
  32998. * @returns the current mesh
  32999. */
  33000. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33001. /**
  33002. * Disposes a previously registered javascript function called after the rendering.
  33003. * @param func defines the function to remove
  33004. * @returns the current mesh
  33005. */
  33006. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33007. /** @hidden */
  33008. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33009. /** @hidden */
  33010. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33011. /** @hidden */
  33012. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33013. /** @hidden */
  33014. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33015. /** @hidden */
  33016. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33017. /** @hidden */
  33018. _rebuild(): void;
  33019. /** @hidden */
  33020. _freeze(): void;
  33021. /** @hidden */
  33022. _unFreeze(): void;
  33023. /**
  33024. * 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
  33025. * @param subMesh defines the subMesh to render
  33026. * @param enableAlphaMode defines if alpha mode can be changed
  33027. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33028. * @returns the current mesh
  33029. */
  33030. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33031. private _onBeforeDraw;
  33032. /**
  33033. * Renormalize the mesh and patch it up if there are no weights
  33034. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33035. * However in the case of zero weights then we set just a single influence to 1.
  33036. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33037. */
  33038. cleanMatrixWeights(): void;
  33039. private normalizeSkinFourWeights;
  33040. private normalizeSkinWeightsAndExtra;
  33041. /**
  33042. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33043. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33044. * the user know there was an issue with importing the mesh
  33045. * @returns a validation object with skinned, valid and report string
  33046. */
  33047. validateSkinning(): {
  33048. skinned: boolean;
  33049. valid: boolean;
  33050. report: string;
  33051. };
  33052. /** @hidden */
  33053. _checkDelayState(): Mesh;
  33054. private _queueLoad;
  33055. /**
  33056. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33057. * A mesh is in the frustum if its bounding box intersects the frustum
  33058. * @param frustumPlanes defines the frustum to test
  33059. * @returns true if the mesh is in the frustum planes
  33060. */
  33061. isInFrustum(frustumPlanes: Plane[]): boolean;
  33062. /**
  33063. * Sets the mesh material by the material or multiMaterial `id` property
  33064. * @param id is a string identifying the material or the multiMaterial
  33065. * @returns the current mesh
  33066. */
  33067. setMaterialByID(id: string): Mesh;
  33068. /**
  33069. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33070. * @returns an array of IAnimatable
  33071. */
  33072. getAnimatables(): IAnimatable[];
  33073. /**
  33074. * Modifies the mesh geometry according to the passed transformation matrix.
  33075. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33076. * The mesh normals are modified using the same transformation.
  33077. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33078. * @param transform defines the transform matrix to use
  33079. * @see https://doc.babylonjs.com/resources/baking_transformations
  33080. * @returns the current mesh
  33081. */
  33082. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33083. /**
  33084. * Modifies the mesh geometry according to its own current World Matrix.
  33085. * The mesh World Matrix is then reset.
  33086. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33087. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33088. * @see https://doc.babylonjs.com/resources/baking_transformations
  33089. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33090. * @returns the current mesh
  33091. */
  33092. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33093. /** @hidden */
  33094. get _positions(): Nullable<Vector3[]>;
  33095. /** @hidden */
  33096. _resetPointsArrayCache(): Mesh;
  33097. /** @hidden */
  33098. _generatePointsArray(): boolean;
  33099. /**
  33100. * Returns a new Mesh object generated from the current mesh properties.
  33101. * This method must not get confused with createInstance()
  33102. * @param name is a string, the name given to the new mesh
  33103. * @param newParent can be any Node object (default `null`)
  33104. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33105. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33106. * @returns a new mesh
  33107. */
  33108. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33109. /**
  33110. * Releases resources associated with this mesh.
  33111. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33112. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33113. */
  33114. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33115. /** @hidden */
  33116. _disposeInstanceSpecificData(): void;
  33117. /** @hidden */
  33118. _disposeThinInstanceSpecificData(): void;
  33119. /**
  33120. * Modifies the mesh geometry according to a displacement map.
  33121. * 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.
  33122. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33123. * @param url is a string, the URL from the image file is to be downloaded.
  33124. * @param minHeight is the lower limit of the displacement.
  33125. * @param maxHeight is the upper limit of the displacement.
  33126. * @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.
  33127. * @param uvOffset is an optional vector2 used to offset UV.
  33128. * @param uvScale is an optional vector2 used to scale UV.
  33129. * @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.
  33130. * @returns the Mesh.
  33131. */
  33132. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33133. /**
  33134. * Modifies the mesh geometry according to a displacementMap buffer.
  33135. * 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.
  33136. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33137. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33138. * @param heightMapWidth is the width of the buffer image.
  33139. * @param heightMapHeight is the height of the buffer image.
  33140. * @param minHeight is the lower limit of the displacement.
  33141. * @param maxHeight is the upper limit of the displacement.
  33142. * @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.
  33143. * @param uvOffset is an optional vector2 used to offset UV.
  33144. * @param uvScale is an optional vector2 used to scale UV.
  33145. * @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.
  33146. * @returns the Mesh.
  33147. */
  33148. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33149. /**
  33150. * Modify the mesh to get a flat shading rendering.
  33151. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33152. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33153. * @returns current mesh
  33154. */
  33155. convertToFlatShadedMesh(): Mesh;
  33156. /**
  33157. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33158. * In other words, more vertices, no more indices and a single bigger VBO.
  33159. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33160. * @returns current mesh
  33161. */
  33162. convertToUnIndexedMesh(): Mesh;
  33163. /**
  33164. * Inverses facet orientations.
  33165. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33166. * @param flipNormals will also inverts the normals
  33167. * @returns current mesh
  33168. */
  33169. flipFaces(flipNormals?: boolean): Mesh;
  33170. /**
  33171. * Increase the number of facets and hence vertices in a mesh
  33172. * Vertex normals are interpolated from existing vertex normals
  33173. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33174. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33175. */
  33176. increaseVertices(numberPerEdge: number): void;
  33177. /**
  33178. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33179. * This will undo any application of covertToFlatShadedMesh
  33180. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33181. */
  33182. forceSharedVertices(): void;
  33183. /** @hidden */
  33184. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33185. /** @hidden */
  33186. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33187. /**
  33188. * Creates a new InstancedMesh object from the mesh model.
  33189. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33190. * @param name defines the name of the new instance
  33191. * @returns a new InstancedMesh
  33192. */
  33193. createInstance(name: string): InstancedMesh;
  33194. /**
  33195. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33196. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33197. * @returns the current mesh
  33198. */
  33199. synchronizeInstances(): Mesh;
  33200. /**
  33201. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33202. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33203. * This should be used together with the simplification to avoid disappearing triangles.
  33204. * @param successCallback an optional success callback to be called after the optimization finished.
  33205. * @returns the current mesh
  33206. */
  33207. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33208. /**
  33209. * Serialize current mesh
  33210. * @param serializationObject defines the object which will receive the serialization data
  33211. */
  33212. serialize(serializationObject: any): void;
  33213. /** @hidden */
  33214. _syncGeometryWithMorphTargetManager(): void;
  33215. /** @hidden */
  33216. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33217. /**
  33218. * Returns a new Mesh object parsed from the source provided.
  33219. * @param parsedMesh is the source
  33220. * @param scene defines the hosting scene
  33221. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33222. * @returns a new Mesh
  33223. */
  33224. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33225. /**
  33226. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33227. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33228. * @param name defines the name of the mesh to create
  33229. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33230. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33231. * @param closePath creates a seam between the first and the last points of each path of the path array
  33232. * @param offset is taken in account only if the `pathArray` is containing a single path
  33233. * @param scene defines the hosting scene
  33234. * @param updatable defines if the mesh must be flagged as updatable
  33235. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33236. * @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)
  33237. * @returns a new Mesh
  33238. */
  33239. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33240. /**
  33241. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33242. * @param name defines the name of the mesh to create
  33243. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33244. * @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
  33245. * @param scene defines the hosting scene
  33246. * @param updatable defines if the mesh must be flagged as updatable
  33247. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33248. * @returns a new Mesh
  33249. */
  33250. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33251. /**
  33252. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33253. * @param name defines the name of the mesh to create
  33254. * @param size sets the size (float) of each box side (default 1)
  33255. * @param scene defines the hosting scene
  33256. * @param updatable defines if the mesh must be flagged as updatable
  33257. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33258. * @returns a new Mesh
  33259. */
  33260. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33261. /**
  33262. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33263. * @param name defines the name of the mesh to create
  33264. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33265. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33266. * @param scene defines the hosting scene
  33267. * @param updatable defines if the mesh must be flagged as updatable
  33268. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33269. * @returns a new Mesh
  33270. */
  33271. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33272. /**
  33273. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33274. * @param name defines the name of the mesh to create
  33275. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33276. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33277. * @param scene defines the hosting scene
  33278. * @returns a new Mesh
  33279. */
  33280. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33281. /**
  33282. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  33285. * @param diameterTop set the top cap diameter (floats, default 1)
  33286. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33287. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33288. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33289. * @param scene defines the hosting scene
  33290. * @param updatable defines if the mesh must be flagged as updatable
  33291. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33292. * @returns a new Mesh
  33293. */
  33294. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33295. /**
  33296. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33297. * @param name defines the name of the mesh to create
  33298. * @param diameter sets the diameter size (float) of the torus (default 1)
  33299. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33300. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33301. * @param scene defines the hosting scene
  33302. * @param updatable defines if the mesh must be flagged as updatable
  33303. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33304. * @returns a new Mesh
  33305. */
  33306. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33307. /**
  33308. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33309. * @param name defines the name of the mesh to create
  33310. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33311. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33312. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33313. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33314. * @param p the number of windings on X axis (positive integers, default 2)
  33315. * @param q the number of windings on Y axis (positive integers, default 3)
  33316. * @param scene defines the hosting scene
  33317. * @param updatable defines if the mesh must be flagged as updatable
  33318. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33319. * @returns a new Mesh
  33320. */
  33321. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33322. /**
  33323. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33324. * @param name defines the name of the mesh to create
  33325. * @param points is an array successive Vector3
  33326. * @param scene defines the hosting scene
  33327. * @param updatable defines if the mesh must be flagged as updatable
  33328. * @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).
  33329. * @returns a new Mesh
  33330. */
  33331. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33332. /**
  33333. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33334. * @param name defines the name of the mesh to create
  33335. * @param points is an array successive Vector3
  33336. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33337. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33338. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33339. * @param scene defines the hosting scene
  33340. * @param updatable defines if the mesh must be flagged as updatable
  33341. * @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)
  33342. * @returns a new Mesh
  33343. */
  33344. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33345. /**
  33346. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33347. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33348. * 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.
  33349. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33350. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33351. * Remember you can only change the shape positions, not their number when updating a polygon.
  33352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33353. * @param name defines the name of the mesh to create
  33354. * @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
  33355. * @param scene defines the hosting scene
  33356. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33357. * @param updatable defines if the mesh must be flagged as updatable
  33358. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33359. * @param earcutInjection can be used to inject your own earcut reference
  33360. * @returns a new Mesh
  33361. */
  33362. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33363. /**
  33364. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33366. * @param name defines the name of the mesh to create
  33367. * @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
  33368. * @param depth defines the height of extrusion
  33369. * @param scene defines the hosting scene
  33370. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33371. * @param updatable defines if the mesh must be flagged as updatable
  33372. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33373. * @param earcutInjection can be used to inject your own earcut reference
  33374. * @returns a new Mesh
  33375. */
  33376. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33377. /**
  33378. * Creates an extruded shape mesh.
  33379. * 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
  33380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33382. * @param name defines the name of the mesh to create
  33383. * @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
  33384. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33385. * @param scale is the value to scale the shape
  33386. * @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
  33387. * @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
  33388. * @param scene defines the hosting scene
  33389. * @param updatable defines if the mesh must be flagged as updatable
  33390. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33391. * @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)
  33392. * @returns a new Mesh
  33393. */
  33394. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33395. /**
  33396. * Creates an custom extruded shape mesh.
  33397. * The custom extrusion is a parametric shape.
  33398. * It has no predefined shape. Its final shape will depend on the input parameters.
  33399. * Please consider using the same method from the MeshBuilder class instead
  33400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33401. * @param name defines the name of the mesh to create
  33402. * @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
  33403. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33404. * @param scaleFunction is a custom Javascript function called on each path point
  33405. * @param rotationFunction is a custom Javascript function called on each path point
  33406. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33407. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33408. * @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
  33409. * @param scene defines the hosting scene
  33410. * @param updatable defines if the mesh must be flagged as updatable
  33411. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33412. * @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)
  33413. * @returns a new Mesh
  33414. */
  33415. 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;
  33416. /**
  33417. * Creates lathe mesh.
  33418. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33419. * Please consider using the same method from the MeshBuilder class instead
  33420. * @param name defines the name of the mesh to create
  33421. * @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
  33422. * @param radius is the radius value of the lathe
  33423. * @param tessellation is the side number of the lathe.
  33424. * @param scene defines the hosting scene
  33425. * @param updatable defines if the mesh must be flagged as updatable
  33426. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33427. * @returns a new Mesh
  33428. */
  33429. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33430. /**
  33431. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33432. * @param name defines the name of the mesh to create
  33433. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33434. * @param scene defines the hosting scene
  33435. * @param updatable defines if the mesh must be flagged as updatable
  33436. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33437. * @returns a new Mesh
  33438. */
  33439. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33440. /**
  33441. * Creates a ground mesh.
  33442. * Please consider using the same method from the MeshBuilder class instead
  33443. * @param name defines the name of the mesh to create
  33444. * @param width set the width of the ground
  33445. * @param height set the height of the ground
  33446. * @param subdivisions sets the number of subdivisions per side
  33447. * @param scene defines the hosting scene
  33448. * @param updatable defines if the mesh must be flagged as updatable
  33449. * @returns a new Mesh
  33450. */
  33451. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33452. /**
  33453. * Creates a tiled ground mesh.
  33454. * Please consider using the same method from the MeshBuilder class instead
  33455. * @param name defines the name of the mesh to create
  33456. * @param xmin set the ground minimum X coordinate
  33457. * @param zmin set the ground minimum Y coordinate
  33458. * @param xmax set the ground maximum X coordinate
  33459. * @param zmax set the ground maximum Z coordinate
  33460. * @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
  33461. * @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
  33462. * @param scene defines the hosting scene
  33463. * @param updatable defines if the mesh must be flagged as updatable
  33464. * @returns a new Mesh
  33465. */
  33466. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33467. w: number;
  33468. h: number;
  33469. }, precision: {
  33470. w: number;
  33471. h: number;
  33472. }, scene: Scene, updatable?: boolean): Mesh;
  33473. /**
  33474. * Creates a ground mesh from a height map.
  33475. * Please consider using the same method from the MeshBuilder class instead
  33476. * @see https://doc.babylonjs.com/babylon101/height_map
  33477. * @param name defines the name of the mesh to create
  33478. * @param url sets the URL of the height map image resource
  33479. * @param width set the ground width size
  33480. * @param height set the ground height size
  33481. * @param subdivisions sets the number of subdivision per side
  33482. * @param minHeight is the minimum altitude on the ground
  33483. * @param maxHeight is the maximum altitude on the ground
  33484. * @param scene defines the hosting scene
  33485. * @param updatable defines if the mesh must be flagged as updatable
  33486. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33487. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33488. * @returns a new Mesh
  33489. */
  33490. 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;
  33491. /**
  33492. * Creates a tube mesh.
  33493. * The tube is a parametric shape.
  33494. * It has no predefined shape. Its final shape will depend on the input parameters.
  33495. * Please consider using the same method from the MeshBuilder class instead
  33496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33497. * @param name defines the name of the mesh to create
  33498. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33499. * @param radius sets the tube radius size
  33500. * @param tessellation is the number of sides on the tubular surface
  33501. * @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
  33502. * @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
  33503. * @param scene defines the hosting scene
  33504. * @param updatable defines if the mesh must be flagged as updatable
  33505. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33506. * @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)
  33507. * @returns a new Mesh
  33508. */
  33509. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33510. (i: number, distance: number): number;
  33511. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33512. /**
  33513. * Creates a polyhedron mesh.
  33514. * Please consider using the same method from the MeshBuilder class instead.
  33515. * * 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
  33516. * * The parameter `size` (positive float, default 1) sets the polygon size
  33517. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33518. * * 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`
  33519. * * 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
  33520. * * 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)`)
  33521. * * 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
  33522. * * 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
  33523. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33524. * * 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
  33525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33526. * @param name defines the name of the mesh to create
  33527. * @param options defines the options used to create the mesh
  33528. * @param scene defines the hosting scene
  33529. * @returns a new Mesh
  33530. */
  33531. static CreatePolyhedron(name: string, options: {
  33532. type?: number;
  33533. size?: number;
  33534. sizeX?: number;
  33535. sizeY?: number;
  33536. sizeZ?: number;
  33537. custom?: any;
  33538. faceUV?: Vector4[];
  33539. faceColors?: Color4[];
  33540. updatable?: boolean;
  33541. sideOrientation?: number;
  33542. }, scene: Scene): Mesh;
  33543. /**
  33544. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33545. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33546. * * 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`)
  33547. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33548. * * 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
  33549. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33550. * * 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
  33551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33552. * @param name defines the name of the mesh
  33553. * @param options defines the options used to create the mesh
  33554. * @param scene defines the hosting scene
  33555. * @returns a new Mesh
  33556. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33557. */
  33558. static CreateIcoSphere(name: string, options: {
  33559. radius?: number;
  33560. flat?: boolean;
  33561. subdivisions?: number;
  33562. sideOrientation?: number;
  33563. updatable?: boolean;
  33564. }, scene: Scene): Mesh;
  33565. /**
  33566. * Creates a decal mesh.
  33567. * Please consider using the same method from the MeshBuilder class instead.
  33568. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33569. * @param name defines the name of the mesh
  33570. * @param sourceMesh defines the mesh receiving the decal
  33571. * @param position sets the position of the decal in world coordinates
  33572. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33573. * @param size sets the decal scaling
  33574. * @param angle sets the angle to rotate the decal
  33575. * @returns a new Mesh
  33576. */
  33577. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33578. /** Creates a Capsule Mesh
  33579. * @param name defines the name of the mesh.
  33580. * @param options the constructors options used to shape the mesh.
  33581. * @param scene defines the scene the mesh is scoped to.
  33582. * @returns the capsule mesh
  33583. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33584. */
  33585. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33586. /**
  33587. * Prepare internal position array for software CPU skinning
  33588. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33589. */
  33590. setPositionsForCPUSkinning(): Float32Array;
  33591. /**
  33592. * Prepare internal normal array for software CPU skinning
  33593. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33594. */
  33595. setNormalsForCPUSkinning(): Float32Array;
  33596. /**
  33597. * Updates the vertex buffer by applying transformation from the bones
  33598. * @param skeleton defines the skeleton to apply to current mesh
  33599. * @returns the current mesh
  33600. */
  33601. applySkeleton(skeleton: Skeleton): Mesh;
  33602. /**
  33603. * 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
  33604. * @param meshes defines the list of meshes to scan
  33605. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33606. */
  33607. static MinMax(meshes: AbstractMesh[]): {
  33608. min: Vector3;
  33609. max: Vector3;
  33610. };
  33611. /**
  33612. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33613. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33614. * @returns a vector3
  33615. */
  33616. static Center(meshesOrMinMaxVector: {
  33617. min: Vector3;
  33618. max: Vector3;
  33619. } | AbstractMesh[]): Vector3;
  33620. /**
  33621. * Merge the array of meshes into a single mesh for performance reasons.
  33622. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33623. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33624. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33625. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33626. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33627. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33628. * @returns a new mesh
  33629. */
  33630. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33631. /** @hidden */
  33632. addInstance(instance: InstancedMesh): void;
  33633. /** @hidden */
  33634. removeInstance(instance: InstancedMesh): void;
  33635. }
  33636. }
  33637. declare module BABYLON {
  33638. /**
  33639. * This is the base class of all the camera used in the application.
  33640. * @see https://doc.babylonjs.com/features/cameras
  33641. */
  33642. export class Camera extends Node {
  33643. /** @hidden */
  33644. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33645. /**
  33646. * This is the default projection mode used by the cameras.
  33647. * It helps recreating a feeling of perspective and better appreciate depth.
  33648. * This is the best way to simulate real life cameras.
  33649. */
  33650. static readonly PERSPECTIVE_CAMERA: number;
  33651. /**
  33652. * This helps creating camera with an orthographic mode.
  33653. * 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.
  33654. */
  33655. static readonly ORTHOGRAPHIC_CAMERA: number;
  33656. /**
  33657. * This is the default FOV mode for perspective cameras.
  33658. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33659. */
  33660. static readonly FOVMODE_VERTICAL_FIXED: number;
  33661. /**
  33662. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33663. */
  33664. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33665. /**
  33666. * This specifies ther is no need for a camera rig.
  33667. * Basically only one eye is rendered corresponding to the camera.
  33668. */
  33669. static readonly RIG_MODE_NONE: number;
  33670. /**
  33671. * Simulates a camera Rig with one blue eye and one red eye.
  33672. * This can be use with 3d blue and red glasses.
  33673. */
  33674. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33675. /**
  33676. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33677. */
  33678. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33679. /**
  33680. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33681. */
  33682. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33683. /**
  33684. * Defines that both eyes of the camera will be rendered over under each other.
  33685. */
  33686. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33687. /**
  33688. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33689. */
  33690. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33691. /**
  33692. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33693. */
  33694. static readonly RIG_MODE_VR: number;
  33695. /**
  33696. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33697. */
  33698. static readonly RIG_MODE_WEBVR: number;
  33699. /**
  33700. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33701. */
  33702. static readonly RIG_MODE_CUSTOM: number;
  33703. /**
  33704. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33705. */
  33706. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33707. /**
  33708. * Define the input manager associated with the camera.
  33709. */
  33710. inputs: CameraInputsManager<Camera>;
  33711. /** @hidden */
  33712. _position: Vector3;
  33713. /**
  33714. * Define the current local position of the camera in the scene
  33715. */
  33716. get position(): Vector3;
  33717. set position(newPosition: Vector3);
  33718. protected _upVector: Vector3;
  33719. /**
  33720. * The vector the camera should consider as up.
  33721. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33722. */
  33723. set upVector(vec: Vector3);
  33724. get upVector(): Vector3;
  33725. /**
  33726. * Define the current limit on the left side for an orthographic camera
  33727. * In scene unit
  33728. */
  33729. orthoLeft: Nullable<number>;
  33730. /**
  33731. * Define the current limit on the right side for an orthographic camera
  33732. * In scene unit
  33733. */
  33734. orthoRight: Nullable<number>;
  33735. /**
  33736. * Define the current limit on the bottom side for an orthographic camera
  33737. * In scene unit
  33738. */
  33739. orthoBottom: Nullable<number>;
  33740. /**
  33741. * Define the current limit on the top side for an orthographic camera
  33742. * In scene unit
  33743. */
  33744. orthoTop: Nullable<number>;
  33745. /**
  33746. * Field Of View is set in Radians. (default is 0.8)
  33747. */
  33748. fov: number;
  33749. /**
  33750. * Define the minimum distance the camera can see from.
  33751. * This is important to note that the depth buffer are not infinite and the closer it starts
  33752. * the more your scene might encounter depth fighting issue.
  33753. */
  33754. minZ: number;
  33755. /**
  33756. * Define the maximum distance the camera can see to.
  33757. * This is important to note that the depth buffer are not infinite and the further it end
  33758. * the more your scene might encounter depth fighting issue.
  33759. */
  33760. maxZ: number;
  33761. /**
  33762. * Define the default inertia of the camera.
  33763. * This helps giving a smooth feeling to the camera movement.
  33764. */
  33765. inertia: number;
  33766. /**
  33767. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  33768. */
  33769. mode: number;
  33770. /**
  33771. * Define whether the camera is intermediate.
  33772. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  33773. */
  33774. isIntermediate: boolean;
  33775. /**
  33776. * Define the viewport of the camera.
  33777. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  33778. */
  33779. viewport: Viewport;
  33780. /**
  33781. * Restricts the camera to viewing objects with the same layerMask.
  33782. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  33783. */
  33784. layerMask: number;
  33785. /**
  33786. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  33787. */
  33788. fovMode: number;
  33789. /**
  33790. * Rig mode of the camera.
  33791. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  33792. * This is normally controlled byt the camera themselves as internal use.
  33793. */
  33794. cameraRigMode: number;
  33795. /**
  33796. * Defines the distance between both "eyes" in case of a RIG
  33797. */
  33798. interaxialDistance: number;
  33799. /**
  33800. * Defines if stereoscopic rendering is done side by side or over under.
  33801. */
  33802. isStereoscopicSideBySide: boolean;
  33803. /**
  33804. * 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
  33805. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  33806. * else in the scene. (Eg. security camera)
  33807. *
  33808. * 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)
  33809. */
  33810. customRenderTargets: RenderTargetTexture[];
  33811. /**
  33812. * When set, the camera will render to this render target instead of the default canvas
  33813. *
  33814. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  33815. */
  33816. outputRenderTarget: Nullable<RenderTargetTexture>;
  33817. /**
  33818. * Observable triggered when the camera view matrix has changed.
  33819. */
  33820. onViewMatrixChangedObservable: Observable<Camera>;
  33821. /**
  33822. * Observable triggered when the camera Projection matrix has changed.
  33823. */
  33824. onProjectionMatrixChangedObservable: Observable<Camera>;
  33825. /**
  33826. * Observable triggered when the inputs have been processed.
  33827. */
  33828. onAfterCheckInputsObservable: Observable<Camera>;
  33829. /**
  33830. * Observable triggered when reset has been called and applied to the camera.
  33831. */
  33832. onRestoreStateObservable: Observable<Camera>;
  33833. /**
  33834. * Is this camera a part of a rig system?
  33835. */
  33836. isRigCamera: boolean;
  33837. /**
  33838. * If isRigCamera set to true this will be set with the parent camera.
  33839. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  33840. */
  33841. rigParent?: Camera;
  33842. /** @hidden */
  33843. _cameraRigParams: any;
  33844. /** @hidden */
  33845. _rigCameras: Camera[];
  33846. /** @hidden */
  33847. _rigPostProcess: Nullable<PostProcess>;
  33848. protected _webvrViewMatrix: Matrix;
  33849. /** @hidden */
  33850. _skipRendering: boolean;
  33851. /** @hidden */
  33852. _projectionMatrix: Matrix;
  33853. /** @hidden */
  33854. _postProcesses: Nullable<PostProcess>[];
  33855. /** @hidden */
  33856. _activeMeshes: SmartArray<AbstractMesh>;
  33857. protected _globalPosition: Vector3;
  33858. /** @hidden */
  33859. _computedViewMatrix: Matrix;
  33860. private _doNotComputeProjectionMatrix;
  33861. private _transformMatrix;
  33862. private _frustumPlanes;
  33863. private _refreshFrustumPlanes;
  33864. private _storedFov;
  33865. private _stateStored;
  33866. /**
  33867. * Instantiates a new camera object.
  33868. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  33869. * @see https://doc.babylonjs.com/features/cameras
  33870. * @param name Defines the name of the camera in the scene
  33871. * @param position Defines the position of the camera
  33872. * @param scene Defines the scene the camera belongs too
  33873. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  33874. */
  33875. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33876. /**
  33877. * Store current camera state (fov, position, etc..)
  33878. * @returns the camera
  33879. */
  33880. storeState(): Camera;
  33881. /**
  33882. * Restores the camera state values if it has been stored. You must call storeState() first
  33883. */
  33884. protected _restoreStateValues(): boolean;
  33885. /**
  33886. * Restored camera state. You must call storeState() first.
  33887. * @returns true if restored and false otherwise
  33888. */
  33889. restoreState(): boolean;
  33890. /**
  33891. * Gets the class name of the camera.
  33892. * @returns the class name
  33893. */
  33894. getClassName(): string;
  33895. /** @hidden */
  33896. readonly _isCamera: boolean;
  33897. /**
  33898. * Gets a string representation of the camera useful for debug purpose.
  33899. * @param fullDetails Defines that a more verboe level of logging is required
  33900. * @returns the string representation
  33901. */
  33902. toString(fullDetails?: boolean): string;
  33903. /**
  33904. * Gets the current world space position of the camera.
  33905. */
  33906. get globalPosition(): Vector3;
  33907. /**
  33908. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  33909. * @returns the active meshe list
  33910. */
  33911. getActiveMeshes(): SmartArray<AbstractMesh>;
  33912. /**
  33913. * Check whether a mesh is part of the current active mesh list of the camera
  33914. * @param mesh Defines the mesh to check
  33915. * @returns true if active, false otherwise
  33916. */
  33917. isActiveMesh(mesh: Mesh): boolean;
  33918. /**
  33919. * Is this camera ready to be used/rendered
  33920. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  33921. * @return true if the camera is ready
  33922. */
  33923. isReady(completeCheck?: boolean): boolean;
  33924. /** @hidden */
  33925. _initCache(): void;
  33926. /** @hidden */
  33927. _updateCache(ignoreParentClass?: boolean): void;
  33928. /** @hidden */
  33929. _isSynchronized(): boolean;
  33930. /** @hidden */
  33931. _isSynchronizedViewMatrix(): boolean;
  33932. /** @hidden */
  33933. _isSynchronizedProjectionMatrix(): boolean;
  33934. /**
  33935. * Attach the input controls to a specific dom element to get the input from.
  33936. * @param element Defines the element the controls should be listened from
  33937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33938. */
  33939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33940. /**
  33941. * Detach the current controls from the specified dom element.
  33942. * @param element Defines the element to stop listening the inputs from
  33943. */
  33944. detachControl(element: HTMLElement): void;
  33945. /**
  33946. * Update the camera state according to the different inputs gathered during the frame.
  33947. */
  33948. update(): void;
  33949. /** @hidden */
  33950. _checkInputs(): void;
  33951. /** @hidden */
  33952. get rigCameras(): Camera[];
  33953. /**
  33954. * Gets the post process used by the rig cameras
  33955. */
  33956. get rigPostProcess(): Nullable<PostProcess>;
  33957. /**
  33958. * Internal, gets the first post proces.
  33959. * @returns the first post process to be run on this camera.
  33960. */
  33961. _getFirstPostProcess(): Nullable<PostProcess>;
  33962. private _cascadePostProcessesToRigCams;
  33963. /**
  33964. * Attach a post process to the camera.
  33965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33966. * @param postProcess The post process to attach to the camera
  33967. * @param insertAt The position of the post process in case several of them are in use in the scene
  33968. * @returns the position the post process has been inserted at
  33969. */
  33970. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  33971. /**
  33972. * Detach a post process to the camera.
  33973. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33974. * @param postProcess The post process to detach from the camera
  33975. */
  33976. detachPostProcess(postProcess: PostProcess): void;
  33977. /**
  33978. * Gets the current world matrix of the camera
  33979. */
  33980. getWorldMatrix(): Matrix;
  33981. /** @hidden */
  33982. _getViewMatrix(): Matrix;
  33983. /**
  33984. * Gets the current view matrix of the camera.
  33985. * @param force forces the camera to recompute the matrix without looking at the cached state
  33986. * @returns the view matrix
  33987. */
  33988. getViewMatrix(force?: boolean): Matrix;
  33989. /**
  33990. * Freeze the projection matrix.
  33991. * It will prevent the cache check of the camera projection compute and can speed up perf
  33992. * if no parameter of the camera are meant to change
  33993. * @param projection Defines manually a projection if necessary
  33994. */
  33995. freezeProjectionMatrix(projection?: Matrix): void;
  33996. /**
  33997. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  33998. */
  33999. unfreezeProjectionMatrix(): void;
  34000. /**
  34001. * Gets the current projection matrix of the camera.
  34002. * @param force forces the camera to recompute the matrix without looking at the cached state
  34003. * @returns the projection matrix
  34004. */
  34005. getProjectionMatrix(force?: boolean): Matrix;
  34006. /**
  34007. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34008. * @returns a Matrix
  34009. */
  34010. getTransformationMatrix(): Matrix;
  34011. private _updateFrustumPlanes;
  34012. /**
  34013. * Checks if a cullable object (mesh...) is in the camera frustum
  34014. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34015. * @param target The object to check
  34016. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34017. * @returns true if the object is in frustum otherwise false
  34018. */
  34019. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34020. /**
  34021. * Checks if a cullable object (mesh...) is in the camera frustum
  34022. * Unlike isInFrustum this cheks the full bounding box
  34023. * @param target The object to check
  34024. * @returns true if the object is in frustum otherwise false
  34025. */
  34026. isCompletelyInFrustum(target: ICullable): boolean;
  34027. /**
  34028. * Gets a ray in the forward direction from the camera.
  34029. * @param length Defines the length of the ray to create
  34030. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34031. * @param origin Defines the start point of the ray which defaults to the camera position
  34032. * @returns the forward ray
  34033. */
  34034. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34035. /**
  34036. * Gets a ray in the forward direction from the camera.
  34037. * @param refRay the ray to (re)use when setting the values
  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. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34044. /**
  34045. * Releases resources associated with this node.
  34046. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34047. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34048. */
  34049. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34050. /** @hidden */
  34051. _isLeftCamera: boolean;
  34052. /**
  34053. * Gets the left camera of a rig setup in case of Rigged Camera
  34054. */
  34055. get isLeftCamera(): boolean;
  34056. /** @hidden */
  34057. _isRightCamera: boolean;
  34058. /**
  34059. * Gets the right camera of a rig setup in case of Rigged Camera
  34060. */
  34061. get isRightCamera(): boolean;
  34062. /**
  34063. * Gets the left camera of a rig setup in case of Rigged Camera
  34064. */
  34065. get leftCamera(): Nullable<FreeCamera>;
  34066. /**
  34067. * Gets the right camera of a rig setup in case of Rigged Camera
  34068. */
  34069. get rightCamera(): Nullable<FreeCamera>;
  34070. /**
  34071. * Gets the left camera target of a rig setup in case of Rigged Camera
  34072. * @returns the target position
  34073. */
  34074. getLeftTarget(): Nullable<Vector3>;
  34075. /**
  34076. * Gets the right camera target of a rig setup in case of Rigged Camera
  34077. * @returns the target position
  34078. */
  34079. getRightTarget(): Nullable<Vector3>;
  34080. /**
  34081. * @hidden
  34082. */
  34083. setCameraRigMode(mode: number, rigParams: any): void;
  34084. /** @hidden */
  34085. static _setStereoscopicRigMode(camera: Camera): void;
  34086. /** @hidden */
  34087. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34088. /** @hidden */
  34089. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34090. /** @hidden */
  34091. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34092. /** @hidden */
  34093. _getVRProjectionMatrix(): Matrix;
  34094. protected _updateCameraRotationMatrix(): void;
  34095. protected _updateWebVRCameraRotationMatrix(): void;
  34096. /**
  34097. * This function MUST be overwritten by the different WebVR cameras available.
  34098. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34099. * @hidden
  34100. */
  34101. _getWebVRProjectionMatrix(): Matrix;
  34102. /**
  34103. * This function MUST be overwritten by the different WebVR cameras available.
  34104. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34105. * @hidden
  34106. */
  34107. _getWebVRViewMatrix(): Matrix;
  34108. /** @hidden */
  34109. setCameraRigParameter(name: string, value: any): void;
  34110. /**
  34111. * needs to be overridden by children so sub has required properties to be copied
  34112. * @hidden
  34113. */
  34114. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34115. /**
  34116. * May need to be overridden by children
  34117. * @hidden
  34118. */
  34119. _updateRigCameras(): void;
  34120. /** @hidden */
  34121. _setupInputs(): void;
  34122. /**
  34123. * Serialiaze the camera setup to a json represention
  34124. * @returns the JSON representation
  34125. */
  34126. serialize(): any;
  34127. /**
  34128. * Clones the current camera.
  34129. * @param name The cloned camera name
  34130. * @returns the cloned camera
  34131. */
  34132. clone(name: string): Camera;
  34133. /**
  34134. * Gets the direction of the camera relative to a given local axis.
  34135. * @param localAxis Defines the reference axis to provide a relative direction.
  34136. * @return the direction
  34137. */
  34138. getDirection(localAxis: Vector3): Vector3;
  34139. /**
  34140. * Returns the current camera absolute rotation
  34141. */
  34142. get absoluteRotation(): Quaternion;
  34143. /**
  34144. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34145. * @param localAxis Defines the reference axis to provide a relative direction.
  34146. * @param result Defines the vector to store the result in
  34147. */
  34148. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34149. /**
  34150. * Gets a camera constructor for a given camera type
  34151. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34152. * @param name The name of the camera the result will be able to instantiate
  34153. * @param scene The scene the result will construct the camera in
  34154. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34155. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34156. * @returns a factory method to construc the camera
  34157. */
  34158. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34159. /**
  34160. * Compute the world matrix of the camera.
  34161. * @returns the camera world matrix
  34162. */
  34163. computeWorldMatrix(): Matrix;
  34164. /**
  34165. * Parse a JSON and creates the camera from the parsed information
  34166. * @param parsedCamera The JSON to parse
  34167. * @param scene The scene to instantiate the camera in
  34168. * @returns the newly constructed camera
  34169. */
  34170. static Parse(parsedCamera: any, scene: Scene): Camera;
  34171. }
  34172. }
  34173. declare module BABYLON {
  34174. /**
  34175. * Class containing static functions to help procedurally build meshes
  34176. */
  34177. export class DiscBuilder {
  34178. /**
  34179. * Creates a plane polygonal mesh. By default, this is a disc
  34180. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34181. * * 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
  34182. * * 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
  34183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34184. * * 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
  34185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34186. * @param name defines the name of the mesh
  34187. * @param options defines the options used to create the mesh
  34188. * @param scene defines the hosting scene
  34189. * @returns the plane polygonal mesh
  34190. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34191. */
  34192. static CreateDisc(name: string, options: {
  34193. radius?: number;
  34194. tessellation?: number;
  34195. arc?: number;
  34196. updatable?: boolean;
  34197. sideOrientation?: number;
  34198. frontUVs?: Vector4;
  34199. backUVs?: Vector4;
  34200. }, scene?: Nullable<Scene>): Mesh;
  34201. }
  34202. }
  34203. declare module BABYLON {
  34204. /**
  34205. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34206. *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.
  34207. * The SPS is also a particle system. It provides some methods to manage the particles.
  34208. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34209. *
  34210. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34211. */
  34212. export class SolidParticleSystem implements IDisposable {
  34213. /**
  34214. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34215. * Example : var p = SPS.particles[i];
  34216. */
  34217. particles: SolidParticle[];
  34218. /**
  34219. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34220. */
  34221. nbParticles: number;
  34222. /**
  34223. * If the particles must ever face the camera (default false). Useful for planar particles.
  34224. */
  34225. billboard: boolean;
  34226. /**
  34227. * Recompute normals when adding a shape
  34228. */
  34229. recomputeNormals: boolean;
  34230. /**
  34231. * This a counter ofr your own usage. It's not set by any SPS functions.
  34232. */
  34233. counter: number;
  34234. /**
  34235. * The SPS name. This name is also given to the underlying mesh.
  34236. */
  34237. name: string;
  34238. /**
  34239. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34240. */
  34241. mesh: Mesh;
  34242. /**
  34243. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34244. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34245. */
  34246. vars: any;
  34247. /**
  34248. * This array is populated when the SPS is set as 'pickable'.
  34249. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34250. * Each element of this array is an object `{idx: int, faceId: int}`.
  34251. * `idx` is the picked particle index in the `SPS.particles` array
  34252. * `faceId` is the picked face index counted within this particle.
  34253. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34254. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34255. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34256. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34257. */
  34258. pickedParticles: {
  34259. idx: number;
  34260. faceId: number;
  34261. }[];
  34262. /**
  34263. * This array is populated when the SPS is set as 'pickable'
  34264. * Each key of this array is a submesh index.
  34265. * Each element of this array is a second array defined like this :
  34266. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34267. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34268. * `idx` is the picked particle index in the `SPS.particles` array
  34269. * `faceId` is the picked face index counted within this particle.
  34270. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34271. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34272. */
  34273. pickedBySubMesh: {
  34274. idx: number;
  34275. faceId: number;
  34276. }[][];
  34277. /**
  34278. * This array is populated when `enableDepthSort` is set to true.
  34279. * Each element of this array is an instance of the class DepthSortedParticle.
  34280. */
  34281. depthSortedParticles: DepthSortedParticle[];
  34282. /**
  34283. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34284. * @hidden
  34285. */
  34286. _bSphereOnly: boolean;
  34287. /**
  34288. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34289. * @hidden
  34290. */
  34291. _bSphereRadiusFactor: number;
  34292. private _scene;
  34293. private _positions;
  34294. private _indices;
  34295. private _normals;
  34296. private _colors;
  34297. private _uvs;
  34298. private _indices32;
  34299. private _positions32;
  34300. private _normals32;
  34301. private _fixedNormal32;
  34302. private _colors32;
  34303. private _uvs32;
  34304. private _index;
  34305. private _updatable;
  34306. private _pickable;
  34307. private _isVisibilityBoxLocked;
  34308. private _alwaysVisible;
  34309. private _depthSort;
  34310. private _expandable;
  34311. private _shapeCounter;
  34312. private _copy;
  34313. private _color;
  34314. private _computeParticleColor;
  34315. private _computeParticleTexture;
  34316. private _computeParticleRotation;
  34317. private _computeParticleVertex;
  34318. private _computeBoundingBox;
  34319. private _depthSortParticles;
  34320. private _camera;
  34321. private _mustUnrotateFixedNormals;
  34322. private _particlesIntersect;
  34323. private _needs32Bits;
  34324. private _isNotBuilt;
  34325. private _lastParticleId;
  34326. private _idxOfId;
  34327. private _multimaterialEnabled;
  34328. private _useModelMaterial;
  34329. private _indicesByMaterial;
  34330. private _materialIndexes;
  34331. private _depthSortFunction;
  34332. private _materialSortFunction;
  34333. private _materials;
  34334. private _multimaterial;
  34335. private _materialIndexesById;
  34336. private _defaultMaterial;
  34337. private _autoUpdateSubMeshes;
  34338. private _tmpVertex;
  34339. /**
  34340. * Creates a SPS (Solid Particle System) object.
  34341. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34342. * @param scene (Scene) is the scene in which the SPS is added.
  34343. * @param options defines the options of the sps e.g.
  34344. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34345. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34346. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34347. * * 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.
  34348. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34349. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34350. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34351. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34352. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34353. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34354. */
  34355. constructor(name: string, scene: Scene, options?: {
  34356. updatable?: boolean;
  34357. isPickable?: boolean;
  34358. enableDepthSort?: boolean;
  34359. particleIntersection?: boolean;
  34360. boundingSphereOnly?: boolean;
  34361. bSphereRadiusFactor?: number;
  34362. expandable?: boolean;
  34363. useModelMaterial?: boolean;
  34364. enableMultiMaterial?: boolean;
  34365. });
  34366. /**
  34367. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34368. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34369. * @returns the created mesh
  34370. */
  34371. buildMesh(): Mesh;
  34372. /**
  34373. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34374. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34375. * Thus the particles generated from `digest()` have their property `position` set yet.
  34376. * @param mesh ( Mesh ) is the mesh to be digested
  34377. * @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
  34378. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34379. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34380. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34381. * @returns the current SPS
  34382. */
  34383. digest(mesh: Mesh, options?: {
  34384. facetNb?: number;
  34385. number?: number;
  34386. delta?: number;
  34387. storage?: [];
  34388. }): SolidParticleSystem;
  34389. /**
  34390. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34391. * @hidden
  34392. */
  34393. private _unrotateFixedNormals;
  34394. /**
  34395. * Resets the temporary working copy particle
  34396. * @hidden
  34397. */
  34398. private _resetCopy;
  34399. /**
  34400. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34401. * @param p the current index in the positions array to be updated
  34402. * @param ind the current index in the indices array
  34403. * @param shape a Vector3 array, the shape geometry
  34404. * @param positions the positions array to be updated
  34405. * @param meshInd the shape indices array
  34406. * @param indices the indices array to be updated
  34407. * @param meshUV the shape uv array
  34408. * @param uvs the uv array to be updated
  34409. * @param meshCol the shape color array
  34410. * @param colors the color array to be updated
  34411. * @param meshNor the shape normals array
  34412. * @param normals the normals array to be updated
  34413. * @param idx the particle index
  34414. * @param idxInShape the particle index in its shape
  34415. * @param options the addShape() method passed options
  34416. * @model the particle model
  34417. * @hidden
  34418. */
  34419. private _meshBuilder;
  34420. /**
  34421. * Returns a shape Vector3 array from positions float array
  34422. * @param positions float array
  34423. * @returns a vector3 array
  34424. * @hidden
  34425. */
  34426. private _posToShape;
  34427. /**
  34428. * Returns a shapeUV array from a float uvs (array deep copy)
  34429. * @param uvs as a float array
  34430. * @returns a shapeUV array
  34431. * @hidden
  34432. */
  34433. private _uvsToShapeUV;
  34434. /**
  34435. * Adds a new particle object in the particles array
  34436. * @param idx particle index in particles array
  34437. * @param id particle id
  34438. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34439. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34440. * @param model particle ModelShape object
  34441. * @param shapeId model shape identifier
  34442. * @param idxInShape index of the particle in the current model
  34443. * @param bInfo model bounding info object
  34444. * @param storage target storage array, if any
  34445. * @hidden
  34446. */
  34447. private _addParticle;
  34448. /**
  34449. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34450. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34451. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34452. * @param nb (positive integer) the number of particles to be created from this model
  34453. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34454. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34455. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34456. * @returns the number of shapes in the system
  34457. */
  34458. addShape(mesh: Mesh, nb: number, options?: {
  34459. positionFunction?: any;
  34460. vertexFunction?: any;
  34461. storage?: [];
  34462. }): number;
  34463. /**
  34464. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34465. * @hidden
  34466. */
  34467. private _rebuildParticle;
  34468. /**
  34469. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34470. * @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.
  34471. * @returns the SPS.
  34472. */
  34473. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34474. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34475. * Returns an array with the removed particles.
  34476. * 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.
  34477. * The SPS can't be empty so at least one particle needs to remain in place.
  34478. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34479. * @param start index of the first particle to remove
  34480. * @param end index of the last particle to remove (included)
  34481. * @returns an array populated with the removed particles
  34482. */
  34483. removeParticles(start: number, end: number): SolidParticle[];
  34484. /**
  34485. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34486. * @param solidParticleArray an array populated with Solid Particles objects
  34487. * @returns the SPS
  34488. */
  34489. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34490. /**
  34491. * Creates a new particle and modifies the SPS mesh geometry :
  34492. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34493. * - calls _addParticle() to populate the particle array
  34494. * factorized code from addShape() and insertParticlesFromArray()
  34495. * @param idx particle index in the particles array
  34496. * @param i particle index in its shape
  34497. * @param modelShape particle ModelShape object
  34498. * @param shape shape vertex array
  34499. * @param meshInd shape indices array
  34500. * @param meshUV shape uv array
  34501. * @param meshCol shape color array
  34502. * @param meshNor shape normals array
  34503. * @param bbInfo shape bounding info
  34504. * @param storage target particle storage
  34505. * @options addShape() passed options
  34506. * @hidden
  34507. */
  34508. private _insertNewParticle;
  34509. /**
  34510. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34511. * This method calls `updateParticle()` for each particle of the SPS.
  34512. * For an animated SPS, it is usually called within the render loop.
  34513. * 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.
  34514. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34515. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34516. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34517. * @returns the SPS.
  34518. */
  34519. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34520. /**
  34521. * Disposes the SPS.
  34522. */
  34523. dispose(): void;
  34524. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34525. * idx is the particle index in the SPS
  34526. * faceId is the picked face index counted within this particle.
  34527. * Returns null if the pickInfo can't identify a picked particle.
  34528. * @param pickingInfo (PickingInfo object)
  34529. * @returns {idx: number, faceId: number} or null
  34530. */
  34531. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34532. idx: number;
  34533. faceId: number;
  34534. }>;
  34535. /**
  34536. * Returns a SolidParticle object from its identifier : particle.id
  34537. * @param id (integer) the particle Id
  34538. * @returns the searched particle or null if not found in the SPS.
  34539. */
  34540. getParticleById(id: number): Nullable<SolidParticle>;
  34541. /**
  34542. * Returns a new array populated with the particles having the passed shapeId.
  34543. * @param shapeId (integer) the shape identifier
  34544. * @returns a new solid particle array
  34545. */
  34546. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34547. /**
  34548. * Populates the passed array "ref" with the particles having the passed shapeId.
  34549. * @param shapeId the shape identifier
  34550. * @returns the SPS
  34551. * @param ref
  34552. */
  34553. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34554. /**
  34555. * Computes the required SubMeshes according the materials assigned to the particles.
  34556. * @returns the solid particle system.
  34557. * Does nothing if called before the SPS mesh is built.
  34558. */
  34559. computeSubMeshes(): SolidParticleSystem;
  34560. /**
  34561. * Sorts the solid particles by material when MultiMaterial is enabled.
  34562. * Updates the indices32 array.
  34563. * Updates the indicesByMaterial array.
  34564. * Updates the mesh indices array.
  34565. * @returns the SPS
  34566. * @hidden
  34567. */
  34568. private _sortParticlesByMaterial;
  34569. /**
  34570. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34571. * @hidden
  34572. */
  34573. private _setMaterialIndexesById;
  34574. /**
  34575. * Returns an array with unique values of Materials from the passed array
  34576. * @param array the material array to be checked and filtered
  34577. * @hidden
  34578. */
  34579. private _filterUniqueMaterialId;
  34580. /**
  34581. * Sets a new Standard Material as _defaultMaterial if not already set.
  34582. * @hidden
  34583. */
  34584. private _setDefaultMaterial;
  34585. /**
  34586. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34587. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34588. * @returns the SPS.
  34589. */
  34590. refreshVisibleSize(): SolidParticleSystem;
  34591. /**
  34592. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34593. * @param size the size (float) of the visibility box
  34594. * note : this doesn't lock the SPS mesh bounding box.
  34595. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34596. */
  34597. setVisibilityBox(size: number): void;
  34598. /**
  34599. * Gets whether the SPS as always visible or not
  34600. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34601. */
  34602. get isAlwaysVisible(): boolean;
  34603. /**
  34604. * Sets the SPS as always visible or not
  34605. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34606. */
  34607. set isAlwaysVisible(val: boolean);
  34608. /**
  34609. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34610. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34611. */
  34612. set isVisibilityBoxLocked(val: boolean);
  34613. /**
  34614. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34615. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34616. */
  34617. get isVisibilityBoxLocked(): boolean;
  34618. /**
  34619. * Tells to `setParticles()` to compute the particle rotations or not.
  34620. * Default value : true. The SPS is faster when it's set to false.
  34621. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34622. */
  34623. set computeParticleRotation(val: boolean);
  34624. /**
  34625. * Tells to `setParticles()` to compute the particle colors or not.
  34626. * Default value : true. The SPS is faster when it's set to false.
  34627. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34628. */
  34629. set computeParticleColor(val: boolean);
  34630. set computeParticleTexture(val: boolean);
  34631. /**
  34632. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34633. * Default value : false. The SPS is faster when it's set to false.
  34634. * Note : the particle custom vertex positions aren't stored values.
  34635. */
  34636. set computeParticleVertex(val: boolean);
  34637. /**
  34638. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34639. */
  34640. set computeBoundingBox(val: boolean);
  34641. /**
  34642. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34643. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34644. * Default : `true`
  34645. */
  34646. set depthSortParticles(val: boolean);
  34647. /**
  34648. * Gets if `setParticles()` computes the particle rotations or not.
  34649. * Default value : true. The SPS is faster when it's set to false.
  34650. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34651. */
  34652. get computeParticleRotation(): boolean;
  34653. /**
  34654. * Gets if `setParticles()` computes the particle colors or not.
  34655. * Default value : true. The SPS is faster when it's set to false.
  34656. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34657. */
  34658. get computeParticleColor(): boolean;
  34659. /**
  34660. * Gets if `setParticles()` computes the particle textures or not.
  34661. * Default value : true. The SPS is faster when it's set to false.
  34662. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34663. */
  34664. get computeParticleTexture(): boolean;
  34665. /**
  34666. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34667. * Default value : false. The SPS is faster when it's set to false.
  34668. * Note : the particle custom vertex positions aren't stored values.
  34669. */
  34670. get computeParticleVertex(): boolean;
  34671. /**
  34672. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34673. */
  34674. get computeBoundingBox(): boolean;
  34675. /**
  34676. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34677. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34678. * Default : `true`
  34679. */
  34680. get depthSortParticles(): boolean;
  34681. /**
  34682. * Gets if the SPS is created as expandable at construction time.
  34683. * Default : `false`
  34684. */
  34685. get expandable(): boolean;
  34686. /**
  34687. * Gets if the SPS supports the Multi Materials
  34688. */
  34689. get multimaterialEnabled(): boolean;
  34690. /**
  34691. * Gets if the SPS uses the model materials for its own multimaterial.
  34692. */
  34693. get useModelMaterial(): boolean;
  34694. /**
  34695. * The SPS used material array.
  34696. */
  34697. get materials(): Material[];
  34698. /**
  34699. * Sets the SPS MultiMaterial from the passed materials.
  34700. * Note : the passed array is internally copied and not used then by reference.
  34701. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34702. */
  34703. setMultiMaterial(materials: Material[]): void;
  34704. /**
  34705. * The SPS computed multimaterial object
  34706. */
  34707. get multimaterial(): MultiMaterial;
  34708. set multimaterial(mm: MultiMaterial);
  34709. /**
  34710. * If the subMeshes must be updated on the next call to setParticles()
  34711. */
  34712. get autoUpdateSubMeshes(): boolean;
  34713. set autoUpdateSubMeshes(val: boolean);
  34714. /**
  34715. * This function does nothing. It may be overwritten to set all the particle first values.
  34716. * The SPS doesn't call this function, you may have to call it by your own.
  34717. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34718. */
  34719. initParticles(): void;
  34720. /**
  34721. * This function does nothing. It may be overwritten to recycle a particle.
  34722. * The SPS doesn't call this function, you may have to call it by your own.
  34723. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34724. * @param particle The particle to recycle
  34725. * @returns the recycled particle
  34726. */
  34727. recycleParticle(particle: SolidParticle): SolidParticle;
  34728. /**
  34729. * Updates a particle : this function should be overwritten by the user.
  34730. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34731. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34732. * @example : just set a particle position or velocity and recycle conditions
  34733. * @param particle The particle to update
  34734. * @returns the updated particle
  34735. */
  34736. updateParticle(particle: SolidParticle): SolidParticle;
  34737. /**
  34738. * Updates a vertex of a particle : it can be overwritten by the user.
  34739. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34740. * @param particle the current particle
  34741. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34742. * @param pt the index of the current vertex in the particle shape
  34743. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34744. * @example : just set a vertex particle position or color
  34745. * @returns the sps
  34746. */
  34747. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34748. /**
  34749. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34750. * This does nothing and may be overwritten by the user.
  34751. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34752. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34753. * @param update the boolean update value actually passed to setParticles()
  34754. */
  34755. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34756. /**
  34757. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34758. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34765. }
  34766. }
  34767. declare module BABYLON {
  34768. /**
  34769. * Represents one particle of a solid particle system.
  34770. */
  34771. export class SolidParticle {
  34772. /**
  34773. * particle global index
  34774. */
  34775. idx: number;
  34776. /**
  34777. * particle identifier
  34778. */
  34779. id: number;
  34780. /**
  34781. * The color of the particle
  34782. */
  34783. color: Nullable<Color4>;
  34784. /**
  34785. * The world space position of the particle.
  34786. */
  34787. position: Vector3;
  34788. /**
  34789. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34790. */
  34791. rotation: Vector3;
  34792. /**
  34793. * The world space rotation quaternion of the particle.
  34794. */
  34795. rotationQuaternion: Nullable<Quaternion>;
  34796. /**
  34797. * The scaling of the particle.
  34798. */
  34799. scaling: Vector3;
  34800. /**
  34801. * The uvs of the particle.
  34802. */
  34803. uvs: Vector4;
  34804. /**
  34805. * The current speed of the particle.
  34806. */
  34807. velocity: Vector3;
  34808. /**
  34809. * The pivot point in the particle local space.
  34810. */
  34811. pivot: Vector3;
  34812. /**
  34813. * Must the particle be translated from its pivot point in its local space ?
  34814. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34815. * Default : false
  34816. */
  34817. translateFromPivot: boolean;
  34818. /**
  34819. * Is the particle active or not ?
  34820. */
  34821. alive: boolean;
  34822. /**
  34823. * Is the particle visible or not ?
  34824. */
  34825. isVisible: boolean;
  34826. /**
  34827. * Index of this particle in the global "positions" array (Internal use)
  34828. * @hidden
  34829. */
  34830. _pos: number;
  34831. /**
  34832. * @hidden Index of this particle in the global "indices" array (Internal use)
  34833. */
  34834. _ind: number;
  34835. /**
  34836. * @hidden ModelShape of this particle (Internal use)
  34837. */
  34838. _model: ModelShape;
  34839. /**
  34840. * ModelShape id of this particle
  34841. */
  34842. shapeId: number;
  34843. /**
  34844. * Index of the particle in its shape id
  34845. */
  34846. idxInShape: number;
  34847. /**
  34848. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34849. */
  34850. _modelBoundingInfo: BoundingInfo;
  34851. /**
  34852. * @hidden Particle BoundingInfo object (Internal use)
  34853. */
  34854. _boundingInfo: BoundingInfo;
  34855. /**
  34856. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34857. */
  34858. _sps: SolidParticleSystem;
  34859. /**
  34860. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34861. */
  34862. _stillInvisible: boolean;
  34863. /**
  34864. * @hidden Last computed particle rotation matrix
  34865. */
  34866. _rotationMatrix: number[];
  34867. /**
  34868. * Parent particle Id, if any.
  34869. * Default null.
  34870. */
  34871. parentId: Nullable<number>;
  34872. /**
  34873. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34874. */
  34875. materialIndex: Nullable<number>;
  34876. /**
  34877. * Custom object or properties.
  34878. */
  34879. props: Nullable<any>;
  34880. /**
  34881. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34882. * The possible values are :
  34883. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34884. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34885. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34886. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34887. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34888. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34889. * */
  34890. cullingStrategy: number;
  34891. /**
  34892. * @hidden Internal global position in the SPS.
  34893. */
  34894. _globalPosition: Vector3;
  34895. /**
  34896. * Creates a Solid Particle object.
  34897. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34898. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34899. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34900. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34901. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34902. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34903. * @param shapeId (integer) is the model shape identifier in the SPS.
  34904. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34905. * @param sps defines the sps it is associated to
  34906. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34907. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34908. */
  34909. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34910. /**
  34911. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34912. * @param target the particle target
  34913. * @returns the current particle
  34914. */
  34915. copyToRef(target: SolidParticle): SolidParticle;
  34916. /**
  34917. * Legacy support, changed scale to scaling
  34918. */
  34919. get scale(): Vector3;
  34920. /**
  34921. * Legacy support, changed scale to scaling
  34922. */
  34923. set scale(scale: Vector3);
  34924. /**
  34925. * Legacy support, changed quaternion to rotationQuaternion
  34926. */
  34927. get quaternion(): Nullable<Quaternion>;
  34928. /**
  34929. * Legacy support, changed quaternion to rotationQuaternion
  34930. */
  34931. set quaternion(q: Nullable<Quaternion>);
  34932. /**
  34933. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34934. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34935. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34936. * @returns true if it intersects
  34937. */
  34938. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34939. /**
  34940. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34941. * A particle is in the frustum if its bounding box intersects the frustum
  34942. * @param frustumPlanes defines the frustum to test
  34943. * @returns true if the particle is in the frustum planes
  34944. */
  34945. isInFrustum(frustumPlanes: Plane[]): boolean;
  34946. /**
  34947. * get the rotation matrix of the particle
  34948. * @hidden
  34949. */
  34950. getRotationMatrix(m: Matrix): void;
  34951. }
  34952. /**
  34953. * Represents the shape of the model used by one particle of a solid particle system.
  34954. * SPS internal tool, don't use it manually.
  34955. */
  34956. export class ModelShape {
  34957. /**
  34958. * The shape id
  34959. * @hidden
  34960. */
  34961. shapeID: number;
  34962. /**
  34963. * flat array of model positions (internal use)
  34964. * @hidden
  34965. */
  34966. _shape: Vector3[];
  34967. /**
  34968. * flat array of model UVs (internal use)
  34969. * @hidden
  34970. */
  34971. _shapeUV: number[];
  34972. /**
  34973. * color array of the model
  34974. * @hidden
  34975. */
  34976. _shapeColors: number[];
  34977. /**
  34978. * indices array of the model
  34979. * @hidden
  34980. */
  34981. _indices: number[];
  34982. /**
  34983. * normals array of the model
  34984. * @hidden
  34985. */
  34986. _normals: number[];
  34987. /**
  34988. * length of the shape in the model indices array (internal use)
  34989. * @hidden
  34990. */
  34991. _indicesLength: number;
  34992. /**
  34993. * Custom position function (internal use)
  34994. * @hidden
  34995. */
  34996. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34997. /**
  34998. * Custom vertex function (internal use)
  34999. * @hidden
  35000. */
  35001. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35002. /**
  35003. * Model material (internal use)
  35004. * @hidden
  35005. */
  35006. _material: Nullable<Material>;
  35007. /**
  35008. * 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.
  35009. * SPS internal tool, don't use it manually.
  35010. * @hidden
  35011. */
  35012. 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>);
  35013. }
  35014. /**
  35015. * Represents a Depth Sorted Particle in the solid particle system.
  35016. * @hidden
  35017. */
  35018. export class DepthSortedParticle {
  35019. /**
  35020. * Particle index
  35021. */
  35022. idx: number;
  35023. /**
  35024. * Index of the particle in the "indices" array
  35025. */
  35026. ind: number;
  35027. /**
  35028. * Length of the particle shape in the "indices" array
  35029. */
  35030. indicesLength: number;
  35031. /**
  35032. * Squared distance from the particle to the camera
  35033. */
  35034. sqDistance: number;
  35035. /**
  35036. * Material index when used with MultiMaterials
  35037. */
  35038. materialIndex: number;
  35039. /**
  35040. * Creates a new sorted particle
  35041. * @param materialIndex
  35042. */
  35043. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35044. }
  35045. /**
  35046. * Represents a solid particle vertex
  35047. */
  35048. export class SolidParticleVertex {
  35049. /**
  35050. * Vertex position
  35051. */
  35052. position: Vector3;
  35053. /**
  35054. * Vertex color
  35055. */
  35056. color: Color4;
  35057. /**
  35058. * Vertex UV
  35059. */
  35060. uv: Vector2;
  35061. /**
  35062. * Creates a new solid particle vertex
  35063. */
  35064. constructor();
  35065. /** Vertex x coordinate */
  35066. get x(): number;
  35067. set x(val: number);
  35068. /** Vertex y coordinate */
  35069. get y(): number;
  35070. set y(val: number);
  35071. /** Vertex z coordinate */
  35072. get z(): number;
  35073. set z(val: number);
  35074. }
  35075. }
  35076. declare module BABYLON {
  35077. /**
  35078. * @hidden
  35079. */
  35080. export class _MeshCollisionData {
  35081. _checkCollisions: boolean;
  35082. _collisionMask: number;
  35083. _collisionGroup: number;
  35084. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35085. _collider: Nullable<Collider>;
  35086. _oldPositionForCollisions: Vector3;
  35087. _diffPositionForCollisions: Vector3;
  35088. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35089. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35090. _collisionResponse: boolean;
  35091. }
  35092. }
  35093. declare module BABYLON {
  35094. /** @hidden */
  35095. class _FacetDataStorage {
  35096. facetPositions: Vector3[];
  35097. facetNormals: Vector3[];
  35098. facetPartitioning: number[][];
  35099. facetNb: number;
  35100. partitioningSubdivisions: number;
  35101. partitioningBBoxRatio: number;
  35102. facetDataEnabled: boolean;
  35103. facetParameters: any;
  35104. bbSize: Vector3;
  35105. subDiv: {
  35106. max: number;
  35107. X: number;
  35108. Y: number;
  35109. Z: number;
  35110. };
  35111. facetDepthSort: boolean;
  35112. facetDepthSortEnabled: boolean;
  35113. depthSortedIndices: IndicesArray;
  35114. depthSortedFacets: {
  35115. ind: number;
  35116. sqDistance: number;
  35117. }[];
  35118. facetDepthSortFunction: (f1: {
  35119. ind: number;
  35120. sqDistance: number;
  35121. }, f2: {
  35122. ind: number;
  35123. sqDistance: number;
  35124. }) => number;
  35125. facetDepthSortFrom: Vector3;
  35126. facetDepthSortOrigin: Vector3;
  35127. invertedMatrix: Matrix;
  35128. }
  35129. /**
  35130. * @hidden
  35131. **/
  35132. class _InternalAbstractMeshDataInfo {
  35133. _hasVertexAlpha: boolean;
  35134. _useVertexColors: boolean;
  35135. _numBoneInfluencers: number;
  35136. _applyFog: boolean;
  35137. _receiveShadows: boolean;
  35138. _facetData: _FacetDataStorage;
  35139. _visibility: number;
  35140. _skeleton: Nullable<Skeleton>;
  35141. _layerMask: number;
  35142. _computeBonesUsingShaders: boolean;
  35143. _isActive: boolean;
  35144. _onlyForInstances: boolean;
  35145. _isActiveIntermediate: boolean;
  35146. _onlyForInstancesIntermediate: boolean;
  35147. _actAsRegularMesh: boolean;
  35148. }
  35149. /**
  35150. * Class used to store all common mesh properties
  35151. */
  35152. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35153. /** No occlusion */
  35154. static OCCLUSION_TYPE_NONE: number;
  35155. /** Occlusion set to optimisitic */
  35156. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35157. /** Occlusion set to strict */
  35158. static OCCLUSION_TYPE_STRICT: number;
  35159. /** Use an accurante occlusion algorithm */
  35160. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35161. /** Use a conservative occlusion algorithm */
  35162. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35163. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35164. * Test order :
  35165. * Is the bounding sphere outside the frustum ?
  35166. * If not, are the bounding box vertices outside the frustum ?
  35167. * It not, then the cullable object is in the frustum.
  35168. */
  35169. static readonly CULLINGSTRATEGY_STANDARD: number;
  35170. /** Culling strategy : Bounding Sphere Only.
  35171. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35172. * It's also less accurate than the standard because some not visible objects can still be selected.
  35173. * Test : is the bounding sphere outside the frustum ?
  35174. * If not, then the cullable object is in the frustum.
  35175. */
  35176. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35177. /** Culling strategy : Optimistic Inclusion.
  35178. * This in an inclusion test first, then the standard exclusion test.
  35179. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35180. * 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.
  35181. * Anyway, it's as accurate as the standard strategy.
  35182. * Test :
  35183. * Is the cullable object bounding sphere center in the frustum ?
  35184. * If not, apply the default culling strategy.
  35185. */
  35186. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35187. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35188. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35189. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35190. * 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.
  35191. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35192. * Test :
  35193. * Is the cullable object bounding sphere center in the frustum ?
  35194. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35195. */
  35196. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35197. /**
  35198. * No billboard
  35199. */
  35200. static get BILLBOARDMODE_NONE(): number;
  35201. /** Billboard on X axis */
  35202. static get BILLBOARDMODE_X(): number;
  35203. /** Billboard on Y axis */
  35204. static get BILLBOARDMODE_Y(): number;
  35205. /** Billboard on Z axis */
  35206. static get BILLBOARDMODE_Z(): number;
  35207. /** Billboard on all axes */
  35208. static get BILLBOARDMODE_ALL(): number;
  35209. /** Billboard on using position instead of orientation */
  35210. static get BILLBOARDMODE_USE_POSITION(): number;
  35211. /** @hidden */
  35212. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35213. /**
  35214. * The culling strategy to use to check whether the mesh must be rendered or not.
  35215. * This value can be changed at any time and will be used on the next render mesh selection.
  35216. * The possible values are :
  35217. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35218. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35219. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35220. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35221. * Please read each static variable documentation to get details about the culling process.
  35222. * */
  35223. cullingStrategy: number;
  35224. /**
  35225. * Gets the number of facets in the mesh
  35226. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35227. */
  35228. get facetNb(): number;
  35229. /**
  35230. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35231. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35232. */
  35233. get partitioningSubdivisions(): number;
  35234. set partitioningSubdivisions(nb: number);
  35235. /**
  35236. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35237. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35238. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35239. */
  35240. get partitioningBBoxRatio(): number;
  35241. set partitioningBBoxRatio(ratio: number);
  35242. /**
  35243. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35244. * Works only for updatable meshes.
  35245. * Doesn't work with multi-materials
  35246. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35247. */
  35248. get mustDepthSortFacets(): boolean;
  35249. set mustDepthSortFacets(sort: boolean);
  35250. /**
  35251. * The location (Vector3) where the facet depth sort must be computed from.
  35252. * By default, the active camera position.
  35253. * Used only when facet depth sort is enabled
  35254. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35255. */
  35256. get facetDepthSortFrom(): Vector3;
  35257. set facetDepthSortFrom(location: Vector3);
  35258. /**
  35259. * gets a boolean indicating if facetData is enabled
  35260. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35261. */
  35262. get isFacetDataEnabled(): boolean;
  35263. /** @hidden */
  35264. _updateNonUniformScalingState(value: boolean): boolean;
  35265. /**
  35266. * An event triggered when this mesh collides with another one
  35267. */
  35268. onCollideObservable: Observable<AbstractMesh>;
  35269. /** Set a function to call when this mesh collides with another one */
  35270. set onCollide(callback: () => void);
  35271. /**
  35272. * An event triggered when the collision's position changes
  35273. */
  35274. onCollisionPositionChangeObservable: Observable<Vector3>;
  35275. /** Set a function to call when the collision's position changes */
  35276. set onCollisionPositionChange(callback: () => void);
  35277. /**
  35278. * An event triggered when material is changed
  35279. */
  35280. onMaterialChangedObservable: Observable<AbstractMesh>;
  35281. /**
  35282. * Gets or sets the orientation for POV movement & rotation
  35283. */
  35284. definedFacingForward: boolean;
  35285. /** @hidden */
  35286. _occlusionQuery: Nullable<WebGLQuery>;
  35287. /** @hidden */
  35288. _renderingGroup: Nullable<RenderingGroup>;
  35289. /**
  35290. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35291. */
  35292. get visibility(): number;
  35293. /**
  35294. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35295. */
  35296. set visibility(value: number);
  35297. /** Gets or sets the alpha index used to sort transparent meshes
  35298. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35299. */
  35300. alphaIndex: number;
  35301. /**
  35302. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35303. */
  35304. isVisible: boolean;
  35305. /**
  35306. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35307. */
  35308. isPickable: boolean;
  35309. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35310. showSubMeshesBoundingBox: boolean;
  35311. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35312. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35313. */
  35314. isBlocker: boolean;
  35315. /**
  35316. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35317. */
  35318. enablePointerMoveEvents: boolean;
  35319. private _renderingGroupId;
  35320. /**
  35321. * Specifies the rendering group id for this mesh (0 by default)
  35322. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35323. */
  35324. get renderingGroupId(): number;
  35325. set renderingGroupId(value: number);
  35326. private _material;
  35327. /** Gets or sets current material */
  35328. get material(): Nullable<Material>;
  35329. set material(value: Nullable<Material>);
  35330. /**
  35331. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35332. * @see https://doc.babylonjs.com/babylon101/shadows
  35333. */
  35334. get receiveShadows(): boolean;
  35335. set receiveShadows(value: boolean);
  35336. /** Defines color to use when rendering outline */
  35337. outlineColor: Color3;
  35338. /** Define width to use when rendering outline */
  35339. outlineWidth: number;
  35340. /** Defines color to use when rendering overlay */
  35341. overlayColor: Color3;
  35342. /** Defines alpha to use when rendering overlay */
  35343. overlayAlpha: number;
  35344. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35345. get hasVertexAlpha(): boolean;
  35346. set hasVertexAlpha(value: boolean);
  35347. /** 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) */
  35348. get useVertexColors(): boolean;
  35349. set useVertexColors(value: boolean);
  35350. /**
  35351. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35352. */
  35353. get computeBonesUsingShaders(): boolean;
  35354. set computeBonesUsingShaders(value: boolean);
  35355. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35356. get numBoneInfluencers(): number;
  35357. set numBoneInfluencers(value: number);
  35358. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35359. get applyFog(): boolean;
  35360. set applyFog(value: boolean);
  35361. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35362. useOctreeForRenderingSelection: boolean;
  35363. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35364. useOctreeForPicking: boolean;
  35365. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35366. useOctreeForCollisions: boolean;
  35367. /**
  35368. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35369. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35370. */
  35371. get layerMask(): number;
  35372. set layerMask(value: number);
  35373. /**
  35374. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35375. */
  35376. alwaysSelectAsActiveMesh: boolean;
  35377. /**
  35378. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35379. */
  35380. doNotSyncBoundingInfo: boolean;
  35381. /**
  35382. * Gets or sets the current action manager
  35383. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35384. */
  35385. actionManager: Nullable<AbstractActionManager>;
  35386. private _meshCollisionData;
  35387. /**
  35388. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35389. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35390. */
  35391. ellipsoid: Vector3;
  35392. /**
  35393. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35394. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35395. */
  35396. ellipsoidOffset: Vector3;
  35397. /**
  35398. * Gets or sets a collision mask used to mask collisions (default is -1).
  35399. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35400. */
  35401. get collisionMask(): number;
  35402. set collisionMask(mask: number);
  35403. /**
  35404. * Gets or sets a collision response flag (default is true).
  35405. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35406. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35407. * to respond to the collision.
  35408. */
  35409. get collisionResponse(): boolean;
  35410. set collisionResponse(response: boolean);
  35411. /**
  35412. * Gets or sets the current collision group mask (-1 by default).
  35413. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35414. */
  35415. get collisionGroup(): number;
  35416. set collisionGroup(mask: number);
  35417. /**
  35418. * Gets or sets current surrounding meshes (null by default).
  35419. *
  35420. * By default collision detection is tested against every mesh in the scene.
  35421. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35422. * meshes will be tested for the collision.
  35423. *
  35424. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35425. */
  35426. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35427. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35428. /**
  35429. * Defines edge width used when edgesRenderer is enabled
  35430. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35431. */
  35432. edgesWidth: number;
  35433. /**
  35434. * Defines edge color used when edgesRenderer is enabled
  35435. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35436. */
  35437. edgesColor: Color4;
  35438. /** @hidden */
  35439. _edgesRenderer: Nullable<IEdgesRenderer>;
  35440. /** @hidden */
  35441. _masterMesh: Nullable<AbstractMesh>;
  35442. /** @hidden */
  35443. _boundingInfo: Nullable<BoundingInfo>;
  35444. /** @hidden */
  35445. _renderId: number;
  35446. /**
  35447. * Gets or sets the list of subMeshes
  35448. * @see https://doc.babylonjs.com/how_to/multi_materials
  35449. */
  35450. subMeshes: SubMesh[];
  35451. /** @hidden */
  35452. _intersectionsInProgress: AbstractMesh[];
  35453. /** @hidden */
  35454. _unIndexed: boolean;
  35455. /** @hidden */
  35456. _lightSources: Light[];
  35457. /** Gets the list of lights affecting that mesh */
  35458. get lightSources(): Light[];
  35459. /** @hidden */
  35460. get _positions(): Nullable<Vector3[]>;
  35461. /** @hidden */
  35462. _waitingData: {
  35463. lods: Nullable<any>;
  35464. actions: Nullable<any>;
  35465. freezeWorldMatrix: Nullable<boolean>;
  35466. };
  35467. /** @hidden */
  35468. _bonesTransformMatrices: Nullable<Float32Array>;
  35469. /** @hidden */
  35470. _transformMatrixTexture: Nullable<RawTexture>;
  35471. /**
  35472. * Gets or sets a skeleton to apply skining transformations
  35473. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35474. */
  35475. set skeleton(value: Nullable<Skeleton>);
  35476. get skeleton(): Nullable<Skeleton>;
  35477. /**
  35478. * An event triggered when the mesh is rebuilt.
  35479. */
  35480. onRebuildObservable: Observable<AbstractMesh>;
  35481. /**
  35482. * Creates a new AbstractMesh
  35483. * @param name defines the name of the mesh
  35484. * @param scene defines the hosting scene
  35485. */
  35486. constructor(name: string, scene?: Nullable<Scene>);
  35487. /**
  35488. * Returns the string "AbstractMesh"
  35489. * @returns "AbstractMesh"
  35490. */
  35491. getClassName(): string;
  35492. /**
  35493. * Gets a string representation of the current mesh
  35494. * @param fullDetails defines a boolean indicating if full details must be included
  35495. * @returns a string representation of the current mesh
  35496. */
  35497. toString(fullDetails?: boolean): string;
  35498. /**
  35499. * @hidden
  35500. */
  35501. protected _getEffectiveParent(): Nullable<Node>;
  35502. /** @hidden */
  35503. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35504. /** @hidden */
  35505. _rebuild(): void;
  35506. /** @hidden */
  35507. _resyncLightSources(): void;
  35508. /** @hidden */
  35509. _resyncLightSource(light: Light): void;
  35510. /** @hidden */
  35511. _unBindEffect(): void;
  35512. /** @hidden */
  35513. _removeLightSource(light: Light, dispose: boolean): void;
  35514. private _markSubMeshesAsDirty;
  35515. /** @hidden */
  35516. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35517. /** @hidden */
  35518. _markSubMeshesAsAttributesDirty(): void;
  35519. /** @hidden */
  35520. _markSubMeshesAsMiscDirty(): void;
  35521. /**
  35522. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35523. */
  35524. get scaling(): Vector3;
  35525. set scaling(newScaling: Vector3);
  35526. /**
  35527. * Returns true if the mesh is blocked. Implemented by child classes
  35528. */
  35529. get isBlocked(): boolean;
  35530. /**
  35531. * Returns the mesh itself by default. Implemented by child classes
  35532. * @param camera defines the camera to use to pick the right LOD level
  35533. * @returns the currentAbstractMesh
  35534. */
  35535. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35536. /**
  35537. * Returns 0 by default. Implemented by child classes
  35538. * @returns an integer
  35539. */
  35540. getTotalVertices(): number;
  35541. /**
  35542. * Returns a positive integer : the total number of indices in this mesh geometry.
  35543. * @returns the numner of indices or zero if the mesh has no geometry.
  35544. */
  35545. getTotalIndices(): number;
  35546. /**
  35547. * Returns null by default. Implemented by child classes
  35548. * @returns null
  35549. */
  35550. getIndices(): Nullable<IndicesArray>;
  35551. /**
  35552. * Returns the array of the requested vertex data kind. Implemented by child classes
  35553. * @param kind defines the vertex data kind to use
  35554. * @returns null
  35555. */
  35556. getVerticesData(kind: string): Nullable<FloatArray>;
  35557. /**
  35558. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35559. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35560. * Note that a new underlying VertexBuffer object is created each call.
  35561. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35562. * @param kind defines vertex data kind:
  35563. * * VertexBuffer.PositionKind
  35564. * * VertexBuffer.UVKind
  35565. * * VertexBuffer.UV2Kind
  35566. * * VertexBuffer.UV3Kind
  35567. * * VertexBuffer.UV4Kind
  35568. * * VertexBuffer.UV5Kind
  35569. * * VertexBuffer.UV6Kind
  35570. * * VertexBuffer.ColorKind
  35571. * * VertexBuffer.MatricesIndicesKind
  35572. * * VertexBuffer.MatricesIndicesExtraKind
  35573. * * VertexBuffer.MatricesWeightsKind
  35574. * * VertexBuffer.MatricesWeightsExtraKind
  35575. * @param data defines the data source
  35576. * @param updatable defines if the data must be flagged as updatable (or static)
  35577. * @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
  35578. * @returns the current mesh
  35579. */
  35580. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35581. /**
  35582. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35583. * If the mesh has no geometry, it is simply returned as it is.
  35584. * @param kind defines vertex data kind:
  35585. * * VertexBuffer.PositionKind
  35586. * * VertexBuffer.UVKind
  35587. * * VertexBuffer.UV2Kind
  35588. * * VertexBuffer.UV3Kind
  35589. * * VertexBuffer.UV4Kind
  35590. * * VertexBuffer.UV5Kind
  35591. * * VertexBuffer.UV6Kind
  35592. * * VertexBuffer.ColorKind
  35593. * * VertexBuffer.MatricesIndicesKind
  35594. * * VertexBuffer.MatricesIndicesExtraKind
  35595. * * VertexBuffer.MatricesWeightsKind
  35596. * * VertexBuffer.MatricesWeightsExtraKind
  35597. * @param data defines the data source
  35598. * @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
  35599. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35600. * @returns the current mesh
  35601. */
  35602. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35603. /**
  35604. * Sets the mesh indices,
  35605. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35606. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35607. * @param totalVertices Defines the total number of vertices
  35608. * @returns the current mesh
  35609. */
  35610. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35611. /**
  35612. * Gets a boolean indicating if specific vertex data is present
  35613. * @param kind defines the vertex data kind to use
  35614. * @returns true is data kind is present
  35615. */
  35616. isVerticesDataPresent(kind: string): boolean;
  35617. /**
  35618. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35619. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35620. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35621. * @returns a BoundingInfo
  35622. */
  35623. getBoundingInfo(): BoundingInfo;
  35624. /**
  35625. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35626. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35627. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35628. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35629. * @returns the current mesh
  35630. */
  35631. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35632. /**
  35633. * Overwrite the current bounding info
  35634. * @param boundingInfo defines the new bounding info
  35635. * @returns the current mesh
  35636. */
  35637. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35638. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35639. get useBones(): boolean;
  35640. /** @hidden */
  35641. _preActivate(): void;
  35642. /** @hidden */
  35643. _preActivateForIntermediateRendering(renderId: number): void;
  35644. /** @hidden */
  35645. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35646. /** @hidden */
  35647. _postActivate(): void;
  35648. /** @hidden */
  35649. _freeze(): void;
  35650. /** @hidden */
  35651. _unFreeze(): void;
  35652. /**
  35653. * Gets the current world matrix
  35654. * @returns a Matrix
  35655. */
  35656. getWorldMatrix(): Matrix;
  35657. /** @hidden */
  35658. _getWorldMatrixDeterminant(): number;
  35659. /**
  35660. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35661. */
  35662. get isAnInstance(): boolean;
  35663. /**
  35664. * Gets a boolean indicating if this mesh has instances
  35665. */
  35666. get hasInstances(): boolean;
  35667. /**
  35668. * Gets a boolean indicating if this mesh has thin instances
  35669. */
  35670. get hasThinInstances(): boolean;
  35671. /**
  35672. * Perform relative position change from the point of view of behind the front of the mesh.
  35673. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35674. * Supports definition of mesh facing forward or backward
  35675. * @param amountRight defines the distance on the right axis
  35676. * @param amountUp defines the distance on the up axis
  35677. * @param amountForward defines the distance on the forward axis
  35678. * @returns the current mesh
  35679. */
  35680. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35681. /**
  35682. * Calculate 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 new displacement vector
  35689. */
  35690. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35691. /**
  35692. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35693. * Supports definition of mesh facing forward or backward
  35694. * @param flipBack defines the flip
  35695. * @param twirlClockwise defines the twirl
  35696. * @param tiltRight defines the tilt
  35697. * @returns the current mesh
  35698. */
  35699. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35700. /**
  35701. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35702. * Supports definition of mesh facing forward or backward.
  35703. * @param flipBack defines the flip
  35704. * @param twirlClockwise defines the twirl
  35705. * @param tiltRight defines the tilt
  35706. * @returns the new rotation vector
  35707. */
  35708. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35709. /**
  35710. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35711. * This means the mesh underlying bounding box and sphere are recomputed.
  35712. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35713. * @returns the current mesh
  35714. */
  35715. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35716. /** @hidden */
  35717. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35718. /** @hidden */
  35719. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35720. /** @hidden */
  35721. _updateBoundingInfo(): AbstractMesh;
  35722. /** @hidden */
  35723. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35724. /** @hidden */
  35725. protected _afterComputeWorldMatrix(): void;
  35726. /** @hidden */
  35727. get _effectiveMesh(): AbstractMesh;
  35728. /**
  35729. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35730. * A mesh is in the frustum if its bounding box intersects the frustum
  35731. * @param frustumPlanes defines the frustum to test
  35732. * @returns true if the mesh is in the frustum planes
  35733. */
  35734. isInFrustum(frustumPlanes: Plane[]): boolean;
  35735. /**
  35736. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35737. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35738. * @param frustumPlanes defines the frustum to test
  35739. * @returns true if the mesh is completely in the frustum planes
  35740. */
  35741. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35742. /**
  35743. * True if the mesh intersects another mesh or a SolidParticle object
  35744. * @param mesh defines a target mesh or SolidParticle to test
  35745. * @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)
  35746. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35747. * @returns true if there is an intersection
  35748. */
  35749. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35750. /**
  35751. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35752. * @param point defines the point to test
  35753. * @returns true if there is an intersection
  35754. */
  35755. intersectsPoint(point: Vector3): boolean;
  35756. /**
  35757. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35758. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35759. */
  35760. get checkCollisions(): boolean;
  35761. set checkCollisions(collisionEnabled: boolean);
  35762. /**
  35763. * Gets Collider object used to compute collisions (not physics)
  35764. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35765. */
  35766. get collider(): Nullable<Collider>;
  35767. /**
  35768. * Move the mesh using collision engine
  35769. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35770. * @param displacement defines the requested displacement vector
  35771. * @returns the current mesh
  35772. */
  35773. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35774. private _onCollisionPositionChange;
  35775. /** @hidden */
  35776. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35777. /** @hidden */
  35778. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35779. /** @hidden */
  35780. _checkCollision(collider: Collider): AbstractMesh;
  35781. /** @hidden */
  35782. _generatePointsArray(): boolean;
  35783. /**
  35784. * Checks if the passed Ray intersects with the mesh
  35785. * @param ray defines the ray to use
  35786. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35787. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35788. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35789. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35790. * @returns the picking info
  35791. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35792. */
  35793. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  35794. /**
  35795. * Clones the current mesh
  35796. * @param name defines the mesh name
  35797. * @param newParent defines the new mesh parent
  35798. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35799. * @returns the new mesh
  35800. */
  35801. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35802. /**
  35803. * Disposes all the submeshes of the current meshnp
  35804. * @returns the current mesh
  35805. */
  35806. releaseSubMeshes(): AbstractMesh;
  35807. /**
  35808. * Releases resources associated with this abstract mesh.
  35809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35811. */
  35812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35813. /**
  35814. * Adds the passed mesh as a child to the current mesh
  35815. * @param mesh defines the child mesh
  35816. * @returns the current mesh
  35817. */
  35818. addChild(mesh: AbstractMesh): AbstractMesh;
  35819. /**
  35820. * Removes the passed mesh from the current mesh children list
  35821. * @param mesh defines the child mesh
  35822. * @returns the current mesh
  35823. */
  35824. removeChild(mesh: AbstractMesh): AbstractMesh;
  35825. /** @hidden */
  35826. private _initFacetData;
  35827. /**
  35828. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35829. * This method can be called within the render loop.
  35830. * 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
  35831. * @returns the current mesh
  35832. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35833. */
  35834. updateFacetData(): AbstractMesh;
  35835. /**
  35836. * Returns the facetLocalNormals array.
  35837. * The normals are expressed in the mesh local spac
  35838. * @returns an array of Vector3
  35839. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35840. */
  35841. getFacetLocalNormals(): Vector3[];
  35842. /**
  35843. * Returns the facetLocalPositions array.
  35844. * The facet positions are expressed in the mesh local space
  35845. * @returns an array of Vector3
  35846. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35847. */
  35848. getFacetLocalPositions(): Vector3[];
  35849. /**
  35850. * Returns the facetLocalPartioning array
  35851. * @returns an array of array of numbers
  35852. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35853. */
  35854. getFacetLocalPartitioning(): number[][];
  35855. /**
  35856. * Returns the i-th facet position in the world system.
  35857. * This method allocates a new Vector3 per call
  35858. * @param i defines the facet index
  35859. * @returns a new Vector3
  35860. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35861. */
  35862. getFacetPosition(i: number): Vector3;
  35863. /**
  35864. * Sets the reference Vector3 with the i-th facet position in the world system
  35865. * @param i defines the facet index
  35866. * @param ref defines the target vector
  35867. * @returns the current mesh
  35868. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35869. */
  35870. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35871. /**
  35872. * Returns the i-th facet normal in the world system.
  35873. * This method allocates a new Vector3 per call
  35874. * @param i defines the facet index
  35875. * @returns a new Vector3
  35876. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35877. */
  35878. getFacetNormal(i: number): Vector3;
  35879. /**
  35880. * Sets the reference Vector3 with the i-th facet normal in the world system
  35881. * @param i defines the facet index
  35882. * @param ref defines the target vector
  35883. * @returns the current mesh
  35884. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35885. */
  35886. getFacetNormalToRef(i: number, ref: Vector3): this;
  35887. /**
  35888. * 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)
  35889. * @param x defines x coordinate
  35890. * @param y defines y coordinate
  35891. * @param z defines z coordinate
  35892. * @returns the array of facet indexes
  35893. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35894. */
  35895. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35896. /**
  35897. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35898. * @param projected sets as the (x,y,z) world projection on the facet
  35899. * @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
  35900. * @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
  35901. * @param x defines x coordinate
  35902. * @param y defines y coordinate
  35903. * @param z defines z coordinate
  35904. * @returns the face index if found (or null instead)
  35905. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35906. */
  35907. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35908. /**
  35909. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35910. * @param projected sets as the (x,y,z) local projection on the facet
  35911. * @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
  35912. * @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
  35913. * @param x defines x coordinate
  35914. * @param y defines y coordinate
  35915. * @param z defines z coordinate
  35916. * @returns the face index if found (or null instead)
  35917. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35918. */
  35919. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35920. /**
  35921. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35922. * @returns the parameters
  35923. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35924. */
  35925. getFacetDataParameters(): any;
  35926. /**
  35927. * Disables the feature FacetData and frees the related memory
  35928. * @returns the current mesh
  35929. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35930. */
  35931. disableFacetData(): AbstractMesh;
  35932. /**
  35933. * Updates the AbstractMesh indices array
  35934. * @param indices defines the data source
  35935. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35936. * @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)
  35937. * @returns the current mesh
  35938. */
  35939. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35940. /**
  35941. * Creates new normals data for the mesh
  35942. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35943. * @returns the current mesh
  35944. */
  35945. createNormals(updatable: boolean): AbstractMesh;
  35946. /**
  35947. * Align the mesh with a normal
  35948. * @param normal defines the normal to use
  35949. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35950. * @returns the current mesh
  35951. */
  35952. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35953. /** @hidden */
  35954. _checkOcclusionQuery(): boolean;
  35955. /**
  35956. * Disables the mesh edge rendering mode
  35957. * @returns the currentAbstractMesh
  35958. */
  35959. disableEdgesRendering(): AbstractMesh;
  35960. /**
  35961. * Enables the edge rendering mode on the mesh.
  35962. * This mode makes the mesh edges visible
  35963. * @param epsilon defines the maximal distance between two angles to detect a face
  35964. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35965. * @returns the currentAbstractMesh
  35966. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35967. */
  35968. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35969. /**
  35970. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35971. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35972. */
  35973. getConnectedParticleSystems(): IParticleSystem[];
  35974. }
  35975. }
  35976. declare module BABYLON {
  35977. /**
  35978. * Interface used to define ActionEvent
  35979. */
  35980. export interface IActionEvent {
  35981. /** The mesh or sprite that triggered the action */
  35982. source: any;
  35983. /** The X mouse cursor position at the time of the event */
  35984. pointerX: number;
  35985. /** The Y mouse cursor position at the time of the event */
  35986. pointerY: number;
  35987. /** The mesh that is currently pointed at (can be null) */
  35988. meshUnderPointer: Nullable<AbstractMesh>;
  35989. /** the original (browser) event that triggered the ActionEvent */
  35990. sourceEvent?: any;
  35991. /** additional data for the event */
  35992. additionalData?: any;
  35993. }
  35994. /**
  35995. * ActionEvent is the event being sent when an action is triggered.
  35996. */
  35997. export class ActionEvent implements IActionEvent {
  35998. /** The mesh or sprite that triggered the action */
  35999. source: any;
  36000. /** The X mouse cursor position at the time of the event */
  36001. pointerX: number;
  36002. /** The Y mouse cursor position at the time of the event */
  36003. pointerY: number;
  36004. /** The mesh that is currently pointed at (can be null) */
  36005. meshUnderPointer: Nullable<AbstractMesh>;
  36006. /** the original (browser) event that triggered the ActionEvent */
  36007. sourceEvent?: any;
  36008. /** additional data for the event */
  36009. additionalData?: any;
  36010. /**
  36011. * Creates a new ActionEvent
  36012. * @param source The mesh or sprite that triggered the action
  36013. * @param pointerX The X mouse cursor position at the time of the event
  36014. * @param pointerY The Y mouse cursor position at the time of the event
  36015. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36016. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36017. * @param additionalData additional data for the event
  36018. */
  36019. constructor(
  36020. /** The mesh or sprite that triggered the action */
  36021. source: any,
  36022. /** The X mouse cursor position at the time of the event */
  36023. pointerX: number,
  36024. /** The Y mouse cursor position at the time of the event */
  36025. pointerY: number,
  36026. /** The mesh that is currently pointed at (can be null) */
  36027. meshUnderPointer: Nullable<AbstractMesh>,
  36028. /** the original (browser) event that triggered the ActionEvent */
  36029. sourceEvent?: any,
  36030. /** additional data for the event */
  36031. additionalData?: any);
  36032. /**
  36033. * Helper function to auto-create an ActionEvent from a source mesh.
  36034. * @param source The source mesh that triggered the event
  36035. * @param evt The original (browser) event
  36036. * @param additionalData additional data for the event
  36037. * @returns the new ActionEvent
  36038. */
  36039. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36040. /**
  36041. * Helper function to auto-create an ActionEvent from a source sprite
  36042. * @param source The source sprite that triggered the event
  36043. * @param scene Scene associated with the sprite
  36044. * @param evt The original (browser) event
  36045. * @param additionalData additional data for the event
  36046. * @returns the new ActionEvent
  36047. */
  36048. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36049. /**
  36050. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36051. * @param scene the scene where the event occurred
  36052. * @param evt The original (browser) event
  36053. * @returns the new ActionEvent
  36054. */
  36055. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36056. /**
  36057. * Helper function to auto-create an ActionEvent from a primitive
  36058. * @param prim defines the target primitive
  36059. * @param pointerPos defines the pointer position
  36060. * @param evt The original (browser) event
  36061. * @param additionalData additional data for the event
  36062. * @returns the new ActionEvent
  36063. */
  36064. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36065. }
  36066. }
  36067. declare module BABYLON {
  36068. /**
  36069. * Abstract class used to decouple action Manager from scene and meshes.
  36070. * Do not instantiate.
  36071. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36072. */
  36073. export abstract class AbstractActionManager implements IDisposable {
  36074. /** Gets the list of active triggers */
  36075. static Triggers: {
  36076. [key: string]: number;
  36077. };
  36078. /** Gets the cursor to use when hovering items */
  36079. hoverCursor: string;
  36080. /** Gets the list of actions */
  36081. actions: IAction[];
  36082. /**
  36083. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36084. */
  36085. isRecursive: boolean;
  36086. /**
  36087. * Releases all associated resources
  36088. */
  36089. abstract dispose(): void;
  36090. /**
  36091. * Does this action manager has pointer triggers
  36092. */
  36093. abstract get hasPointerTriggers(): boolean;
  36094. /**
  36095. * Does this action manager has pick triggers
  36096. */
  36097. abstract get hasPickTriggers(): boolean;
  36098. /**
  36099. * Process a specific trigger
  36100. * @param trigger defines the trigger to process
  36101. * @param evt defines the event details to be processed
  36102. */
  36103. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36104. /**
  36105. * Does this action manager handles actions of any of the given triggers
  36106. * @param triggers defines the triggers to be tested
  36107. * @return a boolean indicating whether one (or more) of the triggers is handled
  36108. */
  36109. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36110. /**
  36111. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36112. * speed.
  36113. * @param triggerA defines the trigger to be tested
  36114. * @param triggerB defines the trigger to be tested
  36115. * @return a boolean indicating whether one (or more) of the triggers is handled
  36116. */
  36117. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36118. /**
  36119. * Does this action manager handles actions of a given trigger
  36120. * @param trigger defines the trigger to be tested
  36121. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36122. * @return whether the trigger is handled
  36123. */
  36124. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36125. /**
  36126. * Serialize this manager to a JSON object
  36127. * @param name defines the property name to store this manager
  36128. * @returns a JSON representation of this manager
  36129. */
  36130. abstract serialize(name: string): any;
  36131. /**
  36132. * Registers an action to this action manager
  36133. * @param action defines the action to be registered
  36134. * @return the action amended (prepared) after registration
  36135. */
  36136. abstract registerAction(action: IAction): Nullable<IAction>;
  36137. /**
  36138. * Unregisters an action to this action manager
  36139. * @param action defines the action to be unregistered
  36140. * @return a boolean indicating whether the action has been unregistered
  36141. */
  36142. abstract unregisterAction(action: IAction): Boolean;
  36143. /**
  36144. * Does exist one action manager with at least one trigger
  36145. **/
  36146. static get HasTriggers(): boolean;
  36147. /**
  36148. * Does exist one action manager with at least one pick trigger
  36149. **/
  36150. static get HasPickTriggers(): boolean;
  36151. /**
  36152. * Does exist one action manager that handles actions of a given trigger
  36153. * @param trigger defines the trigger to be tested
  36154. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36155. **/
  36156. static HasSpecificTrigger(trigger: number): boolean;
  36157. }
  36158. }
  36159. declare module BABYLON {
  36160. /**
  36161. * Defines how a node can be built from a string name.
  36162. */
  36163. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36164. /**
  36165. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36166. */
  36167. export class Node implements IBehaviorAware<Node> {
  36168. /** @hidden */
  36169. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36170. private static _NodeConstructors;
  36171. /**
  36172. * Add a new node constructor
  36173. * @param type defines the type name of the node to construct
  36174. * @param constructorFunc defines the constructor function
  36175. */
  36176. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36177. /**
  36178. * Returns a node constructor based on type name
  36179. * @param type defines the type name
  36180. * @param name defines the new node name
  36181. * @param scene defines the hosting scene
  36182. * @param options defines optional options to transmit to constructors
  36183. * @returns the new constructor or null
  36184. */
  36185. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36186. /**
  36187. * Gets or sets the name of the node
  36188. */
  36189. name: string;
  36190. /**
  36191. * Gets or sets the id of the node
  36192. */
  36193. id: string;
  36194. /**
  36195. * Gets or sets the unique id of the node
  36196. */
  36197. uniqueId: number;
  36198. /**
  36199. * Gets or sets a string used to store user defined state for the node
  36200. */
  36201. state: string;
  36202. /**
  36203. * Gets or sets an object used to store user defined information for the node
  36204. */
  36205. metadata: any;
  36206. /**
  36207. * For internal use only. Please do not use.
  36208. */
  36209. reservedDataStore: any;
  36210. /**
  36211. * List of inspectable custom properties (used by the Inspector)
  36212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36213. */
  36214. inspectableCustomProperties: IInspectable[];
  36215. private _doNotSerialize;
  36216. /**
  36217. * Gets or sets a boolean used to define if the node must be serialized
  36218. */
  36219. get doNotSerialize(): boolean;
  36220. set doNotSerialize(value: boolean);
  36221. /** @hidden */
  36222. _isDisposed: boolean;
  36223. /**
  36224. * Gets a list of Animations associated with the node
  36225. */
  36226. animations: Animation[];
  36227. protected _ranges: {
  36228. [name: string]: Nullable<AnimationRange>;
  36229. };
  36230. /**
  36231. * Callback raised when the node is ready to be used
  36232. */
  36233. onReady: Nullable<(node: Node) => void>;
  36234. private _isEnabled;
  36235. private _isParentEnabled;
  36236. private _isReady;
  36237. /** @hidden */
  36238. _currentRenderId: number;
  36239. private _parentUpdateId;
  36240. /** @hidden */
  36241. _childUpdateId: number;
  36242. /** @hidden */
  36243. _waitingParentId: Nullable<string>;
  36244. /** @hidden */
  36245. _scene: Scene;
  36246. /** @hidden */
  36247. _cache: any;
  36248. private _parentNode;
  36249. private _children;
  36250. /** @hidden */
  36251. _worldMatrix: Matrix;
  36252. /** @hidden */
  36253. _worldMatrixDeterminant: number;
  36254. /** @hidden */
  36255. _worldMatrixDeterminantIsDirty: boolean;
  36256. /** @hidden */
  36257. private _sceneRootNodesIndex;
  36258. /**
  36259. * Gets a boolean indicating if the node has been disposed
  36260. * @returns true if the node was disposed
  36261. */
  36262. isDisposed(): boolean;
  36263. /**
  36264. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36265. * @see https://doc.babylonjs.com/how_to/parenting
  36266. */
  36267. set parent(parent: Nullable<Node>);
  36268. get parent(): Nullable<Node>;
  36269. /** @hidden */
  36270. _addToSceneRootNodes(): void;
  36271. /** @hidden */
  36272. _removeFromSceneRootNodes(): void;
  36273. private _animationPropertiesOverride;
  36274. /**
  36275. * Gets or sets the animation properties override
  36276. */
  36277. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36278. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36279. /**
  36280. * Gets a string identifying the name of the class
  36281. * @returns "Node" string
  36282. */
  36283. getClassName(): string;
  36284. /** @hidden */
  36285. readonly _isNode: boolean;
  36286. /**
  36287. * An event triggered when the mesh is disposed
  36288. */
  36289. onDisposeObservable: Observable<Node>;
  36290. private _onDisposeObserver;
  36291. /**
  36292. * Sets a callback that will be raised when the node will be disposed
  36293. */
  36294. set onDispose(callback: () => void);
  36295. /**
  36296. * Creates a new Node
  36297. * @param name the name and id to be given to this node
  36298. * @param scene the scene this node will be added to
  36299. */
  36300. constructor(name: string, scene?: Nullable<Scene>);
  36301. /**
  36302. * Gets the scene of the node
  36303. * @returns a scene
  36304. */
  36305. getScene(): Scene;
  36306. /**
  36307. * Gets the engine of the node
  36308. * @returns a Engine
  36309. */
  36310. getEngine(): Engine;
  36311. private _behaviors;
  36312. /**
  36313. * Attach a behavior to the node
  36314. * @see https://doc.babylonjs.com/features/behaviour
  36315. * @param behavior defines the behavior to attach
  36316. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36317. * @returns the current Node
  36318. */
  36319. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36320. /**
  36321. * Remove an attached behavior
  36322. * @see https://doc.babylonjs.com/features/behaviour
  36323. * @param behavior defines the behavior to attach
  36324. * @returns the current Node
  36325. */
  36326. removeBehavior(behavior: Behavior<Node>): Node;
  36327. /**
  36328. * Gets the list of attached behaviors
  36329. * @see https://doc.babylonjs.com/features/behaviour
  36330. */
  36331. get behaviors(): Behavior<Node>[];
  36332. /**
  36333. * Gets an attached behavior by name
  36334. * @param name defines the name of the behavior to look for
  36335. * @see https://doc.babylonjs.com/features/behaviour
  36336. * @returns null if behavior was not found else the requested behavior
  36337. */
  36338. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36339. /**
  36340. * Returns the latest update of the World matrix
  36341. * @returns a Matrix
  36342. */
  36343. getWorldMatrix(): Matrix;
  36344. /** @hidden */
  36345. _getWorldMatrixDeterminant(): number;
  36346. /**
  36347. * Returns directly the latest state of the mesh World matrix.
  36348. * A Matrix is returned.
  36349. */
  36350. get worldMatrixFromCache(): Matrix;
  36351. /** @hidden */
  36352. _initCache(): void;
  36353. /** @hidden */
  36354. updateCache(force?: boolean): void;
  36355. /** @hidden */
  36356. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36357. /** @hidden */
  36358. _updateCache(ignoreParentClass?: boolean): void;
  36359. /** @hidden */
  36360. _isSynchronized(): boolean;
  36361. /** @hidden */
  36362. _markSyncedWithParent(): void;
  36363. /** @hidden */
  36364. isSynchronizedWithParent(): boolean;
  36365. /** @hidden */
  36366. isSynchronized(): boolean;
  36367. /**
  36368. * Is this node ready to be used/rendered
  36369. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36370. * @return true if the node is ready
  36371. */
  36372. isReady(completeCheck?: boolean): boolean;
  36373. /**
  36374. * Is this node enabled?
  36375. * 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
  36376. * @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
  36377. * @return whether this node (and its parent) is enabled
  36378. */
  36379. isEnabled(checkAncestors?: boolean): boolean;
  36380. /** @hidden */
  36381. protected _syncParentEnabledState(): void;
  36382. /**
  36383. * Set the enabled state of this node
  36384. * @param value defines the new enabled state
  36385. */
  36386. setEnabled(value: boolean): void;
  36387. /**
  36388. * Is this node a descendant of the given node?
  36389. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36390. * @param ancestor defines the parent node to inspect
  36391. * @returns a boolean indicating if this node is a descendant of the given node
  36392. */
  36393. isDescendantOf(ancestor: Node): boolean;
  36394. /** @hidden */
  36395. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36396. /**
  36397. * Will return all nodes that have this node as ascendant
  36398. * @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
  36399. * @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
  36400. * @return all children nodes of all types
  36401. */
  36402. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36403. /**
  36404. * Get all child-meshes of this node
  36405. * @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)
  36406. * @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
  36407. * @returns an array of AbstractMesh
  36408. */
  36409. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36410. /**
  36411. * Get all direct children of this node
  36412. * @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
  36413. * @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)
  36414. * @returns an array of Node
  36415. */
  36416. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36417. /** @hidden */
  36418. _setReady(state: boolean): void;
  36419. /**
  36420. * Get an animation by name
  36421. * @param name defines the name of the animation to look for
  36422. * @returns null if not found else the requested animation
  36423. */
  36424. getAnimationByName(name: string): Nullable<Animation>;
  36425. /**
  36426. * Creates an animation range for this node
  36427. * @param name defines the name of the range
  36428. * @param from defines the starting key
  36429. * @param to defines the end key
  36430. */
  36431. createAnimationRange(name: string, from: number, to: number): void;
  36432. /**
  36433. * Delete a specific animation range
  36434. * @param name defines the name of the range to delete
  36435. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36436. */
  36437. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36438. /**
  36439. * Get an animation range by name
  36440. * @param name defines the name of the animation range to look for
  36441. * @returns null if not found else the requested animation range
  36442. */
  36443. getAnimationRange(name: string): Nullable<AnimationRange>;
  36444. /**
  36445. * Gets the list of all animation ranges defined on this node
  36446. * @returns an array
  36447. */
  36448. getAnimationRanges(): Nullable<AnimationRange>[];
  36449. /**
  36450. * Will start the animation sequence
  36451. * @param name defines the range frames for animation sequence
  36452. * @param loop defines if the animation should loop (false by default)
  36453. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36454. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36455. * @returns the object created for this animation. If range does not exist, it will return null
  36456. */
  36457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36458. /**
  36459. * Serialize animation ranges into a JSON compatible object
  36460. * @returns serialization object
  36461. */
  36462. serializeAnimationRanges(): any;
  36463. /**
  36464. * Computes the world matrix of the node
  36465. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36466. * @returns the world matrix
  36467. */
  36468. computeWorldMatrix(force?: boolean): Matrix;
  36469. /**
  36470. * Releases resources associated with this node.
  36471. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36472. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36473. */
  36474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36475. /**
  36476. * Parse animation range data from a serialization object and store them into a given node
  36477. * @param node defines where to store the animation ranges
  36478. * @param parsedNode defines the serialization object to read data from
  36479. * @param scene defines the hosting scene
  36480. */
  36481. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36482. /**
  36483. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36484. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36485. * @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
  36486. * @returns the new bounding vectors
  36487. */
  36488. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36489. min: Vector3;
  36490. max: Vector3;
  36491. };
  36492. }
  36493. }
  36494. declare module BABYLON {
  36495. /**
  36496. * @hidden
  36497. */
  36498. export class _IAnimationState {
  36499. key: number;
  36500. repeatCount: number;
  36501. workValue?: any;
  36502. loopMode?: number;
  36503. offsetValue?: any;
  36504. highLimitValue?: any;
  36505. }
  36506. /**
  36507. * Class used to store any kind of animation
  36508. */
  36509. export class Animation {
  36510. /**Name of the animation */
  36511. name: string;
  36512. /**Property to animate */
  36513. targetProperty: string;
  36514. /**The frames per second of the animation */
  36515. framePerSecond: number;
  36516. /**The data type of the animation */
  36517. dataType: number;
  36518. /**The loop mode of the animation */
  36519. loopMode?: number | undefined;
  36520. /**Specifies if blending should be enabled */
  36521. enableBlending?: boolean | undefined;
  36522. /**
  36523. * Use matrix interpolation instead of using direct key value when animating matrices
  36524. */
  36525. static AllowMatricesInterpolation: boolean;
  36526. /**
  36527. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36528. */
  36529. static AllowMatrixDecomposeForInterpolation: boolean;
  36530. /** Define the Url to load snippets */
  36531. static SnippetUrl: string;
  36532. /** Snippet ID if the animation was created from the snippet server */
  36533. snippetId: string;
  36534. /**
  36535. * Stores the key frames of the animation
  36536. */
  36537. private _keys;
  36538. /**
  36539. * Stores the easing function of the animation
  36540. */
  36541. private _easingFunction;
  36542. /**
  36543. * @hidden Internal use only
  36544. */
  36545. _runtimeAnimations: RuntimeAnimation[];
  36546. /**
  36547. * The set of event that will be linked to this animation
  36548. */
  36549. private _events;
  36550. /**
  36551. * Stores an array of target property paths
  36552. */
  36553. targetPropertyPath: string[];
  36554. /**
  36555. * Stores the blending speed of the animation
  36556. */
  36557. blendingSpeed: number;
  36558. /**
  36559. * Stores the animation ranges for the animation
  36560. */
  36561. private _ranges;
  36562. /**
  36563. * @hidden Internal use
  36564. */
  36565. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36566. /**
  36567. * Sets up an animation
  36568. * @param property The property to animate
  36569. * @param animationType The animation type to apply
  36570. * @param framePerSecond The frames per second of the animation
  36571. * @param easingFunction The easing function used in the animation
  36572. * @returns The created animation
  36573. */
  36574. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36575. /**
  36576. * Create and start an animation on a node
  36577. * @param name defines the name of the global animation that will be run on all nodes
  36578. * @param node defines the root node where the animation will take place
  36579. * @param targetProperty defines property to animate
  36580. * @param framePerSecond defines the number of frame per second yo use
  36581. * @param totalFrame defines the number of frames in total
  36582. * @param from defines the initial value
  36583. * @param to defines the final value
  36584. * @param loopMode defines which loop mode you want to use (off by default)
  36585. * @param easingFunction defines the easing function to use (linear by default)
  36586. * @param onAnimationEnd defines the callback to call when animation end
  36587. * @returns the animatable created for this animation
  36588. */
  36589. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36590. /**
  36591. * Create and start an animation on a node and its descendants
  36592. * @param name defines the name of the global animation that will be run on all nodes
  36593. * @param node defines the root node where the animation will take place
  36594. * @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
  36595. * @param targetProperty defines property to animate
  36596. * @param framePerSecond defines the number of frame per second to use
  36597. * @param totalFrame defines the number of frames in total
  36598. * @param from defines the initial value
  36599. * @param to defines the final value
  36600. * @param loopMode defines which loop mode you want to use (off by default)
  36601. * @param easingFunction defines the easing function to use (linear by default)
  36602. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36603. * @returns the list of animatables created for all nodes
  36604. * @example https://www.babylonjs-playground.com/#MH0VLI
  36605. */
  36606. 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[]>;
  36607. /**
  36608. * Creates a new animation, merges it with the existing animations and starts it
  36609. * @param name Name of the animation
  36610. * @param node Node which contains the scene that begins the animations
  36611. * @param targetProperty Specifies which property to animate
  36612. * @param framePerSecond The frames per second of the animation
  36613. * @param totalFrame The total number of frames
  36614. * @param from The frame at the beginning of the animation
  36615. * @param to The frame at the end of the animation
  36616. * @param loopMode Specifies the loop mode of the animation
  36617. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36618. * @param onAnimationEnd Callback to run once the animation is complete
  36619. * @returns Nullable animation
  36620. */
  36621. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36622. /**
  36623. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36624. * @param sourceAnimation defines the Animation containing keyframes to convert
  36625. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36626. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36627. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36628. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36629. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36630. */
  36631. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36632. /**
  36633. * Transition property of an host to the target Value
  36634. * @param property The property to transition
  36635. * @param targetValue The target Value of the property
  36636. * @param host The object where the property to animate belongs
  36637. * @param scene Scene used to run the animation
  36638. * @param frameRate Framerate (in frame/s) to use
  36639. * @param transition The transition type we want to use
  36640. * @param duration The duration of the animation, in milliseconds
  36641. * @param onAnimationEnd Callback trigger at the end of the animation
  36642. * @returns Nullable animation
  36643. */
  36644. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36645. /**
  36646. * Return the array of runtime animations currently using this animation
  36647. */
  36648. get runtimeAnimations(): RuntimeAnimation[];
  36649. /**
  36650. * Specifies if any of the runtime animations are currently running
  36651. */
  36652. get hasRunningRuntimeAnimations(): boolean;
  36653. /**
  36654. * Initializes the animation
  36655. * @param name Name of the animation
  36656. * @param targetProperty Property to animate
  36657. * @param framePerSecond The frames per second of the animation
  36658. * @param dataType The data type of the animation
  36659. * @param loopMode The loop mode of the animation
  36660. * @param enableBlending Specifies if blending should be enabled
  36661. */
  36662. constructor(
  36663. /**Name of the animation */
  36664. name: string,
  36665. /**Property to animate */
  36666. targetProperty: string,
  36667. /**The frames per second of the animation */
  36668. framePerSecond: number,
  36669. /**The data type of the animation */
  36670. dataType: number,
  36671. /**The loop mode of the animation */
  36672. loopMode?: number | undefined,
  36673. /**Specifies if blending should be enabled */
  36674. enableBlending?: boolean | undefined);
  36675. /**
  36676. * Converts the animation to a string
  36677. * @param fullDetails support for multiple levels of logging within scene loading
  36678. * @returns String form of the animation
  36679. */
  36680. toString(fullDetails?: boolean): string;
  36681. /**
  36682. * Add an event to this animation
  36683. * @param event Event to add
  36684. */
  36685. addEvent(event: AnimationEvent): void;
  36686. /**
  36687. * Remove all events found at the given frame
  36688. * @param frame The frame to remove events from
  36689. */
  36690. removeEvents(frame: number): void;
  36691. /**
  36692. * Retrieves all the events from the animation
  36693. * @returns Events from the animation
  36694. */
  36695. getEvents(): AnimationEvent[];
  36696. /**
  36697. * Creates an animation range
  36698. * @param name Name of the animation range
  36699. * @param from Starting frame of the animation range
  36700. * @param to Ending frame of the animation
  36701. */
  36702. createRange(name: string, from: number, to: number): void;
  36703. /**
  36704. * Deletes an animation range by name
  36705. * @param name Name of the animation range to delete
  36706. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36707. */
  36708. deleteRange(name: string, deleteFrames?: boolean): void;
  36709. /**
  36710. * Gets the animation range by name, or null if not defined
  36711. * @param name Name of the animation range
  36712. * @returns Nullable animation range
  36713. */
  36714. getRange(name: string): Nullable<AnimationRange>;
  36715. /**
  36716. * Gets the key frames from the animation
  36717. * @returns The key frames of the animation
  36718. */
  36719. getKeys(): Array<IAnimationKey>;
  36720. /**
  36721. * Gets the highest frame rate of the animation
  36722. * @returns Highest frame rate of the animation
  36723. */
  36724. getHighestFrame(): number;
  36725. /**
  36726. * Gets the easing function of the animation
  36727. * @returns Easing function of the animation
  36728. */
  36729. getEasingFunction(): IEasingFunction;
  36730. /**
  36731. * Sets the easing function of the animation
  36732. * @param easingFunction A custom mathematical formula for animation
  36733. */
  36734. setEasingFunction(easingFunction: EasingFunction): void;
  36735. /**
  36736. * Interpolates a scalar linearly
  36737. * @param startValue Start value of the animation curve
  36738. * @param endValue End value of the animation curve
  36739. * @param gradient Scalar amount to interpolate
  36740. * @returns Interpolated scalar value
  36741. */
  36742. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36743. /**
  36744. * Interpolates a scalar cubically
  36745. * @param startValue Start value of the animation curve
  36746. * @param outTangent End tangent of the animation
  36747. * @param endValue End value of the animation curve
  36748. * @param inTangent Start tangent of the animation curve
  36749. * @param gradient Scalar amount to interpolate
  36750. * @returns Interpolated scalar value
  36751. */
  36752. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36753. /**
  36754. * Interpolates a quaternion using a spherical linear interpolation
  36755. * @param startValue Start value of the animation curve
  36756. * @param endValue End value of the animation curve
  36757. * @param gradient Scalar amount to interpolate
  36758. * @returns Interpolated quaternion value
  36759. */
  36760. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36761. /**
  36762. * Interpolates a quaternion cubically
  36763. * @param startValue Start value of the animation curve
  36764. * @param outTangent End tangent of the animation curve
  36765. * @param endValue End value of the animation curve
  36766. * @param inTangent Start tangent of the animation curve
  36767. * @param gradient Scalar amount to interpolate
  36768. * @returns Interpolated quaternion value
  36769. */
  36770. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36771. /**
  36772. * Interpolates a Vector3 linearl
  36773. * @param startValue Start value of the animation curve
  36774. * @param endValue End value of the animation curve
  36775. * @param gradient Scalar amount to interpolate
  36776. * @returns Interpolated scalar value
  36777. */
  36778. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36779. /**
  36780. * Interpolates a Vector3 cubically
  36781. * @param startValue Start value of the animation curve
  36782. * @param outTangent End tangent of the animation
  36783. * @param endValue End value of the animation curve
  36784. * @param inTangent Start tangent of the animation curve
  36785. * @param gradient Scalar amount to interpolate
  36786. * @returns InterpolatedVector3 value
  36787. */
  36788. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36789. /**
  36790. * Interpolates a Vector2 linearly
  36791. * @param startValue Start value of the animation curve
  36792. * @param endValue End value of the animation curve
  36793. * @param gradient Scalar amount to interpolate
  36794. * @returns Interpolated Vector2 value
  36795. */
  36796. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36797. /**
  36798. * Interpolates a Vector2 cubically
  36799. * @param startValue Start value of the animation curve
  36800. * @param outTangent End tangent of the animation
  36801. * @param endValue End value of the animation curve
  36802. * @param inTangent Start tangent of the animation curve
  36803. * @param gradient Scalar amount to interpolate
  36804. * @returns Interpolated Vector2 value
  36805. */
  36806. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36807. /**
  36808. * Interpolates a size linearly
  36809. * @param startValue Start value of the animation curve
  36810. * @param endValue End value of the animation curve
  36811. * @param gradient Scalar amount to interpolate
  36812. * @returns Interpolated Size value
  36813. */
  36814. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36815. /**
  36816. * Interpolates a Color3 linearly
  36817. * @param startValue Start value of the animation curve
  36818. * @param endValue End value of the animation curve
  36819. * @param gradient Scalar amount to interpolate
  36820. * @returns Interpolated Color3 value
  36821. */
  36822. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36823. /**
  36824. * Interpolates a Color4 linearly
  36825. * @param startValue Start value of the animation curve
  36826. * @param endValue End value of the animation curve
  36827. * @param gradient Scalar amount to interpolate
  36828. * @returns Interpolated Color3 value
  36829. */
  36830. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36831. /**
  36832. * @hidden Internal use only
  36833. */
  36834. _getKeyValue(value: any): any;
  36835. /**
  36836. * @hidden Internal use only
  36837. */
  36838. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36839. /**
  36840. * Defines the function to use to interpolate matrices
  36841. * @param startValue defines the start matrix
  36842. * @param endValue defines the end matrix
  36843. * @param gradient defines the gradient between both matrices
  36844. * @param result defines an optional target matrix where to store the interpolation
  36845. * @returns the interpolated matrix
  36846. */
  36847. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36848. /**
  36849. * Makes a copy of the animation
  36850. * @returns Cloned animation
  36851. */
  36852. clone(): Animation;
  36853. /**
  36854. * Sets the key frames of the animation
  36855. * @param values The animation key frames to set
  36856. */
  36857. setKeys(values: Array<IAnimationKey>): void;
  36858. /**
  36859. * Serializes the animation to an object
  36860. * @returns Serialized object
  36861. */
  36862. serialize(): any;
  36863. /**
  36864. * Float animation type
  36865. */
  36866. static readonly ANIMATIONTYPE_FLOAT: number;
  36867. /**
  36868. * Vector3 animation type
  36869. */
  36870. static readonly ANIMATIONTYPE_VECTOR3: number;
  36871. /**
  36872. * Quaternion animation type
  36873. */
  36874. static readonly ANIMATIONTYPE_QUATERNION: number;
  36875. /**
  36876. * Matrix animation type
  36877. */
  36878. static readonly ANIMATIONTYPE_MATRIX: number;
  36879. /**
  36880. * Color3 animation type
  36881. */
  36882. static readonly ANIMATIONTYPE_COLOR3: number;
  36883. /**
  36884. * Color3 animation type
  36885. */
  36886. static readonly ANIMATIONTYPE_COLOR4: number;
  36887. /**
  36888. * Vector2 animation type
  36889. */
  36890. static readonly ANIMATIONTYPE_VECTOR2: number;
  36891. /**
  36892. * Size animation type
  36893. */
  36894. static readonly ANIMATIONTYPE_SIZE: number;
  36895. /**
  36896. * Relative Loop Mode
  36897. */
  36898. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36899. /**
  36900. * Cycle Loop Mode
  36901. */
  36902. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36903. /**
  36904. * Constant Loop Mode
  36905. */
  36906. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36907. /** @hidden */
  36908. static _UniversalLerp(left: any, right: any, amount: number): any;
  36909. /**
  36910. * Parses an animation object and creates an animation
  36911. * @param parsedAnimation Parsed animation object
  36912. * @returns Animation object
  36913. */
  36914. static Parse(parsedAnimation: any): Animation;
  36915. /**
  36916. * Appends the serialized animations from the source animations
  36917. * @param source Source containing the animations
  36918. * @param destination Target to store the animations
  36919. */
  36920. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36921. /**
  36922. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36923. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36924. * @param url defines the url to load from
  36925. * @returns a promise that will resolve to the new animation or an array of animations
  36926. */
  36927. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36928. /**
  36929. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36930. * @param snippetId defines the snippet to load
  36931. * @returns a promise that will resolve to the new animation or a new array of animations
  36932. */
  36933. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36934. }
  36935. }
  36936. declare module BABYLON {
  36937. /**
  36938. * Interface containing an array of animations
  36939. */
  36940. export interface IAnimatable {
  36941. /**
  36942. * Array of animations
  36943. */
  36944. animations: Nullable<Array<Animation>>;
  36945. }
  36946. }
  36947. declare module BABYLON {
  36948. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36949. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36950. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36951. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36952. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36953. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36954. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36955. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36956. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36957. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36958. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36959. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36960. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36961. /**
  36962. * Decorator used to define property that can be serialized as reference to a camera
  36963. * @param sourceName defines the name of the property to decorate
  36964. */
  36965. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36966. /**
  36967. * Class used to help serialization objects
  36968. */
  36969. export class SerializationHelper {
  36970. /** @hidden */
  36971. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36972. /** @hidden */
  36973. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36974. /** @hidden */
  36975. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36976. /** @hidden */
  36977. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36978. /**
  36979. * Appends the serialized animations from the source animations
  36980. * @param source Source containing the animations
  36981. * @param destination Target to store the animations
  36982. */
  36983. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36984. /**
  36985. * Static function used to serialized a specific entity
  36986. * @param entity defines the entity to serialize
  36987. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36988. * @returns a JSON compatible object representing the serialization of the entity
  36989. */
  36990. static Serialize<T>(entity: T, serializationObject?: any): any;
  36991. /**
  36992. * Creates a new entity from a serialization data object
  36993. * @param creationFunction defines a function used to instanciated the new entity
  36994. * @param source defines the source serialization data
  36995. * @param scene defines the hosting scene
  36996. * @param rootUrl defines the root url for resources
  36997. * @returns a new entity
  36998. */
  36999. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37000. /**
  37001. * Clones an object
  37002. * @param creationFunction defines the function used to instanciate the new object
  37003. * @param source defines the source object
  37004. * @returns the cloned object
  37005. */
  37006. static Clone<T>(creationFunction: () => T, source: T): T;
  37007. /**
  37008. * Instanciates a new object based on a source one (some data will be shared between both object)
  37009. * @param creationFunction defines the function used to instanciate the new object
  37010. * @param source defines the source object
  37011. * @returns the new object
  37012. */
  37013. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37014. }
  37015. }
  37016. declare module BABYLON {
  37017. /**
  37018. * Base class of all the textures in babylon.
  37019. * It groups all the common properties the materials, post process, lights... might need
  37020. * in order to make a correct use of the texture.
  37021. */
  37022. export class BaseTexture implements IAnimatable {
  37023. /**
  37024. * Default anisotropic filtering level for the application.
  37025. * It is set to 4 as a good tradeoff between perf and quality.
  37026. */
  37027. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37028. /**
  37029. * Gets or sets the unique id of the texture
  37030. */
  37031. uniqueId: number;
  37032. /**
  37033. * Define the name of the texture.
  37034. */
  37035. name: string;
  37036. /**
  37037. * Gets or sets an object used to store user defined information.
  37038. */
  37039. metadata: any;
  37040. /**
  37041. * For internal use only. Please do not use.
  37042. */
  37043. reservedDataStore: any;
  37044. private _hasAlpha;
  37045. /**
  37046. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37047. */
  37048. set hasAlpha(value: boolean);
  37049. get hasAlpha(): boolean;
  37050. /**
  37051. * Defines if the alpha value should be determined via the rgb values.
  37052. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37053. */
  37054. getAlphaFromRGB: boolean;
  37055. /**
  37056. * Intensity or strength of the texture.
  37057. * It is commonly used by materials to fine tune the intensity of the texture
  37058. */
  37059. level: number;
  37060. /**
  37061. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37062. * This is part of the texture as textures usually maps to one uv set.
  37063. */
  37064. coordinatesIndex: number;
  37065. protected _coordinatesMode: number;
  37066. /**
  37067. * How a texture is mapped.
  37068. *
  37069. * | Value | Type | Description |
  37070. * | ----- | ----------------------------------- | ----------- |
  37071. * | 0 | EXPLICIT_MODE | |
  37072. * | 1 | SPHERICAL_MODE | |
  37073. * | 2 | PLANAR_MODE | |
  37074. * | 3 | CUBIC_MODE | |
  37075. * | 4 | PROJECTION_MODE | |
  37076. * | 5 | SKYBOX_MODE | |
  37077. * | 6 | INVCUBIC_MODE | |
  37078. * | 7 | EQUIRECTANGULAR_MODE | |
  37079. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37080. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37081. */
  37082. set coordinatesMode(value: number);
  37083. get coordinatesMode(): number;
  37084. private _wrapU;
  37085. /**
  37086. * | Value | Type | Description |
  37087. * | ----- | ------------------ | ----------- |
  37088. * | 0 | CLAMP_ADDRESSMODE | |
  37089. * | 1 | WRAP_ADDRESSMODE | |
  37090. * | 2 | MIRROR_ADDRESSMODE | |
  37091. */
  37092. get wrapU(): number;
  37093. set wrapU(value: number);
  37094. private _wrapV;
  37095. /**
  37096. * | Value | Type | Description |
  37097. * | ----- | ------------------ | ----------- |
  37098. * | 0 | CLAMP_ADDRESSMODE | |
  37099. * | 1 | WRAP_ADDRESSMODE | |
  37100. * | 2 | MIRROR_ADDRESSMODE | |
  37101. */
  37102. get wrapV(): number;
  37103. set wrapV(value: number);
  37104. /**
  37105. * | Value | Type | Description |
  37106. * | ----- | ------------------ | ----------- |
  37107. * | 0 | CLAMP_ADDRESSMODE | |
  37108. * | 1 | WRAP_ADDRESSMODE | |
  37109. * | 2 | MIRROR_ADDRESSMODE | |
  37110. */
  37111. wrapR: number;
  37112. /**
  37113. * With compliant hardware and browser (supporting anisotropic filtering)
  37114. * this defines the level of anisotropic filtering in the texture.
  37115. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37116. */
  37117. anisotropicFilteringLevel: number;
  37118. /**
  37119. * Define if the texture is a cube texture or if false a 2d texture.
  37120. */
  37121. get isCube(): boolean;
  37122. set isCube(value: boolean);
  37123. /**
  37124. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37125. */
  37126. get is3D(): boolean;
  37127. set is3D(value: boolean);
  37128. /**
  37129. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37130. */
  37131. get is2DArray(): boolean;
  37132. set is2DArray(value: boolean);
  37133. private _gammaSpace;
  37134. /**
  37135. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37136. * HDR texture are usually stored in linear space.
  37137. * This only impacts the PBR and Background materials
  37138. */
  37139. get gammaSpace(): boolean;
  37140. set gammaSpace(gamma: boolean);
  37141. /**
  37142. * Gets or sets whether or not the texture contains RGBD data.
  37143. */
  37144. get isRGBD(): boolean;
  37145. set isRGBD(value: boolean);
  37146. /**
  37147. * Is Z inverted in the texture (useful in a cube texture).
  37148. */
  37149. invertZ: boolean;
  37150. /**
  37151. * Are mip maps generated for this texture or not.
  37152. */
  37153. get noMipmap(): boolean;
  37154. /**
  37155. * @hidden
  37156. */
  37157. lodLevelInAlpha: boolean;
  37158. /**
  37159. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37160. */
  37161. get lodGenerationOffset(): number;
  37162. set lodGenerationOffset(value: number);
  37163. /**
  37164. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37165. */
  37166. get lodGenerationScale(): number;
  37167. set lodGenerationScale(value: number);
  37168. /**
  37169. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37170. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37171. * average roughness values.
  37172. */
  37173. get linearSpecularLOD(): boolean;
  37174. set linearSpecularLOD(value: boolean);
  37175. /**
  37176. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37177. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37178. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37179. */
  37180. get irradianceTexture(): Nullable<BaseTexture>;
  37181. set irradianceTexture(value: Nullable<BaseTexture>);
  37182. /**
  37183. * Define if the texture is a render target.
  37184. */
  37185. isRenderTarget: boolean;
  37186. /**
  37187. * Define the unique id of the texture in the scene.
  37188. */
  37189. get uid(): string;
  37190. /** @hidden */
  37191. _prefiltered: boolean;
  37192. /**
  37193. * Return a string representation of the texture.
  37194. * @returns the texture as a string
  37195. */
  37196. toString(): string;
  37197. /**
  37198. * Get the class name of the texture.
  37199. * @returns "BaseTexture"
  37200. */
  37201. getClassName(): string;
  37202. /**
  37203. * Define the list of animation attached to the texture.
  37204. */
  37205. animations: Animation[];
  37206. /**
  37207. * An event triggered when the texture is disposed.
  37208. */
  37209. onDisposeObservable: Observable<BaseTexture>;
  37210. private _onDisposeObserver;
  37211. /**
  37212. * Callback triggered when the texture has been disposed.
  37213. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37214. */
  37215. set onDispose(callback: () => void);
  37216. /**
  37217. * Define the current state of the loading sequence when in delayed load mode.
  37218. */
  37219. delayLoadState: number;
  37220. protected _scene: Nullable<Scene>;
  37221. protected _engine: Nullable<ThinEngine>;
  37222. /** @hidden */
  37223. _texture: Nullable<InternalTexture>;
  37224. private _uid;
  37225. /**
  37226. * Define if the texture is preventinga material to render or not.
  37227. * If not and the texture is not ready, the engine will use a default black texture instead.
  37228. */
  37229. get isBlocking(): boolean;
  37230. /**
  37231. * Instantiates a new BaseTexture.
  37232. * Base class of all the textures in babylon.
  37233. * It groups all the common properties the materials, post process, lights... might need
  37234. * in order to make a correct use of the texture.
  37235. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37236. */
  37237. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37238. /**
  37239. * Get the scene the texture belongs to.
  37240. * @returns the scene or null if undefined
  37241. */
  37242. getScene(): Nullable<Scene>;
  37243. /** @hidden */
  37244. protected _getEngine(): Nullable<ThinEngine>;
  37245. /**
  37246. * Checks if the texture has the same transform matrix than another texture
  37247. * @param texture texture to check against
  37248. * @returns true if the transforms are the same, else false
  37249. */
  37250. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37251. /**
  37252. * Get the texture transform matrix used to offset tile the texture for istance.
  37253. * @returns the transformation matrix
  37254. */
  37255. getTextureMatrix(): Matrix;
  37256. /**
  37257. * Get the texture reflection matrix used to rotate/transform the reflection.
  37258. * @returns the reflection matrix
  37259. */
  37260. getReflectionTextureMatrix(): Matrix;
  37261. /**
  37262. * Get the underlying lower level texture from Babylon.
  37263. * @returns the insternal texture
  37264. */
  37265. getInternalTexture(): Nullable<InternalTexture>;
  37266. /**
  37267. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37268. * @returns true if ready or not blocking
  37269. */
  37270. isReadyOrNotBlocking(): boolean;
  37271. /**
  37272. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37273. * @returns true if fully ready
  37274. */
  37275. isReady(): boolean;
  37276. private _cachedSize;
  37277. /**
  37278. * Get the size of the texture.
  37279. * @returns the texture size.
  37280. */
  37281. getSize(): ISize;
  37282. /**
  37283. * Get the base size of the texture.
  37284. * It can be different from the size if the texture has been resized for POT for instance
  37285. * @returns the base size
  37286. */
  37287. getBaseSize(): ISize;
  37288. /**
  37289. * Update the sampling mode of the texture.
  37290. * Default is Trilinear mode.
  37291. *
  37292. * | Value | Type | Description |
  37293. * | ----- | ------------------ | ----------- |
  37294. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37295. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37296. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37297. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37298. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37299. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37300. * | 7 | NEAREST_LINEAR | |
  37301. * | 8 | NEAREST_NEAREST | |
  37302. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37303. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37304. * | 11 | LINEAR_LINEAR | |
  37305. * | 12 | LINEAR_NEAREST | |
  37306. *
  37307. * > _mag_: magnification filter (close to the viewer)
  37308. * > _min_: minification filter (far from the viewer)
  37309. * > _mip_: filter used between mip map levels
  37310. *@param samplingMode Define the new sampling mode of the texture
  37311. */
  37312. updateSamplingMode(samplingMode: number): void;
  37313. /**
  37314. * Scales the texture if is `canRescale()`
  37315. * @param ratio the resize factor we want to use to rescale
  37316. */
  37317. scale(ratio: number): void;
  37318. /**
  37319. * Get if the texture can rescale.
  37320. */
  37321. get canRescale(): boolean;
  37322. /** @hidden */
  37323. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37324. /** @hidden */
  37325. _rebuild(): void;
  37326. /**
  37327. * Triggers the load sequence in delayed load mode.
  37328. */
  37329. delayLoad(): void;
  37330. /**
  37331. * Clones the texture.
  37332. * @returns the cloned texture
  37333. */
  37334. clone(): Nullable<BaseTexture>;
  37335. /**
  37336. * Get the texture underlying type (INT, FLOAT...)
  37337. */
  37338. get textureType(): number;
  37339. /**
  37340. * Get the texture underlying format (RGB, RGBA...)
  37341. */
  37342. get textureFormat(): number;
  37343. /**
  37344. * Indicates that textures need to be re-calculated for all materials
  37345. */
  37346. protected _markAllSubMeshesAsTexturesDirty(): void;
  37347. /**
  37348. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37349. * This will returns an RGBA array buffer containing either in values (0-255) or
  37350. * float values (0-1) depending of the underlying buffer type.
  37351. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37352. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37353. * @param buffer defines a user defined buffer to fill with data (can be null)
  37354. * @returns The Array buffer containing the pixels data.
  37355. */
  37356. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37357. /**
  37358. * Release and destroy the underlying lower level texture aka internalTexture.
  37359. */
  37360. releaseInternalTexture(): void;
  37361. /** @hidden */
  37362. get _lodTextureHigh(): Nullable<BaseTexture>;
  37363. /** @hidden */
  37364. get _lodTextureMid(): Nullable<BaseTexture>;
  37365. /** @hidden */
  37366. get _lodTextureLow(): Nullable<BaseTexture>;
  37367. /**
  37368. * Dispose the texture and release its associated resources.
  37369. */
  37370. dispose(): void;
  37371. /**
  37372. * Serialize the texture into a JSON representation that can be parsed later on.
  37373. * @returns the JSON representation of the texture
  37374. */
  37375. serialize(): any;
  37376. /**
  37377. * Helper function to be called back once a list of texture contains only ready textures.
  37378. * @param textures Define the list of textures to wait for
  37379. * @param callback Define the callback triggered once the entire list will be ready
  37380. */
  37381. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37382. private static _isScene;
  37383. }
  37384. }
  37385. declare module BABYLON {
  37386. /**
  37387. * Options to be used when creating an effect.
  37388. */
  37389. export interface IEffectCreationOptions {
  37390. /**
  37391. * Atrributes that will be used in the shader.
  37392. */
  37393. attributes: string[];
  37394. /**
  37395. * Uniform varible names that will be set in the shader.
  37396. */
  37397. uniformsNames: string[];
  37398. /**
  37399. * Uniform buffer variable names that will be set in the shader.
  37400. */
  37401. uniformBuffersNames: string[];
  37402. /**
  37403. * Sampler texture variable names that will be set in the shader.
  37404. */
  37405. samplers: string[];
  37406. /**
  37407. * Define statements that will be set in the shader.
  37408. */
  37409. defines: any;
  37410. /**
  37411. * Possible fallbacks for this effect to improve performance when needed.
  37412. */
  37413. fallbacks: Nullable<IEffectFallbacks>;
  37414. /**
  37415. * Callback that will be called when the shader is compiled.
  37416. */
  37417. onCompiled: Nullable<(effect: Effect) => void>;
  37418. /**
  37419. * Callback that will be called if an error occurs during shader compilation.
  37420. */
  37421. onError: Nullable<(effect: Effect, errors: string) => void>;
  37422. /**
  37423. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37424. */
  37425. indexParameters?: any;
  37426. /**
  37427. * Max number of lights that can be used in the shader.
  37428. */
  37429. maxSimultaneousLights?: number;
  37430. /**
  37431. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37432. */
  37433. transformFeedbackVaryings?: Nullable<string[]>;
  37434. /**
  37435. * 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
  37436. */
  37437. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37438. /**
  37439. * Is this effect rendering to several color attachments ?
  37440. */
  37441. multiTarget?: boolean;
  37442. }
  37443. /**
  37444. * Effect containing vertex and fragment shader that can be executed on an object.
  37445. */
  37446. export class Effect implements IDisposable {
  37447. /**
  37448. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37449. */
  37450. static ShadersRepository: string;
  37451. /**
  37452. * Enable logging of the shader code when a compilation error occurs
  37453. */
  37454. static LogShaderCodeOnCompilationError: boolean;
  37455. /**
  37456. * Name of the effect.
  37457. */
  37458. name: any;
  37459. /**
  37460. * String container all the define statements that should be set on the shader.
  37461. */
  37462. defines: string;
  37463. /**
  37464. * Callback that will be called when the shader is compiled.
  37465. */
  37466. onCompiled: Nullable<(effect: Effect) => void>;
  37467. /**
  37468. * Callback that will be called if an error occurs during shader compilation.
  37469. */
  37470. onError: Nullable<(effect: Effect, errors: string) => void>;
  37471. /**
  37472. * Callback that will be called when effect is bound.
  37473. */
  37474. onBind: Nullable<(effect: Effect) => void>;
  37475. /**
  37476. * Unique ID of the effect.
  37477. */
  37478. uniqueId: number;
  37479. /**
  37480. * Observable that will be called when the shader is compiled.
  37481. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37482. */
  37483. onCompileObservable: Observable<Effect>;
  37484. /**
  37485. * Observable that will be called if an error occurs during shader compilation.
  37486. */
  37487. onErrorObservable: Observable<Effect>;
  37488. /** @hidden */
  37489. _onBindObservable: Nullable<Observable<Effect>>;
  37490. /**
  37491. * @hidden
  37492. * Specifies if the effect was previously ready
  37493. */
  37494. _wasPreviouslyReady: boolean;
  37495. /**
  37496. * Observable that will be called when effect is bound.
  37497. */
  37498. get onBindObservable(): Observable<Effect>;
  37499. /** @hidden */
  37500. _bonesComputationForcedToCPU: boolean;
  37501. /** @hidden */
  37502. _multiTarget: boolean;
  37503. private static _uniqueIdSeed;
  37504. private _engine;
  37505. private _uniformBuffersNames;
  37506. private _uniformBuffersNamesList;
  37507. private _uniformsNames;
  37508. private _samplerList;
  37509. private _samplers;
  37510. private _isReady;
  37511. private _compilationError;
  37512. private _allFallbacksProcessed;
  37513. private _attributesNames;
  37514. private _attributes;
  37515. private _attributeLocationByName;
  37516. private _uniforms;
  37517. /**
  37518. * Key for the effect.
  37519. * @hidden
  37520. */
  37521. _key: string;
  37522. private _indexParameters;
  37523. private _fallbacks;
  37524. private _vertexSourceCode;
  37525. private _fragmentSourceCode;
  37526. private _vertexSourceCodeOverride;
  37527. private _fragmentSourceCodeOverride;
  37528. private _transformFeedbackVaryings;
  37529. /**
  37530. * Compiled shader to webGL program.
  37531. * @hidden
  37532. */
  37533. _pipelineContext: Nullable<IPipelineContext>;
  37534. private _valueCache;
  37535. private static _baseCache;
  37536. /**
  37537. * Instantiates an effect.
  37538. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37539. * @param baseName Name of the effect.
  37540. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37541. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37542. * @param samplers List of sampler variables that will be passed to the shader.
  37543. * @param engine Engine to be used to render the effect
  37544. * @param defines Define statements to be added to the shader.
  37545. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37546. * @param onCompiled Callback that will be called when the shader is compiled.
  37547. * @param onError Callback that will be called if an error occurs during shader compilation.
  37548. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37549. */
  37550. 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);
  37551. private _useFinalCode;
  37552. /**
  37553. * Unique key for this effect
  37554. */
  37555. get key(): string;
  37556. /**
  37557. * If the effect has been compiled and prepared.
  37558. * @returns if the effect is compiled and prepared.
  37559. */
  37560. isReady(): boolean;
  37561. private _isReadyInternal;
  37562. /**
  37563. * The engine the effect was initialized with.
  37564. * @returns the engine.
  37565. */
  37566. getEngine(): Engine;
  37567. /**
  37568. * The pipeline context for this effect
  37569. * @returns the associated pipeline context
  37570. */
  37571. getPipelineContext(): Nullable<IPipelineContext>;
  37572. /**
  37573. * The set of names of attribute variables for the shader.
  37574. * @returns An array of attribute names.
  37575. */
  37576. getAttributesNames(): string[];
  37577. /**
  37578. * Returns the attribute at the given index.
  37579. * @param index The index of the attribute.
  37580. * @returns The location of the attribute.
  37581. */
  37582. getAttributeLocation(index: number): number;
  37583. /**
  37584. * Returns the attribute based on the name of the variable.
  37585. * @param name of the attribute to look up.
  37586. * @returns the attribute location.
  37587. */
  37588. getAttributeLocationByName(name: string): number;
  37589. /**
  37590. * The number of attributes.
  37591. * @returns the numnber of attributes.
  37592. */
  37593. getAttributesCount(): number;
  37594. /**
  37595. * Gets the index of a uniform variable.
  37596. * @param uniformName of the uniform to look up.
  37597. * @returns the index.
  37598. */
  37599. getUniformIndex(uniformName: string): number;
  37600. /**
  37601. * Returns the attribute based on the name of the variable.
  37602. * @param uniformName of the uniform to look up.
  37603. * @returns the location of the uniform.
  37604. */
  37605. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37606. /**
  37607. * Returns an array of sampler variable names
  37608. * @returns The array of sampler variable names.
  37609. */
  37610. getSamplers(): string[];
  37611. /**
  37612. * Returns an array of uniform variable names
  37613. * @returns The array of uniform variable names.
  37614. */
  37615. getUniformNames(): string[];
  37616. /**
  37617. * Returns an array of uniform buffer variable names
  37618. * @returns The array of uniform buffer variable names.
  37619. */
  37620. getUniformBuffersNames(): string[];
  37621. /**
  37622. * Returns the index parameters used to create the effect
  37623. * @returns The index parameters object
  37624. */
  37625. getIndexParameters(): any;
  37626. /**
  37627. * The error from the last compilation.
  37628. * @returns the error string.
  37629. */
  37630. getCompilationError(): string;
  37631. /**
  37632. * Gets a boolean indicating that all fallbacks were used during compilation
  37633. * @returns true if all fallbacks were used
  37634. */
  37635. allFallbacksProcessed(): boolean;
  37636. /**
  37637. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37638. * @param func The callback to be used.
  37639. */
  37640. executeWhenCompiled(func: (effect: Effect) => void): void;
  37641. private _checkIsReady;
  37642. private _loadShader;
  37643. /**
  37644. * Gets the vertex shader source code of this effect
  37645. */
  37646. get vertexSourceCode(): string;
  37647. /**
  37648. * Gets the fragment shader source code of this effect
  37649. */
  37650. get fragmentSourceCode(): string;
  37651. /**
  37652. * Recompiles the webGL program
  37653. * @param vertexSourceCode The source code for the vertex shader.
  37654. * @param fragmentSourceCode The source code for the fragment shader.
  37655. * @param onCompiled Callback called when completed.
  37656. * @param onError Callback called on error.
  37657. * @hidden
  37658. */
  37659. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37660. /**
  37661. * Prepares the effect
  37662. * @hidden
  37663. */
  37664. _prepareEffect(): void;
  37665. private _getShaderCodeAndErrorLine;
  37666. private _processCompilationErrors;
  37667. /**
  37668. * Checks if the effect is supported. (Must be called after compilation)
  37669. */
  37670. get isSupported(): boolean;
  37671. /**
  37672. * Binds a texture to the engine to be used as output of the shader.
  37673. * @param channel Name of the output variable.
  37674. * @param texture Texture to bind.
  37675. * @hidden
  37676. */
  37677. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37678. /**
  37679. * Sets a texture on the engine to be used in the shader.
  37680. * @param channel Name of the sampler variable.
  37681. * @param texture Texture to set.
  37682. */
  37683. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37684. /**
  37685. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37686. * @param channel Name of the sampler variable.
  37687. * @param texture Texture to set.
  37688. */
  37689. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37690. /**
  37691. * Sets an array of textures on the engine to be used in the shader.
  37692. * @param channel Name of the variable.
  37693. * @param textures Textures to set.
  37694. */
  37695. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37696. /**
  37697. * 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)
  37698. * @param channel Name of the sampler variable.
  37699. * @param postProcess Post process to get the input texture from.
  37700. */
  37701. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37702. /**
  37703. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37704. * 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)
  37705. * @param channel Name of the sampler variable.
  37706. * @param postProcess Post process to get the output texture from.
  37707. */
  37708. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37709. /** @hidden */
  37710. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37711. /** @hidden */
  37712. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37713. /** @hidden */
  37714. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37715. /** @hidden */
  37716. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37717. /**
  37718. * Binds a buffer to a uniform.
  37719. * @param buffer Buffer to bind.
  37720. * @param name Name of the uniform variable to bind to.
  37721. */
  37722. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37723. /**
  37724. * Binds block to a uniform.
  37725. * @param blockName Name of the block to bind.
  37726. * @param index Index to bind.
  37727. */
  37728. bindUniformBlock(blockName: string, index: number): void;
  37729. /**
  37730. * Sets an interger value on a uniform variable.
  37731. * @param uniformName Name of the variable.
  37732. * @param value Value to be set.
  37733. * @returns this effect.
  37734. */
  37735. setInt(uniformName: string, value: number): Effect;
  37736. /**
  37737. * Sets an int array on a uniform variable.
  37738. * @param uniformName Name of the variable.
  37739. * @param array array to be set.
  37740. * @returns this effect.
  37741. */
  37742. setIntArray(uniformName: string, array: Int32Array): Effect;
  37743. /**
  37744. * 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)
  37745. * @param uniformName Name of the variable.
  37746. * @param array array to be set.
  37747. * @returns this effect.
  37748. */
  37749. setIntArray2(uniformName: string, array: Int32Array): Effect;
  37750. /**
  37751. * 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)
  37752. * @param uniformName Name of the variable.
  37753. * @param array array to be set.
  37754. * @returns this effect.
  37755. */
  37756. setIntArray3(uniformName: string, array: Int32Array): Effect;
  37757. /**
  37758. * 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)
  37759. * @param uniformName Name of the variable.
  37760. * @param array array to be set.
  37761. * @returns this effect.
  37762. */
  37763. setIntArray4(uniformName: string, array: Int32Array): Effect;
  37764. /**
  37765. * Sets an float array on a uniform variable.
  37766. * @param uniformName Name of the variable.
  37767. * @param array array to be set.
  37768. * @returns this effect.
  37769. */
  37770. setFloatArray(uniformName: string, array: Float32Array): Effect;
  37771. /**
  37772. * 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)
  37773. * @param uniformName Name of the variable.
  37774. * @param array array to be set.
  37775. * @returns this effect.
  37776. */
  37777. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  37778. /**
  37779. * 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)
  37780. * @param uniformName Name of the variable.
  37781. * @param array array to be set.
  37782. * @returns this effect.
  37783. */
  37784. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  37785. /**
  37786. * 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)
  37787. * @param uniformName Name of the variable.
  37788. * @param array array to be set.
  37789. * @returns this effect.
  37790. */
  37791. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  37792. /**
  37793. * Sets an array on a uniform variable.
  37794. * @param uniformName Name of the variable.
  37795. * @param array array to be set.
  37796. * @returns this effect.
  37797. */
  37798. setArray(uniformName: string, array: number[]): Effect;
  37799. /**
  37800. * 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)
  37801. * @param uniformName Name of the variable.
  37802. * @param array array to be set.
  37803. * @returns this effect.
  37804. */
  37805. setArray2(uniformName: string, array: number[]): Effect;
  37806. /**
  37807. * 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)
  37808. * @param uniformName Name of the variable.
  37809. * @param array array to be set.
  37810. * @returns this effect.
  37811. */
  37812. setArray3(uniformName: string, array: number[]): Effect;
  37813. /**
  37814. * 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)
  37815. * @param uniformName Name of the variable.
  37816. * @param array array to be set.
  37817. * @returns this effect.
  37818. */
  37819. setArray4(uniformName: string, array: number[]): Effect;
  37820. /**
  37821. * Sets matrices on a uniform variable.
  37822. * @param uniformName Name of the variable.
  37823. * @param matrices matrices to be set.
  37824. * @returns this effect.
  37825. */
  37826. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  37827. /**
  37828. * Sets matrix on a uniform variable.
  37829. * @param uniformName Name of the variable.
  37830. * @param matrix matrix to be set.
  37831. * @returns this effect.
  37832. */
  37833. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  37834. /**
  37835. * 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)
  37836. * @param uniformName Name of the variable.
  37837. * @param matrix matrix to be set.
  37838. * @returns this effect.
  37839. */
  37840. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37841. /**
  37842. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  37843. * @param uniformName Name of the variable.
  37844. * @param matrix matrix to be set.
  37845. * @returns this effect.
  37846. */
  37847. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37848. /**
  37849. * Sets a float on a uniform variable.
  37850. * @param uniformName Name of the variable.
  37851. * @param value value to be set.
  37852. * @returns this effect.
  37853. */
  37854. setFloat(uniformName: string, value: number): Effect;
  37855. /**
  37856. * Sets a boolean on a uniform variable.
  37857. * @param uniformName Name of the variable.
  37858. * @param bool value to be set.
  37859. * @returns this effect.
  37860. */
  37861. setBool(uniformName: string, bool: boolean): Effect;
  37862. /**
  37863. * Sets a Vector2 on a uniform variable.
  37864. * @param uniformName Name of the variable.
  37865. * @param vector2 vector2 to be set.
  37866. * @returns this effect.
  37867. */
  37868. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  37869. /**
  37870. * Sets a float2 on a uniform variable.
  37871. * @param uniformName Name of the variable.
  37872. * @param x First float in float2.
  37873. * @param y Second float in float2.
  37874. * @returns this effect.
  37875. */
  37876. setFloat2(uniformName: string, x: number, y: number): Effect;
  37877. /**
  37878. * Sets a Vector3 on a uniform variable.
  37879. * @param uniformName Name of the variable.
  37880. * @param vector3 Value to be set.
  37881. * @returns this effect.
  37882. */
  37883. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  37884. /**
  37885. * Sets a float3 on a uniform variable.
  37886. * @param uniformName Name of the variable.
  37887. * @param x First float in float3.
  37888. * @param y Second float in float3.
  37889. * @param z Third float in float3.
  37890. * @returns this effect.
  37891. */
  37892. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  37893. /**
  37894. * Sets a Vector4 on a uniform variable.
  37895. * @param uniformName Name of the variable.
  37896. * @param vector4 Value to be set.
  37897. * @returns this effect.
  37898. */
  37899. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  37900. /**
  37901. * Sets a float4 on a uniform variable.
  37902. * @param uniformName Name of the variable.
  37903. * @param x First float in float4.
  37904. * @param y Second float in float4.
  37905. * @param z Third float in float4.
  37906. * @param w Fourth float in float4.
  37907. * @returns this effect.
  37908. */
  37909. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  37910. /**
  37911. * Sets a Color3 on a uniform variable.
  37912. * @param uniformName Name of the variable.
  37913. * @param color3 Value to be set.
  37914. * @returns this effect.
  37915. */
  37916. setColor3(uniformName: string, color3: IColor3Like): Effect;
  37917. /**
  37918. * Sets a Color4 on a uniform variable.
  37919. * @param uniformName Name of the variable.
  37920. * @param color3 Value to be set.
  37921. * @param alpha Alpha value to be set.
  37922. * @returns this effect.
  37923. */
  37924. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  37925. /**
  37926. * Sets a Color4 on a uniform variable
  37927. * @param uniformName defines the name of the variable
  37928. * @param color4 defines the value to be set
  37929. * @returns this effect.
  37930. */
  37931. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  37932. /** Release all associated resources */
  37933. dispose(): void;
  37934. /**
  37935. * This function will add a new shader to the shader store
  37936. * @param name the name of the shader
  37937. * @param pixelShader optional pixel shader content
  37938. * @param vertexShader optional vertex shader content
  37939. */
  37940. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  37941. /**
  37942. * Store of each shader (The can be looked up using effect.key)
  37943. */
  37944. static ShadersStore: {
  37945. [key: string]: string;
  37946. };
  37947. /**
  37948. * Store of each included file for a shader (The can be looked up using effect.key)
  37949. */
  37950. static IncludesShadersStore: {
  37951. [key: string]: string;
  37952. };
  37953. /**
  37954. * Resets the cache of effects.
  37955. */
  37956. static ResetCache(): void;
  37957. }
  37958. }
  37959. declare module BABYLON {
  37960. /**
  37961. * Interface used to describe the capabilities of the engine relatively to the current browser
  37962. */
  37963. export interface EngineCapabilities {
  37964. /** Maximum textures units per fragment shader */
  37965. maxTexturesImageUnits: number;
  37966. /** Maximum texture units per vertex shader */
  37967. maxVertexTextureImageUnits: number;
  37968. /** Maximum textures units in the entire pipeline */
  37969. maxCombinedTexturesImageUnits: number;
  37970. /** Maximum texture size */
  37971. maxTextureSize: number;
  37972. /** Maximum texture samples */
  37973. maxSamples?: number;
  37974. /** Maximum cube texture size */
  37975. maxCubemapTextureSize: number;
  37976. /** Maximum render texture size */
  37977. maxRenderTextureSize: number;
  37978. /** Maximum number of vertex attributes */
  37979. maxVertexAttribs: number;
  37980. /** Maximum number of varyings */
  37981. maxVaryingVectors: number;
  37982. /** Maximum number of uniforms per vertex shader */
  37983. maxVertexUniformVectors: number;
  37984. /** Maximum number of uniforms per fragment shader */
  37985. maxFragmentUniformVectors: number;
  37986. /** Defines if standard derivates (dx/dy) are supported */
  37987. standardDerivatives: boolean;
  37988. /** Defines if s3tc texture compression is supported */
  37989. s3tc?: WEBGL_compressed_texture_s3tc;
  37990. /** Defines if pvrtc texture compression is supported */
  37991. pvrtc: any;
  37992. /** Defines if etc1 texture compression is supported */
  37993. etc1: any;
  37994. /** Defines if etc2 texture compression is supported */
  37995. etc2: any;
  37996. /** Defines if astc texture compression is supported */
  37997. astc: any;
  37998. /** Defines if bptc texture compression is supported */
  37999. bptc: any;
  38000. /** Defines if float textures are supported */
  38001. textureFloat: boolean;
  38002. /** Defines if vertex array objects are supported */
  38003. vertexArrayObject: boolean;
  38004. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38005. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38006. /** Gets the maximum level of anisotropy supported */
  38007. maxAnisotropy: number;
  38008. /** Defines if instancing is supported */
  38009. instancedArrays: boolean;
  38010. /** Defines if 32 bits indices are supported */
  38011. uintIndices: boolean;
  38012. /** Defines if high precision shaders are supported */
  38013. highPrecisionShaderSupported: boolean;
  38014. /** Defines if depth reading in the fragment shader is supported */
  38015. fragmentDepthSupported: boolean;
  38016. /** Defines if float texture linear filtering is supported*/
  38017. textureFloatLinearFiltering: boolean;
  38018. /** Defines if rendering to float textures is supported */
  38019. textureFloatRender: boolean;
  38020. /** Defines if half float textures are supported*/
  38021. textureHalfFloat: boolean;
  38022. /** Defines if half float texture linear filtering is supported*/
  38023. textureHalfFloatLinearFiltering: boolean;
  38024. /** Defines if rendering to half float textures is supported */
  38025. textureHalfFloatRender: boolean;
  38026. /** Defines if textureLOD shader command is supported */
  38027. textureLOD: boolean;
  38028. /** Defines if draw buffers extension is supported */
  38029. drawBuffersExtension: boolean;
  38030. /** Defines if depth textures are supported */
  38031. depthTextureExtension: boolean;
  38032. /** Defines if float color buffer are supported */
  38033. colorBufferFloat: boolean;
  38034. /** Gets disjoint timer query extension (null if not supported) */
  38035. timerQuery?: EXT_disjoint_timer_query;
  38036. /** Defines if timestamp can be used with timer query */
  38037. canUseTimestampForTimerQuery: boolean;
  38038. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38039. multiview?: any;
  38040. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38041. oculusMultiview?: any;
  38042. /** Function used to let the system compiles shaders in background */
  38043. parallelShaderCompile?: {
  38044. COMPLETION_STATUS_KHR: number;
  38045. };
  38046. /** Max number of texture samples for MSAA */
  38047. maxMSAASamples: number;
  38048. /** Defines if the blend min max extension is supported */
  38049. blendMinMax: boolean;
  38050. }
  38051. }
  38052. declare module BABYLON {
  38053. /**
  38054. * @hidden
  38055. **/
  38056. export class DepthCullingState {
  38057. private _isDepthTestDirty;
  38058. private _isDepthMaskDirty;
  38059. private _isDepthFuncDirty;
  38060. private _isCullFaceDirty;
  38061. private _isCullDirty;
  38062. private _isZOffsetDirty;
  38063. private _isFrontFaceDirty;
  38064. private _depthTest;
  38065. private _depthMask;
  38066. private _depthFunc;
  38067. private _cull;
  38068. private _cullFace;
  38069. private _zOffset;
  38070. private _frontFace;
  38071. /**
  38072. * Initializes the state.
  38073. */
  38074. constructor();
  38075. get isDirty(): boolean;
  38076. get zOffset(): number;
  38077. set zOffset(value: number);
  38078. get cullFace(): Nullable<number>;
  38079. set cullFace(value: Nullable<number>);
  38080. get cull(): Nullable<boolean>;
  38081. set cull(value: Nullable<boolean>);
  38082. get depthFunc(): Nullable<number>;
  38083. set depthFunc(value: Nullable<number>);
  38084. get depthMask(): boolean;
  38085. set depthMask(value: boolean);
  38086. get depthTest(): boolean;
  38087. set depthTest(value: boolean);
  38088. get frontFace(): Nullable<number>;
  38089. set frontFace(value: Nullable<number>);
  38090. reset(): void;
  38091. apply(gl: WebGLRenderingContext): void;
  38092. }
  38093. }
  38094. declare module BABYLON {
  38095. /**
  38096. * @hidden
  38097. **/
  38098. export class StencilState {
  38099. /** 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 */
  38100. static readonly ALWAYS: number;
  38101. /** Passed to stencilOperation to specify that stencil value must be kept */
  38102. static readonly KEEP: number;
  38103. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38104. static readonly REPLACE: number;
  38105. private _isStencilTestDirty;
  38106. private _isStencilMaskDirty;
  38107. private _isStencilFuncDirty;
  38108. private _isStencilOpDirty;
  38109. private _stencilTest;
  38110. private _stencilMask;
  38111. private _stencilFunc;
  38112. private _stencilFuncRef;
  38113. private _stencilFuncMask;
  38114. private _stencilOpStencilFail;
  38115. private _stencilOpDepthFail;
  38116. private _stencilOpStencilDepthPass;
  38117. get isDirty(): boolean;
  38118. get stencilFunc(): number;
  38119. set stencilFunc(value: number);
  38120. get stencilFuncRef(): number;
  38121. set stencilFuncRef(value: number);
  38122. get stencilFuncMask(): number;
  38123. set stencilFuncMask(value: number);
  38124. get stencilOpStencilFail(): number;
  38125. set stencilOpStencilFail(value: number);
  38126. get stencilOpDepthFail(): number;
  38127. set stencilOpDepthFail(value: number);
  38128. get stencilOpStencilDepthPass(): number;
  38129. set stencilOpStencilDepthPass(value: number);
  38130. get stencilMask(): number;
  38131. set stencilMask(value: number);
  38132. get stencilTest(): boolean;
  38133. set stencilTest(value: boolean);
  38134. constructor();
  38135. reset(): void;
  38136. apply(gl: WebGLRenderingContext): void;
  38137. }
  38138. }
  38139. declare module BABYLON {
  38140. /**
  38141. * @hidden
  38142. **/
  38143. export class AlphaState {
  38144. private _isAlphaBlendDirty;
  38145. private _isBlendFunctionParametersDirty;
  38146. private _isBlendEquationParametersDirty;
  38147. private _isBlendConstantsDirty;
  38148. private _alphaBlend;
  38149. private _blendFunctionParameters;
  38150. private _blendEquationParameters;
  38151. private _blendConstants;
  38152. /**
  38153. * Initializes the state.
  38154. */
  38155. constructor();
  38156. get isDirty(): boolean;
  38157. get alphaBlend(): boolean;
  38158. set alphaBlend(value: boolean);
  38159. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38160. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38161. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38162. reset(): void;
  38163. apply(gl: WebGLRenderingContext): void;
  38164. }
  38165. }
  38166. declare module BABYLON {
  38167. /** @hidden */
  38168. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38169. attributeProcessor(attribute: string): string;
  38170. varyingProcessor(varying: string, isFragment: boolean): string;
  38171. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38172. }
  38173. }
  38174. declare module BABYLON {
  38175. /**
  38176. * Interface for attribute information associated with buffer instanciation
  38177. */
  38178. export interface InstancingAttributeInfo {
  38179. /**
  38180. * Name of the GLSL attribute
  38181. * if attribute index is not specified, this is used to retrieve the index from the effect
  38182. */
  38183. attributeName: string;
  38184. /**
  38185. * Index/offset of the attribute in the vertex shader
  38186. * if not specified, this will be computes from the name.
  38187. */
  38188. index?: number;
  38189. /**
  38190. * size of the attribute, 1, 2, 3 or 4
  38191. */
  38192. attributeSize: number;
  38193. /**
  38194. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38195. */
  38196. offset: number;
  38197. /**
  38198. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38199. * default to 1
  38200. */
  38201. divisor?: number;
  38202. /**
  38203. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38204. * default is FLOAT
  38205. */
  38206. attributeType?: number;
  38207. /**
  38208. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38209. */
  38210. normalized?: boolean;
  38211. }
  38212. }
  38213. declare module BABYLON {
  38214. interface ThinEngine {
  38215. /**
  38216. * Update a video texture
  38217. * @param texture defines the texture to update
  38218. * @param video defines the video element to use
  38219. * @param invertY defines if data must be stored with Y axis inverted
  38220. */
  38221. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38222. }
  38223. }
  38224. declare module BABYLON {
  38225. interface ThinEngine {
  38226. /**
  38227. * Creates a dynamic texture
  38228. * @param width defines the width of the texture
  38229. * @param height defines the height of the texture
  38230. * @param generateMipMaps defines if the engine should generate the mip levels
  38231. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38232. * @returns the dynamic texture inside an InternalTexture
  38233. */
  38234. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38235. /**
  38236. * Update the content of a dynamic texture
  38237. * @param texture defines the texture to update
  38238. * @param canvas defines the canvas containing the source
  38239. * @param invertY defines if data must be stored with Y axis inverted
  38240. * @param premulAlpha defines if alpha is stored as premultiplied
  38241. * @param format defines the format of the data
  38242. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38243. */
  38244. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38245. }
  38246. }
  38247. declare module BABYLON {
  38248. /**
  38249. * Settings for finer control over video usage
  38250. */
  38251. export interface VideoTextureSettings {
  38252. /**
  38253. * Applies `autoplay` to video, if specified
  38254. */
  38255. autoPlay?: boolean;
  38256. /**
  38257. * Applies `muted` to video, if specified
  38258. */
  38259. muted?: boolean;
  38260. /**
  38261. * Applies `loop` to video, if specified
  38262. */
  38263. loop?: boolean;
  38264. /**
  38265. * Automatically updates internal texture from video at every frame in the render loop
  38266. */
  38267. autoUpdateTexture: boolean;
  38268. /**
  38269. * Image src displayed during the video loading or until the user interacts with the video.
  38270. */
  38271. poster?: string;
  38272. }
  38273. /**
  38274. * If you want to display a video in your scene, this is the special texture for that.
  38275. * This special texture works similar to other textures, with the exception of a few parameters.
  38276. * @see https://doc.babylonjs.com/how_to/video_texture
  38277. */
  38278. export class VideoTexture extends Texture {
  38279. /**
  38280. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38281. */
  38282. readonly autoUpdateTexture: boolean;
  38283. /**
  38284. * The video instance used by the texture internally
  38285. */
  38286. readonly video: HTMLVideoElement;
  38287. private _onUserActionRequestedObservable;
  38288. /**
  38289. * Event triggerd when a dom action is required by the user to play the video.
  38290. * This happens due to recent changes in browser policies preventing video to auto start.
  38291. */
  38292. get onUserActionRequestedObservable(): Observable<Texture>;
  38293. private _generateMipMaps;
  38294. private _stillImageCaptured;
  38295. private _displayingPosterTexture;
  38296. private _settings;
  38297. private _createInternalTextureOnEvent;
  38298. private _frameId;
  38299. private _currentSrc;
  38300. /**
  38301. * Creates a video texture.
  38302. * If you want to display a video in your scene, this is the special texture for that.
  38303. * This special texture works similar to other textures, with the exception of a few parameters.
  38304. * @see https://doc.babylonjs.com/how_to/video_texture
  38305. * @param name optional name, will detect from video source, if not defined
  38306. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38307. * @param scene is obviously the current scene.
  38308. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38309. * @param invertY is false by default but can be used to invert video on Y axis
  38310. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38311. * @param settings allows finer control over video usage
  38312. */
  38313. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38314. private _getName;
  38315. private _getVideo;
  38316. private _createInternalTexture;
  38317. private reset;
  38318. /**
  38319. * @hidden Internal method to initiate `update`.
  38320. */
  38321. _rebuild(): void;
  38322. /**
  38323. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38324. */
  38325. update(): void;
  38326. /**
  38327. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38328. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38329. */
  38330. updateTexture(isVisible: boolean): void;
  38331. protected _updateInternalTexture: () => void;
  38332. /**
  38333. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38334. * @param url New url.
  38335. */
  38336. updateURL(url: string): void;
  38337. /**
  38338. * Clones the texture.
  38339. * @returns the cloned texture
  38340. */
  38341. clone(): VideoTexture;
  38342. /**
  38343. * Dispose the texture and release its associated resources.
  38344. */
  38345. dispose(): void;
  38346. /**
  38347. * Creates a video texture straight from a stream.
  38348. * @param scene Define the scene the texture should be created in
  38349. * @param stream Define the stream the texture should be created from
  38350. * @returns The created video texture as a promise
  38351. */
  38352. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38353. /**
  38354. * Creates a video texture straight from your WebCam video feed.
  38355. * @param scene Define the scene the texture should be created in
  38356. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38357. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38358. * @returns The created video texture as a promise
  38359. */
  38360. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38361. minWidth: number;
  38362. maxWidth: number;
  38363. minHeight: number;
  38364. maxHeight: number;
  38365. deviceId: string;
  38366. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38367. /**
  38368. * Creates a video texture straight from your WebCam video feed.
  38369. * @param scene Define the scene the texture should be created in
  38370. * @param onReady Define a callback to triggered once the texture will be ready
  38371. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38372. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38373. */
  38374. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38375. minWidth: number;
  38376. maxWidth: number;
  38377. minHeight: number;
  38378. maxHeight: number;
  38379. deviceId: string;
  38380. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38381. }
  38382. }
  38383. declare module BABYLON {
  38384. /**
  38385. * Defines the interface used by objects working like Scene
  38386. * @hidden
  38387. */
  38388. export interface ISceneLike {
  38389. _addPendingData(data: any): void;
  38390. _removePendingData(data: any): void;
  38391. offlineProvider: IOfflineProvider;
  38392. }
  38393. /**
  38394. * Information about the current host
  38395. */
  38396. export interface HostInformation {
  38397. /**
  38398. * Defines if the current host is a mobile
  38399. */
  38400. isMobile: boolean;
  38401. }
  38402. /** Interface defining initialization parameters for Engine class */
  38403. export interface EngineOptions extends WebGLContextAttributes {
  38404. /**
  38405. * Defines if the engine should no exceed a specified device ratio
  38406. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38407. */
  38408. limitDeviceRatio?: number;
  38409. /**
  38410. * Defines if webvr should be enabled automatically
  38411. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38412. */
  38413. autoEnableWebVR?: boolean;
  38414. /**
  38415. * Defines if webgl2 should be turned off even if supported
  38416. * @see https://doc.babylonjs.com/features/webgl2
  38417. */
  38418. disableWebGL2Support?: boolean;
  38419. /**
  38420. * Defines if webaudio should be initialized as well
  38421. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38422. */
  38423. audioEngine?: boolean;
  38424. /**
  38425. * Defines if animations should run using a deterministic lock step
  38426. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38427. */
  38428. deterministicLockstep?: boolean;
  38429. /** Defines the maximum steps to use with deterministic lock step mode */
  38430. lockstepMaxSteps?: number;
  38431. /** Defines the seconds between each deterministic lock step */
  38432. timeStep?: number;
  38433. /**
  38434. * Defines that engine should ignore context lost events
  38435. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38436. */
  38437. doNotHandleContextLost?: boolean;
  38438. /**
  38439. * Defines that engine should ignore modifying touch action attribute and style
  38440. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38441. */
  38442. doNotHandleTouchAction?: boolean;
  38443. /**
  38444. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38445. */
  38446. useHighPrecisionFloats?: boolean;
  38447. /**
  38448. * Make the canvas XR Compatible for XR sessions
  38449. */
  38450. xrCompatible?: boolean;
  38451. /**
  38452. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38453. */
  38454. useHighPrecisionMatrix?: boolean;
  38455. /**
  38456. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38457. */
  38458. failIfMajorPerformanceCaveat?: boolean;
  38459. }
  38460. /**
  38461. * The base engine class (root of all engines)
  38462. */
  38463. export class ThinEngine {
  38464. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38465. static ExceptionList: ({
  38466. key: string;
  38467. capture: string;
  38468. captureConstraint: number;
  38469. targets: string[];
  38470. } | {
  38471. key: string;
  38472. capture: null;
  38473. captureConstraint: null;
  38474. targets: string[];
  38475. })[];
  38476. /** @hidden */
  38477. static _TextureLoaders: IInternalTextureLoader[];
  38478. /**
  38479. * Returns the current npm package of the sdk
  38480. */
  38481. static get NpmPackage(): string;
  38482. /**
  38483. * Returns the current version of the framework
  38484. */
  38485. static get Version(): string;
  38486. /**
  38487. * Returns a string describing the current engine
  38488. */
  38489. get description(): string;
  38490. /**
  38491. * Gets or sets the epsilon value used by collision engine
  38492. */
  38493. static CollisionsEpsilon: number;
  38494. /**
  38495. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38496. */
  38497. static get ShadersRepository(): string;
  38498. static set ShadersRepository(value: string);
  38499. /** @hidden */
  38500. _shaderProcessor: IShaderProcessor;
  38501. /**
  38502. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38503. */
  38504. forcePOTTextures: boolean;
  38505. /**
  38506. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38507. */
  38508. isFullscreen: boolean;
  38509. /**
  38510. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38511. */
  38512. cullBackFaces: boolean;
  38513. /**
  38514. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38515. */
  38516. renderEvenInBackground: boolean;
  38517. /**
  38518. * Gets or sets a boolean indicating that cache can be kept between frames
  38519. */
  38520. preventCacheWipeBetweenFrames: boolean;
  38521. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38522. validateShaderPrograms: boolean;
  38523. /**
  38524. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38525. * This can provide greater z depth for distant objects.
  38526. */
  38527. useReverseDepthBuffer: boolean;
  38528. /**
  38529. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38530. */
  38531. disableUniformBuffers: boolean;
  38532. /** @hidden */
  38533. _uniformBuffers: UniformBuffer[];
  38534. /**
  38535. * Gets a boolean indicating that the engine supports uniform buffers
  38536. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38537. */
  38538. get supportsUniformBuffers(): boolean;
  38539. /** @hidden */
  38540. _gl: WebGLRenderingContext;
  38541. /** @hidden */
  38542. _webGLVersion: number;
  38543. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38544. protected _windowIsBackground: boolean;
  38545. protected _creationOptions: EngineOptions;
  38546. protected _highPrecisionShadersAllowed: boolean;
  38547. /** @hidden */
  38548. get _shouldUseHighPrecisionShader(): boolean;
  38549. /**
  38550. * Gets a boolean indicating that only power of 2 textures are supported
  38551. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38552. */
  38553. get needPOTTextures(): boolean;
  38554. /** @hidden */
  38555. _badOS: boolean;
  38556. /** @hidden */
  38557. _badDesktopOS: boolean;
  38558. private _hardwareScalingLevel;
  38559. /** @hidden */
  38560. _caps: EngineCapabilities;
  38561. private _isStencilEnable;
  38562. private _glVersion;
  38563. private _glRenderer;
  38564. private _glVendor;
  38565. /** @hidden */
  38566. _videoTextureSupported: boolean;
  38567. protected _renderingQueueLaunched: boolean;
  38568. protected _activeRenderLoops: (() => void)[];
  38569. /**
  38570. * Observable signaled when a context lost event is raised
  38571. */
  38572. onContextLostObservable: Observable<ThinEngine>;
  38573. /**
  38574. * Observable signaled when a context restored event is raised
  38575. */
  38576. onContextRestoredObservable: Observable<ThinEngine>;
  38577. private _onContextLost;
  38578. private _onContextRestored;
  38579. protected _contextWasLost: boolean;
  38580. /** @hidden */
  38581. _doNotHandleContextLost: boolean;
  38582. /**
  38583. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38584. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38585. */
  38586. get doNotHandleContextLost(): boolean;
  38587. set doNotHandleContextLost(value: boolean);
  38588. /**
  38589. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38590. */
  38591. disableVertexArrayObjects: boolean;
  38592. /** @hidden */
  38593. protected _colorWrite: boolean;
  38594. /** @hidden */
  38595. protected _colorWriteChanged: boolean;
  38596. /** @hidden */
  38597. protected _depthCullingState: DepthCullingState;
  38598. /** @hidden */
  38599. protected _stencilState: StencilState;
  38600. /** @hidden */
  38601. _alphaState: AlphaState;
  38602. /** @hidden */
  38603. _alphaMode: number;
  38604. /** @hidden */
  38605. _alphaEquation: number;
  38606. /** @hidden */
  38607. _internalTexturesCache: InternalTexture[];
  38608. /** @hidden */
  38609. protected _activeChannel: number;
  38610. private _currentTextureChannel;
  38611. /** @hidden */
  38612. protected _boundTexturesCache: {
  38613. [key: string]: Nullable<InternalTexture>;
  38614. };
  38615. /** @hidden */
  38616. protected _currentEffect: Nullable<Effect>;
  38617. /** @hidden */
  38618. protected _currentProgram: Nullable<WebGLProgram>;
  38619. private _compiledEffects;
  38620. private _vertexAttribArraysEnabled;
  38621. /** @hidden */
  38622. protected _cachedViewport: Nullable<IViewportLike>;
  38623. private _cachedVertexArrayObject;
  38624. /** @hidden */
  38625. protected _cachedVertexBuffers: any;
  38626. /** @hidden */
  38627. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38628. /** @hidden */
  38629. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38630. /** @hidden */
  38631. _currentRenderTarget: Nullable<InternalTexture>;
  38632. private _uintIndicesCurrentlySet;
  38633. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38634. /** @hidden */
  38635. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38636. /** @hidden */
  38637. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38638. private _currentBufferPointers;
  38639. private _currentInstanceLocations;
  38640. private _currentInstanceBuffers;
  38641. private _textureUnits;
  38642. /** @hidden */
  38643. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38644. /** @hidden */
  38645. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38646. /** @hidden */
  38647. _boundRenderFunction: any;
  38648. private _vaoRecordInProgress;
  38649. private _mustWipeVertexAttributes;
  38650. private _emptyTexture;
  38651. private _emptyCubeTexture;
  38652. private _emptyTexture3D;
  38653. private _emptyTexture2DArray;
  38654. /** @hidden */
  38655. _frameHandler: number;
  38656. private _nextFreeTextureSlots;
  38657. private _maxSimultaneousTextures;
  38658. private _activeRequests;
  38659. /** @hidden */
  38660. _transformTextureUrl: Nullable<(url: string) => string>;
  38661. /**
  38662. * Gets information about the current host
  38663. */
  38664. hostInformation: HostInformation;
  38665. protected get _supportsHardwareTextureRescaling(): boolean;
  38666. private _framebufferDimensionsObject;
  38667. /**
  38668. * sets the object from which width and height will be taken from when getting render width and height
  38669. * Will fallback to the gl object
  38670. * @param dimensions the framebuffer width and height that will be used.
  38671. */
  38672. set framebufferDimensionsObject(dimensions: Nullable<{
  38673. framebufferWidth: number;
  38674. framebufferHeight: number;
  38675. }>);
  38676. /**
  38677. * Gets the current viewport
  38678. */
  38679. get currentViewport(): Nullable<IViewportLike>;
  38680. /**
  38681. * Gets the default empty texture
  38682. */
  38683. get emptyTexture(): InternalTexture;
  38684. /**
  38685. * Gets the default empty 3D texture
  38686. */
  38687. get emptyTexture3D(): InternalTexture;
  38688. /**
  38689. * Gets the default empty 2D array texture
  38690. */
  38691. get emptyTexture2DArray(): InternalTexture;
  38692. /**
  38693. * Gets the default empty cube texture
  38694. */
  38695. get emptyCubeTexture(): InternalTexture;
  38696. /**
  38697. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38698. */
  38699. readonly premultipliedAlpha: boolean;
  38700. /**
  38701. * Observable event triggered before each texture is initialized
  38702. */
  38703. onBeforeTextureInitObservable: Observable<Texture>;
  38704. /**
  38705. * Creates a new engine
  38706. * @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
  38707. * @param antialias defines enable antialiasing (default: false)
  38708. * @param options defines further options to be sent to the getContext() function
  38709. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38710. */
  38711. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38712. private _rebuildInternalTextures;
  38713. private _rebuildEffects;
  38714. /**
  38715. * Gets a boolean indicating if all created effects are ready
  38716. * @returns true if all effects are ready
  38717. */
  38718. areAllEffectsReady(): boolean;
  38719. protected _rebuildBuffers(): void;
  38720. protected _initGLContext(): void;
  38721. /**
  38722. * Gets version of the current webGL context
  38723. */
  38724. get webGLVersion(): number;
  38725. /**
  38726. * Gets a string identifying the name of the class
  38727. * @returns "Engine" string
  38728. */
  38729. getClassName(): string;
  38730. /**
  38731. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  38732. */
  38733. get isStencilEnable(): boolean;
  38734. /** @hidden */
  38735. _prepareWorkingCanvas(): void;
  38736. /**
  38737. * Reset the texture cache to empty state
  38738. */
  38739. resetTextureCache(): void;
  38740. /**
  38741. * Gets an object containing information about the current webGL context
  38742. * @returns an object containing the vender, the renderer and the version of the current webGL context
  38743. */
  38744. getGlInfo(): {
  38745. vendor: string;
  38746. renderer: string;
  38747. version: string;
  38748. };
  38749. /**
  38750. * Defines the hardware scaling level.
  38751. * By default the hardware scaling level is computed from the window device ratio.
  38752. * 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.
  38753. * @param level defines the level to use
  38754. */
  38755. setHardwareScalingLevel(level: number): void;
  38756. /**
  38757. * Gets the current hardware scaling level.
  38758. * By default the hardware scaling level is computed from the window device ratio.
  38759. * 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.
  38760. * @returns a number indicating the current hardware scaling level
  38761. */
  38762. getHardwareScalingLevel(): number;
  38763. /**
  38764. * Gets the list of loaded textures
  38765. * @returns an array containing all loaded textures
  38766. */
  38767. getLoadedTexturesCache(): InternalTexture[];
  38768. /**
  38769. * Gets the object containing all engine capabilities
  38770. * @returns the EngineCapabilities object
  38771. */
  38772. getCaps(): EngineCapabilities;
  38773. /**
  38774. * stop executing a render loop function and remove it from the execution array
  38775. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  38776. */
  38777. stopRenderLoop(renderFunction?: () => void): void;
  38778. /** @hidden */
  38779. _renderLoop(): void;
  38780. /**
  38781. * Gets the HTML canvas attached with the current webGL context
  38782. * @returns a HTML canvas
  38783. */
  38784. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  38785. /**
  38786. * Gets host window
  38787. * @returns the host window object
  38788. */
  38789. getHostWindow(): Nullable<Window>;
  38790. /**
  38791. * Gets the current render width
  38792. * @param useScreen defines if screen size must be used (or the current render target if any)
  38793. * @returns a number defining the current render width
  38794. */
  38795. getRenderWidth(useScreen?: boolean): number;
  38796. /**
  38797. * Gets the current render height
  38798. * @param useScreen defines if screen size must be used (or the current render target if any)
  38799. * @returns a number defining the current render height
  38800. */
  38801. getRenderHeight(useScreen?: boolean): number;
  38802. /**
  38803. * Can be used to override the current requestAnimationFrame requester.
  38804. * @hidden
  38805. */
  38806. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  38807. /**
  38808. * Register and execute a render loop. The engine can have more than one render function
  38809. * @param renderFunction defines the function to continuously execute
  38810. */
  38811. runRenderLoop(renderFunction: () => void): void;
  38812. /**
  38813. * Clear the current render buffer or the current render target (if any is set up)
  38814. * @param color defines the color to use
  38815. * @param backBuffer defines if the back buffer must be cleared
  38816. * @param depth defines if the depth buffer must be cleared
  38817. * @param stencil defines if the stencil buffer must be cleared
  38818. */
  38819. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  38820. private _viewportCached;
  38821. /** @hidden */
  38822. _viewport(x: number, y: number, width: number, height: number): void;
  38823. /**
  38824. * Set the WebGL's viewport
  38825. * @param viewport defines the viewport element to be used
  38826. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  38827. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  38828. */
  38829. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  38830. /**
  38831. * Begin a new frame
  38832. */
  38833. beginFrame(): void;
  38834. /**
  38835. * Enf the current frame
  38836. */
  38837. endFrame(): void;
  38838. /**
  38839. * Resize the view according to the canvas' size
  38840. */
  38841. resize(): void;
  38842. /**
  38843. * Force a specific size of the canvas
  38844. * @param width defines the new canvas' width
  38845. * @param height defines the new canvas' height
  38846. * @returns true if the size was changed
  38847. */
  38848. setSize(width: number, height: number): boolean;
  38849. /**
  38850. * Binds the frame buffer to the specified texture.
  38851. * @param texture The texture to render to or null for the default canvas
  38852. * @param faceIndex The face of the texture to render to in case of cube texture
  38853. * @param requiredWidth The width of the target to render to
  38854. * @param requiredHeight The height of the target to render to
  38855. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  38856. * @param lodLevel defines the lod level to bind to the frame buffer
  38857. * @param layer defines the 2d array index to bind to frame buffer to
  38858. */
  38859. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  38860. /** @hidden */
  38861. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  38862. /**
  38863. * Unbind the current render target texture from the webGL context
  38864. * @param texture defines the render target texture to unbind
  38865. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  38866. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  38867. */
  38868. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  38869. /**
  38870. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  38871. */
  38872. flushFramebuffer(): void;
  38873. /**
  38874. * Unbind the current render target and bind the default framebuffer
  38875. */
  38876. restoreDefaultFramebuffer(): void;
  38877. /** @hidden */
  38878. protected _resetVertexBufferBinding(): void;
  38879. /**
  38880. * Creates a vertex buffer
  38881. * @param data the data for the vertex buffer
  38882. * @returns the new WebGL static buffer
  38883. */
  38884. createVertexBuffer(data: DataArray): DataBuffer;
  38885. private _createVertexBuffer;
  38886. /**
  38887. * Creates a dynamic vertex buffer
  38888. * @param data the data for the dynamic vertex buffer
  38889. * @returns the new WebGL dynamic buffer
  38890. */
  38891. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  38892. protected _resetIndexBufferBinding(): void;
  38893. /**
  38894. * Creates a new index buffer
  38895. * @param indices defines the content of the index buffer
  38896. * @param updatable defines if the index buffer must be updatable
  38897. * @returns a new webGL buffer
  38898. */
  38899. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  38900. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  38901. /**
  38902. * Bind a webGL buffer to the webGL context
  38903. * @param buffer defines the buffer to bind
  38904. */
  38905. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  38906. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  38907. private bindBuffer;
  38908. /**
  38909. * update the bound buffer with the given data
  38910. * @param data defines the data to update
  38911. */
  38912. updateArrayBuffer(data: Float32Array): void;
  38913. private _vertexAttribPointer;
  38914. /** @hidden */
  38915. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  38916. private _bindVertexBuffersAttributes;
  38917. /**
  38918. * Records a vertex array object
  38919. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38920. * @param vertexBuffers defines the list of vertex buffers to store
  38921. * @param indexBuffer defines the index buffer to store
  38922. * @param effect defines the effect to store
  38923. * @returns the new vertex array object
  38924. */
  38925. recordVertexArrayObject(vertexBuffers: {
  38926. [key: string]: VertexBuffer;
  38927. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  38928. /**
  38929. * Bind a specific vertex array object
  38930. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38931. * @param vertexArrayObject defines the vertex array object to bind
  38932. * @param indexBuffer defines the index buffer to bind
  38933. */
  38934. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  38935. /**
  38936. * Bind webGl buffers directly to the webGL context
  38937. * @param vertexBuffer defines the vertex buffer to bind
  38938. * @param indexBuffer defines the index buffer to bind
  38939. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  38940. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  38941. * @param effect defines the effect associated with the vertex buffer
  38942. */
  38943. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  38944. private _unbindVertexArrayObject;
  38945. /**
  38946. * Bind a list of vertex buffers to the webGL context
  38947. * @param vertexBuffers defines the list of vertex buffers to bind
  38948. * @param indexBuffer defines the index buffer to bind
  38949. * @param effect defines the effect associated with the vertex buffers
  38950. */
  38951. bindBuffers(vertexBuffers: {
  38952. [key: string]: Nullable<VertexBuffer>;
  38953. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  38954. /**
  38955. * Unbind all instance attributes
  38956. */
  38957. unbindInstanceAttributes(): void;
  38958. /**
  38959. * Release and free the memory of a vertex array object
  38960. * @param vao defines the vertex array object to delete
  38961. */
  38962. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  38963. /** @hidden */
  38964. _releaseBuffer(buffer: DataBuffer): boolean;
  38965. protected _deleteBuffer(buffer: DataBuffer): void;
  38966. /**
  38967. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  38968. * @param instancesBuffer defines the webGL buffer to update and bind
  38969. * @param data defines the data to store in the buffer
  38970. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  38971. */
  38972. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  38973. /**
  38974. * Bind the content of a webGL buffer used with instantiation
  38975. * @param instancesBuffer defines the webGL buffer to bind
  38976. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  38977. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  38978. */
  38979. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  38980. /**
  38981. * Disable the instance attribute corresponding to the name in parameter
  38982. * @param name defines the name of the attribute to disable
  38983. */
  38984. disableInstanceAttributeByName(name: string): void;
  38985. /**
  38986. * Disable the instance attribute corresponding to the location in parameter
  38987. * @param attributeLocation defines the attribute location of the attribute to disable
  38988. */
  38989. disableInstanceAttribute(attributeLocation: number): void;
  38990. /**
  38991. * Disable the attribute corresponding to the location in parameter
  38992. * @param attributeLocation defines the attribute location of the attribute to disable
  38993. */
  38994. disableAttributeByIndex(attributeLocation: number): void;
  38995. /**
  38996. * Send a draw order
  38997. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  38998. * @param indexStart defines the starting index
  38999. * @param indexCount defines the number of index to draw
  39000. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39001. */
  39002. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39003. /**
  39004. * Draw a list of points
  39005. * @param verticesStart defines the index of first vertex to draw
  39006. * @param verticesCount defines the count of vertices to draw
  39007. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39008. */
  39009. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39010. /**
  39011. * Draw a list of unindexed primitives
  39012. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39013. * @param verticesStart defines the index of first vertex to draw
  39014. * @param verticesCount defines the count of vertices to draw
  39015. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39016. */
  39017. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39018. /**
  39019. * Draw a list of indexed primitives
  39020. * @param fillMode defines the primitive to use
  39021. * @param indexStart defines the starting index
  39022. * @param indexCount defines the number of index to draw
  39023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39024. */
  39025. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39026. /**
  39027. * Draw a list of unindexed primitives
  39028. * @param fillMode defines the primitive to use
  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. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39034. private _drawMode;
  39035. /** @hidden */
  39036. protected _reportDrawCall(): void;
  39037. /** @hidden */
  39038. _releaseEffect(effect: Effect): void;
  39039. /** @hidden */
  39040. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39041. /**
  39042. * Create a new effect (used to store vertex/fragment shaders)
  39043. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39044. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39045. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39046. * @param samplers defines an array of string used to represent textures
  39047. * @param defines defines the string containing the defines to use to compile the shaders
  39048. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39049. * @param onCompiled defines a function to call when the effect creation is successful
  39050. * @param onError defines a function to call when the effect creation has failed
  39051. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39052. * @returns the new Effect
  39053. */
  39054. 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;
  39055. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39056. private _compileShader;
  39057. private _compileRawShader;
  39058. /** @hidden */
  39059. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39060. /**
  39061. * Directly creates a webGL program
  39062. * @param pipelineContext defines the pipeline context to attach to
  39063. * @param vertexCode defines the vertex shader code to use
  39064. * @param fragmentCode defines the fragment shader code to use
  39065. * @param context defines the webGL context to use (if not set, the current one will be used)
  39066. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39067. * @returns the new webGL program
  39068. */
  39069. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39070. /**
  39071. * Creates a webGL program
  39072. * @param pipelineContext defines the pipeline context to attach to
  39073. * @param vertexCode defines the vertex shader code to use
  39074. * @param fragmentCode defines the fragment shader code to use
  39075. * @param defines defines the string containing the defines to use to compile the shaders
  39076. * @param context defines the webGL context to use (if not set, the current one will be used)
  39077. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39078. * @returns the new webGL program
  39079. */
  39080. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39081. /**
  39082. * Creates a new pipeline context
  39083. * @returns the new pipeline
  39084. */
  39085. createPipelineContext(): IPipelineContext;
  39086. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39087. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39088. /** @hidden */
  39089. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39090. /** @hidden */
  39091. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39092. /** @hidden */
  39093. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39094. /**
  39095. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39096. * @param pipelineContext defines the pipeline context to use
  39097. * @param uniformsNames defines the list of uniform names
  39098. * @returns an array of webGL uniform locations
  39099. */
  39100. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39101. /**
  39102. * Gets the lsit of active attributes for a given webGL program
  39103. * @param pipelineContext defines the pipeline context to use
  39104. * @param attributesNames defines the list of attribute names to get
  39105. * @returns an array of indices indicating the offset of each attribute
  39106. */
  39107. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39108. /**
  39109. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39110. * @param effect defines the effect to activate
  39111. */
  39112. enableEffect(effect: Nullable<Effect>): void;
  39113. /**
  39114. * Set the value of an uniform to a number (int)
  39115. * @param uniform defines the webGL uniform location where to store the value
  39116. * @param value defines the int number to store
  39117. * @returns true if the value was set
  39118. */
  39119. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39120. /**
  39121. * Set the value of an uniform to an array of int32
  39122. * @param uniform defines the webGL uniform location where to store the value
  39123. * @param array defines the array of int32 to store
  39124. * @returns true if the value was set
  39125. */
  39126. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39127. /**
  39128. * Set the value of an uniform to an array of int32 (stored as vec2)
  39129. * @param uniform defines the webGL uniform location where to store the value
  39130. * @param array defines the array of int32 to store
  39131. * @returns true if the value was set
  39132. */
  39133. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39134. /**
  39135. * Set the value of an uniform to an array of int32 (stored as vec3)
  39136. * @param uniform defines the webGL uniform location where to store the value
  39137. * @param array defines the array of int32 to store
  39138. * @returns true if the value was set
  39139. */
  39140. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39141. /**
  39142. * Set the value of an uniform to an array of int32 (stored as vec4)
  39143. * @param uniform defines the webGL uniform location where to store the value
  39144. * @param array defines the array of int32 to store
  39145. * @returns true if the value was set
  39146. */
  39147. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39148. /**
  39149. * Set the value of an uniform to an array of number
  39150. * @param uniform defines the webGL uniform location where to store the value
  39151. * @param array defines the array of number to store
  39152. * @returns true if the value was set
  39153. */
  39154. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39155. /**
  39156. * Set the value of an uniform to an array of number (stored as vec2)
  39157. * @param uniform defines the webGL uniform location where to store the value
  39158. * @param array defines the array of number to store
  39159. * @returns true if the value was set
  39160. */
  39161. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39162. /**
  39163. * Set the value of an uniform to an array of number (stored as vec3)
  39164. * @param uniform defines the webGL uniform location where to store the value
  39165. * @param array defines the array of number to store
  39166. * @returns true if the value was set
  39167. */
  39168. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39169. /**
  39170. * Set the value of an uniform to an array of number (stored as vec4)
  39171. * @param uniform defines the webGL uniform location where to store the value
  39172. * @param array defines the array of number to store
  39173. * @returns true if the value was set
  39174. */
  39175. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39176. /**
  39177. * Set the value of an uniform to an array of float32 (stored as matrices)
  39178. * @param uniform defines the webGL uniform location where to store the value
  39179. * @param matrices defines the array of float32 to store
  39180. * @returns true if the value was set
  39181. */
  39182. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39183. /**
  39184. * Set the value of an uniform to a matrix (3x3)
  39185. * @param uniform defines the webGL uniform location where to store the value
  39186. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39187. * @returns true if the value was set
  39188. */
  39189. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39190. /**
  39191. * Set the value of an uniform to a matrix (2x2)
  39192. * @param uniform defines the webGL uniform location where to store the value
  39193. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39194. * @returns true if the value was set
  39195. */
  39196. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39197. /**
  39198. * Set the value of an uniform to a number (float)
  39199. * @param uniform defines the webGL uniform location where to store the value
  39200. * @param value defines the float number to store
  39201. * @returns true if the value was transfered
  39202. */
  39203. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39204. /**
  39205. * Set the value of an uniform to a vec2
  39206. * @param uniform defines the webGL uniform location where to store the value
  39207. * @param x defines the 1st component of the value
  39208. * @param y defines the 2nd component of the value
  39209. * @returns true if the value was set
  39210. */
  39211. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39212. /**
  39213. * Set the value of an uniform to a vec3
  39214. * @param uniform defines the webGL uniform location where to store the value
  39215. * @param x defines the 1st component of the value
  39216. * @param y defines the 2nd component of the value
  39217. * @param z defines the 3rd component of the value
  39218. * @returns true if the value was set
  39219. */
  39220. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39221. /**
  39222. * Set the value of an uniform to a vec4
  39223. * @param uniform defines the webGL uniform location where to store the value
  39224. * @param x defines the 1st component of the value
  39225. * @param y defines the 2nd component of the value
  39226. * @param z defines the 3rd component of the value
  39227. * @param w defines the 4th component of the value
  39228. * @returns true if the value was set
  39229. */
  39230. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39231. /**
  39232. * Apply all cached states (depth, culling, stencil and alpha)
  39233. */
  39234. applyStates(): void;
  39235. /**
  39236. * Enable or disable color writing
  39237. * @param enable defines the state to set
  39238. */
  39239. setColorWrite(enable: boolean): void;
  39240. /**
  39241. * Gets a boolean indicating if color writing is enabled
  39242. * @returns the current color writing state
  39243. */
  39244. getColorWrite(): boolean;
  39245. /**
  39246. * Gets the depth culling state manager
  39247. */
  39248. get depthCullingState(): DepthCullingState;
  39249. /**
  39250. * Gets the alpha state manager
  39251. */
  39252. get alphaState(): AlphaState;
  39253. /**
  39254. * Gets the stencil state manager
  39255. */
  39256. get stencilState(): StencilState;
  39257. /**
  39258. * Clears the list of texture accessible through engine.
  39259. * This can help preventing texture load conflict due to name collision.
  39260. */
  39261. clearInternalTexturesCache(): void;
  39262. /**
  39263. * Force the entire cache to be cleared
  39264. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39265. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39266. */
  39267. wipeCaches(bruteForce?: boolean): void;
  39268. /** @hidden */
  39269. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39270. min: number;
  39271. mag: number;
  39272. };
  39273. /** @hidden */
  39274. _createTexture(): WebGLTexture;
  39275. /**
  39276. * Usually called from Texture.ts.
  39277. * Passed information to create a WebGLTexture
  39278. * @param url defines a value which contains one of the following:
  39279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39283. * @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)
  39284. * @param scene needed for loading to the correct scene
  39285. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39286. * @param onLoad optional callback to be called upon successful completion
  39287. * @param onError optional callback to be called upon failure
  39288. * @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
  39289. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39291. * @param forcedExtension defines the extension to use to pick the right loader
  39292. * @param mimeType defines an optional mime type
  39293. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39294. */
  39295. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  39296. /**
  39297. * Loads an image as an HTMLImageElement.
  39298. * @param input url string, ArrayBuffer, or Blob to load
  39299. * @param onLoad callback called when the image successfully loads
  39300. * @param onError callback called when the image fails to load
  39301. * @param offlineProvider offline provider for caching
  39302. * @param mimeType optional mime type
  39303. * @returns the HTMLImageElement of the loaded image
  39304. * @hidden
  39305. */
  39306. 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>;
  39307. /**
  39308. * @hidden
  39309. */
  39310. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39311. private _unpackFlipYCached;
  39312. /**
  39313. * In case you are sharing the context with other applications, it might
  39314. * be interested to not cache the unpack flip y state to ensure a consistent
  39315. * value would be set.
  39316. */
  39317. enableUnpackFlipYCached: boolean;
  39318. /** @hidden */
  39319. _unpackFlipY(value: boolean): void;
  39320. /** @hidden */
  39321. _getUnpackAlignement(): number;
  39322. private _getTextureTarget;
  39323. /**
  39324. * Update the sampling mode of a given texture
  39325. * @param samplingMode defines the required sampling mode
  39326. * @param texture defines the texture to update
  39327. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39328. */
  39329. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39330. /**
  39331. * Update the sampling mode of a given texture
  39332. * @param texture defines the texture to update
  39333. * @param wrapU defines the texture wrap mode of the u coordinates
  39334. * @param wrapV defines the texture wrap mode of the v coordinates
  39335. * @param wrapR defines the texture wrap mode of the r coordinates
  39336. */
  39337. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39338. /** @hidden */
  39339. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39340. width: number;
  39341. height: number;
  39342. layers?: number;
  39343. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39344. /** @hidden */
  39345. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39346. /** @hidden */
  39347. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39348. /**
  39349. * Update a portion of an internal texture
  39350. * @param texture defines the texture to update
  39351. * @param imageData defines the data to store into the texture
  39352. * @param xOffset defines the x coordinates of the update rectangle
  39353. * @param yOffset defines the y coordinates of the update rectangle
  39354. * @param width defines the width of the update rectangle
  39355. * @param height defines the height of the update rectangle
  39356. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39357. * @param lod defines the lod level to update (0 by default)
  39358. */
  39359. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39360. /** @hidden */
  39361. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39362. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39363. private _prepareWebGLTexture;
  39364. /** @hidden */
  39365. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39366. private _getDepthStencilBuffer;
  39367. /** @hidden */
  39368. _releaseFramebufferObjects(texture: InternalTexture): void;
  39369. /** @hidden */
  39370. _releaseTexture(texture: InternalTexture): void;
  39371. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39372. protected _setProgram(program: WebGLProgram): void;
  39373. protected _boundUniforms: {
  39374. [key: number]: WebGLUniformLocation;
  39375. };
  39376. /**
  39377. * Binds an effect to the webGL context
  39378. * @param effect defines the effect to bind
  39379. */
  39380. bindSamplers(effect: Effect): void;
  39381. private _activateCurrentTexture;
  39382. /** @hidden */
  39383. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39384. /** @hidden */
  39385. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39386. /**
  39387. * Unbind all textures from the webGL context
  39388. */
  39389. unbindAllTextures(): void;
  39390. /**
  39391. * Sets a texture to the according uniform.
  39392. * @param channel The texture channel
  39393. * @param uniform The uniform to set
  39394. * @param texture The texture to apply
  39395. */
  39396. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39397. private _bindSamplerUniformToChannel;
  39398. private _getTextureWrapMode;
  39399. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39400. /**
  39401. * Sets an array of texture to the webGL context
  39402. * @param channel defines the channel where the texture array must be set
  39403. * @param uniform defines the associated uniform location
  39404. * @param textures defines the array of textures to bind
  39405. */
  39406. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39407. /** @hidden */
  39408. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39409. private _setTextureParameterFloat;
  39410. private _setTextureParameterInteger;
  39411. /**
  39412. * Unbind all vertex attributes from the webGL context
  39413. */
  39414. unbindAllAttributes(): void;
  39415. /**
  39416. * 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
  39417. */
  39418. releaseEffects(): void;
  39419. /**
  39420. * Dispose and release all associated resources
  39421. */
  39422. dispose(): void;
  39423. /**
  39424. * Attach a new callback raised when context lost event is fired
  39425. * @param callback defines the callback to call
  39426. */
  39427. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39428. /**
  39429. * Attach a new callback raised when context restored event is fired
  39430. * @param callback defines the callback to call
  39431. */
  39432. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39433. /**
  39434. * Get the current error code of the webGL context
  39435. * @returns the error code
  39436. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39437. */
  39438. getError(): number;
  39439. private _canRenderToFloatFramebuffer;
  39440. private _canRenderToHalfFloatFramebuffer;
  39441. private _canRenderToFramebuffer;
  39442. /** @hidden */
  39443. _getWebGLTextureType(type: number): number;
  39444. /** @hidden */
  39445. _getInternalFormat(format: number): number;
  39446. /** @hidden */
  39447. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39448. /** @hidden */
  39449. _getRGBAMultiSampleBufferFormat(type: number): number;
  39450. /** @hidden */
  39451. _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;
  39452. /**
  39453. * Loads a file from a url
  39454. * @param url url to load
  39455. * @param onSuccess callback called when the file successfully loads
  39456. * @param onProgress callback called while file is loading (if the server supports this mode)
  39457. * @param offlineProvider defines the offline provider for caching
  39458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39459. * @param onError callback called when the file fails to load
  39460. * @returns a file request object
  39461. * @hidden
  39462. */
  39463. 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;
  39464. /**
  39465. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39466. * @param x defines the x coordinate of the rectangle where pixels must be read
  39467. * @param y defines the y coordinate of the rectangle where pixels must be read
  39468. * @param width defines the width of the rectangle where pixels must be read
  39469. * @param height defines the height of the rectangle where pixels must be read
  39470. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39471. * @returns a Uint8Array containing RGBA colors
  39472. */
  39473. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39474. private static _IsSupported;
  39475. private static _HasMajorPerformanceCaveat;
  39476. /**
  39477. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39478. */
  39479. static get IsSupported(): boolean;
  39480. /**
  39481. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39482. * @returns true if the engine can be created
  39483. * @ignorenaming
  39484. */
  39485. static isSupported(): boolean;
  39486. /**
  39487. * 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)
  39488. */
  39489. static get HasMajorPerformanceCaveat(): boolean;
  39490. /**
  39491. * Find the next highest power of two.
  39492. * @param x Number to start search from.
  39493. * @return Next highest power of two.
  39494. */
  39495. static CeilingPOT(x: number): number;
  39496. /**
  39497. * Find the next lowest power of two.
  39498. * @param x Number to start search from.
  39499. * @return Next lowest power of two.
  39500. */
  39501. static FloorPOT(x: number): number;
  39502. /**
  39503. * Find the nearest power of two.
  39504. * @param x Number to start search from.
  39505. * @return Next nearest power of two.
  39506. */
  39507. static NearestPOT(x: number): number;
  39508. /**
  39509. * Get the closest exponent of two
  39510. * @param value defines the value to approximate
  39511. * @param max defines the maximum value to return
  39512. * @param mode defines how to define the closest value
  39513. * @returns closest exponent of two of the given value
  39514. */
  39515. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39516. /**
  39517. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39518. * @param func - the function to be called
  39519. * @param requester - the object that will request the next frame. Falls back to window.
  39520. * @returns frame number
  39521. */
  39522. static QueueNewFrame(func: () => void, requester?: any): number;
  39523. /**
  39524. * Gets host document
  39525. * @returns the host document object
  39526. */
  39527. getHostDocument(): Nullable<Document>;
  39528. }
  39529. }
  39530. declare module BABYLON {
  39531. /**
  39532. * Defines the source of the internal texture
  39533. */
  39534. export enum InternalTextureSource {
  39535. /**
  39536. * The source of the texture data is unknown
  39537. */
  39538. Unknown = 0,
  39539. /**
  39540. * Texture data comes from an URL
  39541. */
  39542. Url = 1,
  39543. /**
  39544. * Texture data is only used for temporary storage
  39545. */
  39546. Temp = 2,
  39547. /**
  39548. * Texture data comes from raw data (ArrayBuffer)
  39549. */
  39550. Raw = 3,
  39551. /**
  39552. * Texture content is dynamic (video or dynamic texture)
  39553. */
  39554. Dynamic = 4,
  39555. /**
  39556. * Texture content is generated by rendering to it
  39557. */
  39558. RenderTarget = 5,
  39559. /**
  39560. * Texture content is part of a multi render target process
  39561. */
  39562. MultiRenderTarget = 6,
  39563. /**
  39564. * Texture data comes from a cube data file
  39565. */
  39566. Cube = 7,
  39567. /**
  39568. * Texture data comes from a raw cube data
  39569. */
  39570. CubeRaw = 8,
  39571. /**
  39572. * Texture data come from a prefiltered cube data file
  39573. */
  39574. CubePrefiltered = 9,
  39575. /**
  39576. * Texture content is raw 3D data
  39577. */
  39578. Raw3D = 10,
  39579. /**
  39580. * Texture content is raw 2D array data
  39581. */
  39582. Raw2DArray = 11,
  39583. /**
  39584. * Texture content is a depth texture
  39585. */
  39586. Depth = 12,
  39587. /**
  39588. * Texture data comes from a raw cube data encoded with RGBD
  39589. */
  39590. CubeRawRGBD = 13
  39591. }
  39592. /**
  39593. * Class used to store data associated with WebGL texture data for the engine
  39594. * This class should not be used directly
  39595. */
  39596. export class InternalTexture {
  39597. /** @hidden */
  39598. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39599. /**
  39600. * Defines if the texture is ready
  39601. */
  39602. isReady: boolean;
  39603. /**
  39604. * Defines if the texture is a cube texture
  39605. */
  39606. isCube: boolean;
  39607. /**
  39608. * Defines if the texture contains 3D data
  39609. */
  39610. is3D: boolean;
  39611. /**
  39612. * Defines if the texture contains 2D array data
  39613. */
  39614. is2DArray: boolean;
  39615. /**
  39616. * Defines if the texture contains multiview data
  39617. */
  39618. isMultiview: boolean;
  39619. /**
  39620. * Gets the URL used to load this texture
  39621. */
  39622. url: string;
  39623. /**
  39624. * Gets the sampling mode of the texture
  39625. */
  39626. samplingMode: number;
  39627. /**
  39628. * Gets a boolean indicating if the texture needs mipmaps generation
  39629. */
  39630. generateMipMaps: boolean;
  39631. /**
  39632. * Gets the number of samples used by the texture (WebGL2+ only)
  39633. */
  39634. samples: number;
  39635. /**
  39636. * Gets the type of the texture (int, float...)
  39637. */
  39638. type: number;
  39639. /**
  39640. * Gets the format of the texture (RGB, RGBA...)
  39641. */
  39642. format: number;
  39643. /**
  39644. * Observable called when the texture is loaded
  39645. */
  39646. onLoadedObservable: Observable<InternalTexture>;
  39647. /**
  39648. * Gets the width of the texture
  39649. */
  39650. width: number;
  39651. /**
  39652. * Gets the height of the texture
  39653. */
  39654. height: number;
  39655. /**
  39656. * Gets the depth of the texture
  39657. */
  39658. depth: number;
  39659. /**
  39660. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39661. */
  39662. baseWidth: number;
  39663. /**
  39664. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39665. */
  39666. baseHeight: number;
  39667. /**
  39668. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39669. */
  39670. baseDepth: number;
  39671. /**
  39672. * Gets a boolean indicating if the texture is inverted on Y axis
  39673. */
  39674. invertY: boolean;
  39675. /** @hidden */
  39676. _invertVScale: boolean;
  39677. /** @hidden */
  39678. _associatedChannel: number;
  39679. /** @hidden */
  39680. _source: InternalTextureSource;
  39681. /** @hidden */
  39682. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39683. /** @hidden */
  39684. _bufferView: Nullable<ArrayBufferView>;
  39685. /** @hidden */
  39686. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39687. /** @hidden */
  39688. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39689. /** @hidden */
  39690. _size: number;
  39691. /** @hidden */
  39692. _extension: string;
  39693. /** @hidden */
  39694. _files: Nullable<string[]>;
  39695. /** @hidden */
  39696. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39697. /** @hidden */
  39698. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39699. /** @hidden */
  39700. _framebuffer: Nullable<WebGLFramebuffer>;
  39701. /** @hidden */
  39702. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39703. /** @hidden */
  39704. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39705. /** @hidden */
  39706. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39707. /** @hidden */
  39708. _attachments: Nullable<number[]>;
  39709. /** @hidden */
  39710. _textureArray: Nullable<InternalTexture[]>;
  39711. /** @hidden */
  39712. _cachedCoordinatesMode: Nullable<number>;
  39713. /** @hidden */
  39714. _cachedWrapU: Nullable<number>;
  39715. /** @hidden */
  39716. _cachedWrapV: Nullable<number>;
  39717. /** @hidden */
  39718. _cachedWrapR: Nullable<number>;
  39719. /** @hidden */
  39720. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39721. /** @hidden */
  39722. _isDisabled: boolean;
  39723. /** @hidden */
  39724. _compression: Nullable<string>;
  39725. /** @hidden */
  39726. _generateStencilBuffer: boolean;
  39727. /** @hidden */
  39728. _generateDepthBuffer: boolean;
  39729. /** @hidden */
  39730. _comparisonFunction: number;
  39731. /** @hidden */
  39732. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  39733. /** @hidden */
  39734. _lodGenerationScale: number;
  39735. /** @hidden */
  39736. _lodGenerationOffset: number;
  39737. /** @hidden */
  39738. _depthStencilTexture: Nullable<InternalTexture>;
  39739. /** @hidden */
  39740. _colorTextureArray: Nullable<WebGLTexture>;
  39741. /** @hidden */
  39742. _depthStencilTextureArray: Nullable<WebGLTexture>;
  39743. /** @hidden */
  39744. _lodTextureHigh: Nullable<BaseTexture>;
  39745. /** @hidden */
  39746. _lodTextureMid: Nullable<BaseTexture>;
  39747. /** @hidden */
  39748. _lodTextureLow: Nullable<BaseTexture>;
  39749. /** @hidden */
  39750. _isRGBD: boolean;
  39751. /** @hidden */
  39752. _linearSpecularLOD: boolean;
  39753. /** @hidden */
  39754. _irradianceTexture: Nullable<BaseTexture>;
  39755. /** @hidden */
  39756. _webGLTexture: Nullable<WebGLTexture>;
  39757. /** @hidden */
  39758. _references: number;
  39759. /** @hidden */
  39760. _gammaSpace: Nullable<boolean>;
  39761. private _engine;
  39762. /**
  39763. * Gets the Engine the texture belongs to.
  39764. * @returns The babylon engine
  39765. */
  39766. getEngine(): ThinEngine;
  39767. /**
  39768. * Gets the data source type of the texture
  39769. */
  39770. get source(): InternalTextureSource;
  39771. /**
  39772. * Creates a new InternalTexture
  39773. * @param engine defines the engine to use
  39774. * @param source defines the type of data that will be used
  39775. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39776. */
  39777. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  39778. /**
  39779. * Increments the number of references (ie. the number of Texture that point to it)
  39780. */
  39781. incrementReferences(): void;
  39782. /**
  39783. * Change the size of the texture (not the size of the content)
  39784. * @param width defines the new width
  39785. * @param height defines the new height
  39786. * @param depth defines the new depth (1 by default)
  39787. */
  39788. updateSize(width: int, height: int, depth?: int): void;
  39789. /** @hidden */
  39790. _rebuild(): void;
  39791. /** @hidden */
  39792. _swapAndDie(target: InternalTexture): void;
  39793. /**
  39794. * Dispose the current allocated resources
  39795. */
  39796. dispose(): void;
  39797. }
  39798. }
  39799. declare module BABYLON {
  39800. /**
  39801. * Class used to work with sound analyzer using fast fourier transform (FFT)
  39802. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39803. */
  39804. export class Analyser {
  39805. /**
  39806. * Gets or sets the smoothing
  39807. * @ignorenaming
  39808. */
  39809. SMOOTHING: number;
  39810. /**
  39811. * Gets or sets the FFT table size
  39812. * @ignorenaming
  39813. */
  39814. FFT_SIZE: number;
  39815. /**
  39816. * Gets or sets the bar graph amplitude
  39817. * @ignorenaming
  39818. */
  39819. BARGRAPHAMPLITUDE: number;
  39820. /**
  39821. * Gets or sets the position of the debug canvas
  39822. * @ignorenaming
  39823. */
  39824. DEBUGCANVASPOS: {
  39825. x: number;
  39826. y: number;
  39827. };
  39828. /**
  39829. * Gets or sets the debug canvas size
  39830. * @ignorenaming
  39831. */
  39832. DEBUGCANVASSIZE: {
  39833. width: number;
  39834. height: number;
  39835. };
  39836. private _byteFreqs;
  39837. private _byteTime;
  39838. private _floatFreqs;
  39839. private _webAudioAnalyser;
  39840. private _debugCanvas;
  39841. private _debugCanvasContext;
  39842. private _scene;
  39843. private _registerFunc;
  39844. private _audioEngine;
  39845. /**
  39846. * Creates a new analyser
  39847. * @param scene defines hosting scene
  39848. */
  39849. constructor(scene: Scene);
  39850. /**
  39851. * Get the number of data values you will have to play with for the visualization
  39852. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  39853. * @returns a number
  39854. */
  39855. getFrequencyBinCount(): number;
  39856. /**
  39857. * Gets the current frequency data as a byte array
  39858. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39859. * @returns a Uint8Array
  39860. */
  39861. getByteFrequencyData(): Uint8Array;
  39862. /**
  39863. * Gets the current waveform as a byte array
  39864. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  39865. * @returns a Uint8Array
  39866. */
  39867. getByteTimeDomainData(): Uint8Array;
  39868. /**
  39869. * Gets the current frequency data as a float array
  39870. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39871. * @returns a Float32Array
  39872. */
  39873. getFloatFrequencyData(): Float32Array;
  39874. /**
  39875. * Renders the debug canvas
  39876. */
  39877. drawDebugCanvas(): void;
  39878. /**
  39879. * Stops rendering the debug canvas and removes it
  39880. */
  39881. stopDebugCanvas(): void;
  39882. /**
  39883. * Connects two audio nodes
  39884. * @param inputAudioNode defines first node to connect
  39885. * @param outputAudioNode defines second node to connect
  39886. */
  39887. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  39888. /**
  39889. * Releases all associated resources
  39890. */
  39891. dispose(): void;
  39892. }
  39893. }
  39894. declare module BABYLON {
  39895. /**
  39896. * This represents an audio engine and it is responsible
  39897. * to play, synchronize and analyse sounds throughout the application.
  39898. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39899. */
  39900. export interface IAudioEngine extends IDisposable {
  39901. /**
  39902. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39903. */
  39904. readonly canUseWebAudio: boolean;
  39905. /**
  39906. * Gets the current AudioContext if available.
  39907. */
  39908. readonly audioContext: Nullable<AudioContext>;
  39909. /**
  39910. * The master gain node defines the global audio volume of your audio engine.
  39911. */
  39912. readonly masterGain: GainNode;
  39913. /**
  39914. * Gets whether or not mp3 are supported by your browser.
  39915. */
  39916. readonly isMP3supported: boolean;
  39917. /**
  39918. * Gets whether or not ogg are supported by your browser.
  39919. */
  39920. readonly isOGGsupported: boolean;
  39921. /**
  39922. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39923. * @ignoreNaming
  39924. */
  39925. WarnedWebAudioUnsupported: boolean;
  39926. /**
  39927. * Defines if the audio engine relies on a custom unlocked button.
  39928. * In this case, the embedded button will not be displayed.
  39929. */
  39930. useCustomUnlockedButton: boolean;
  39931. /**
  39932. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  39933. */
  39934. readonly unlocked: boolean;
  39935. /**
  39936. * Event raised when audio has been unlocked on the browser.
  39937. */
  39938. onAudioUnlockedObservable: Observable<AudioEngine>;
  39939. /**
  39940. * Event raised when audio has been locked on the browser.
  39941. */
  39942. onAudioLockedObservable: Observable<AudioEngine>;
  39943. /**
  39944. * Flags the audio engine in Locked state.
  39945. * This happens due to new browser policies preventing audio to autoplay.
  39946. */
  39947. lock(): void;
  39948. /**
  39949. * Unlocks the audio engine once a user action has been done on the dom.
  39950. * This is helpful to resume play once browser policies have been satisfied.
  39951. */
  39952. unlock(): void;
  39953. /**
  39954. * Gets the global volume sets on the master gain.
  39955. * @returns the global volume if set or -1 otherwise
  39956. */
  39957. getGlobalVolume(): number;
  39958. /**
  39959. * Sets the global volume of your experience (sets on the master gain).
  39960. * @param newVolume Defines the new global volume of the application
  39961. */
  39962. setGlobalVolume(newVolume: number): void;
  39963. /**
  39964. * Connect the audio engine to an audio analyser allowing some amazing
  39965. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39966. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39967. * @param analyser The analyser to connect to the engine
  39968. */
  39969. connectToAnalyser(analyser: Analyser): void;
  39970. }
  39971. /**
  39972. * This represents the default audio engine used in babylon.
  39973. * It is responsible to play, synchronize and analyse sounds throughout the application.
  39974. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39975. */
  39976. export class AudioEngine implements IAudioEngine {
  39977. private _audioContext;
  39978. private _audioContextInitialized;
  39979. private _muteButton;
  39980. private _hostElement;
  39981. /**
  39982. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39983. */
  39984. canUseWebAudio: boolean;
  39985. /**
  39986. * The master gain node defines the global audio volume of your audio engine.
  39987. */
  39988. masterGain: GainNode;
  39989. /**
  39990. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39991. * @ignoreNaming
  39992. */
  39993. WarnedWebAudioUnsupported: boolean;
  39994. /**
  39995. * Gets whether or not mp3 are supported by your browser.
  39996. */
  39997. isMP3supported: boolean;
  39998. /**
  39999. * Gets whether or not ogg are supported by your browser.
  40000. */
  40001. isOGGsupported: boolean;
  40002. /**
  40003. * Gets whether audio has been unlocked on the device.
  40004. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  40005. * a user interaction has happened.
  40006. */
  40007. unlocked: boolean;
  40008. /**
  40009. * Defines if the audio engine relies on a custom unlocked button.
  40010. * In this case, the embedded button will not be displayed.
  40011. */
  40012. useCustomUnlockedButton: boolean;
  40013. /**
  40014. * Event raised when audio has been unlocked on the browser.
  40015. */
  40016. onAudioUnlockedObservable: Observable<AudioEngine>;
  40017. /**
  40018. * Event raised when audio has been locked on the browser.
  40019. */
  40020. onAudioLockedObservable: Observable<AudioEngine>;
  40021. /**
  40022. * Gets the current AudioContext if available.
  40023. */
  40024. get audioContext(): Nullable<AudioContext>;
  40025. private _connectedAnalyser;
  40026. /**
  40027. * Instantiates a new audio engine.
  40028. *
  40029. * There should be only one per page as some browsers restrict the number
  40030. * of audio contexts you can create.
  40031. * @param hostElement defines the host element where to display the mute icon if necessary
  40032. */
  40033. constructor(hostElement?: Nullable<HTMLElement>);
  40034. /**
  40035. * Flags the audio engine in Locked state.
  40036. * This happens due to new browser policies preventing audio to autoplay.
  40037. */
  40038. lock(): void;
  40039. /**
  40040. * Unlocks the audio engine once a user action has been done on the dom.
  40041. * This is helpful to resume play once browser policies have been satisfied.
  40042. */
  40043. unlock(): void;
  40044. private _resumeAudioContext;
  40045. private _initializeAudioContext;
  40046. private _tryToRun;
  40047. private _triggerRunningState;
  40048. private _triggerSuspendedState;
  40049. private _displayMuteButton;
  40050. private _moveButtonToTopLeft;
  40051. private _onResize;
  40052. private _hideMuteButton;
  40053. /**
  40054. * Destroy and release the resources associated with the audio ccontext.
  40055. */
  40056. dispose(): void;
  40057. /**
  40058. * Gets the global volume sets on the master gain.
  40059. * @returns the global volume if set or -1 otherwise
  40060. */
  40061. getGlobalVolume(): number;
  40062. /**
  40063. * Sets the global volume of your experience (sets on the master gain).
  40064. * @param newVolume Defines the new global volume of the application
  40065. */
  40066. setGlobalVolume(newVolume: number): void;
  40067. /**
  40068. * Connect the audio engine to an audio analyser allowing some amazing
  40069. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40071. * @param analyser The analyser to connect to the engine
  40072. */
  40073. connectToAnalyser(analyser: Analyser): void;
  40074. }
  40075. }
  40076. declare module BABYLON {
  40077. /**
  40078. * Interface used to present a loading screen while loading a scene
  40079. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40080. */
  40081. export interface ILoadingScreen {
  40082. /**
  40083. * Function called to display the loading screen
  40084. */
  40085. displayLoadingUI: () => void;
  40086. /**
  40087. * Function called to hide the loading screen
  40088. */
  40089. hideLoadingUI: () => void;
  40090. /**
  40091. * Gets or sets the color to use for the background
  40092. */
  40093. loadingUIBackgroundColor: string;
  40094. /**
  40095. * Gets or sets the text to display while loading
  40096. */
  40097. loadingUIText: string;
  40098. }
  40099. /**
  40100. * Class used for the default loading screen
  40101. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40102. */
  40103. export class DefaultLoadingScreen implements ILoadingScreen {
  40104. private _renderingCanvas;
  40105. private _loadingText;
  40106. private _loadingDivBackgroundColor;
  40107. private _loadingDiv;
  40108. private _loadingTextDiv;
  40109. /** Gets or sets the logo url to use for the default loading screen */
  40110. static DefaultLogoUrl: string;
  40111. /** Gets or sets the spinner url to use for the default loading screen */
  40112. static DefaultSpinnerUrl: string;
  40113. /**
  40114. * Creates a new default loading screen
  40115. * @param _renderingCanvas defines the canvas used to render the scene
  40116. * @param _loadingText defines the default text to display
  40117. * @param _loadingDivBackgroundColor defines the default background color
  40118. */
  40119. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40120. /**
  40121. * Function called to display the loading screen
  40122. */
  40123. displayLoadingUI(): void;
  40124. /**
  40125. * Function called to hide the loading screen
  40126. */
  40127. hideLoadingUI(): void;
  40128. /**
  40129. * Gets or sets the text to display while loading
  40130. */
  40131. set loadingUIText(text: string);
  40132. get loadingUIText(): string;
  40133. /**
  40134. * Gets or sets the color to use for the background
  40135. */
  40136. get loadingUIBackgroundColor(): string;
  40137. set loadingUIBackgroundColor(color: string);
  40138. private _resizeLoadingUI;
  40139. }
  40140. }
  40141. declare module BABYLON {
  40142. /**
  40143. * Interface for any object that can request an animation frame
  40144. */
  40145. export interface ICustomAnimationFrameRequester {
  40146. /**
  40147. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40148. */
  40149. renderFunction?: Function;
  40150. /**
  40151. * Called to request the next frame to render to
  40152. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40153. */
  40154. requestAnimationFrame: Function;
  40155. /**
  40156. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40157. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40158. */
  40159. requestID?: number;
  40160. }
  40161. }
  40162. declare module BABYLON {
  40163. /**
  40164. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40165. */
  40166. export class PerformanceMonitor {
  40167. private _enabled;
  40168. private _rollingFrameTime;
  40169. private _lastFrameTimeMs;
  40170. /**
  40171. * constructor
  40172. * @param frameSampleSize The number of samples required to saturate the sliding window
  40173. */
  40174. constructor(frameSampleSize?: number);
  40175. /**
  40176. * Samples current frame
  40177. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40178. */
  40179. sampleFrame(timeMs?: number): void;
  40180. /**
  40181. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40182. */
  40183. get averageFrameTime(): number;
  40184. /**
  40185. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40186. */
  40187. get averageFrameTimeVariance(): number;
  40188. /**
  40189. * Returns the frame time of the most recent frame
  40190. */
  40191. get instantaneousFrameTime(): number;
  40192. /**
  40193. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40194. */
  40195. get averageFPS(): number;
  40196. /**
  40197. * Returns the average framerate in frames per second using the most recent frame time
  40198. */
  40199. get instantaneousFPS(): number;
  40200. /**
  40201. * Returns true if enough samples have been taken to completely fill the sliding window
  40202. */
  40203. get isSaturated(): boolean;
  40204. /**
  40205. * Enables contributions to the sliding window sample set
  40206. */
  40207. enable(): void;
  40208. /**
  40209. * Disables contributions to the sliding window sample set
  40210. * Samples will not be interpolated over the disabled period
  40211. */
  40212. disable(): void;
  40213. /**
  40214. * Returns true if sampling is enabled
  40215. */
  40216. get isEnabled(): boolean;
  40217. /**
  40218. * Resets performance monitor
  40219. */
  40220. reset(): void;
  40221. }
  40222. /**
  40223. * RollingAverage
  40224. *
  40225. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40226. */
  40227. export class RollingAverage {
  40228. /**
  40229. * Current average
  40230. */
  40231. average: number;
  40232. /**
  40233. * Current variance
  40234. */
  40235. variance: number;
  40236. protected _samples: Array<number>;
  40237. protected _sampleCount: number;
  40238. protected _pos: number;
  40239. protected _m2: number;
  40240. /**
  40241. * constructor
  40242. * @param length The number of samples required to saturate the sliding window
  40243. */
  40244. constructor(length: number);
  40245. /**
  40246. * Adds a sample to the sample set
  40247. * @param v The sample value
  40248. */
  40249. add(v: number): void;
  40250. /**
  40251. * Returns previously added values or null if outside of history or outside the sliding window domain
  40252. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40253. * @return Value previously recorded with add() or null if outside of range
  40254. */
  40255. history(i: number): number;
  40256. /**
  40257. * Returns true if enough samples have been taken to completely fill the sliding window
  40258. * @return true if sample-set saturated
  40259. */
  40260. isSaturated(): boolean;
  40261. /**
  40262. * Resets the rolling average (equivalent to 0 samples taken so far)
  40263. */
  40264. reset(): void;
  40265. /**
  40266. * Wraps a value around the sample range boundaries
  40267. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40268. * @return Wrapped position in sample range
  40269. */
  40270. protected _wrapPosition(i: number): number;
  40271. }
  40272. }
  40273. declare module BABYLON {
  40274. /**
  40275. * This class is used to track a performance counter which is number based.
  40276. * The user has access to many properties which give statistics of different nature.
  40277. *
  40278. * The implementer can track two kinds of Performance Counter: time and count.
  40279. * 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.
  40280. * 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.
  40281. */
  40282. export class PerfCounter {
  40283. /**
  40284. * Gets or sets a global boolean to turn on and off all the counters
  40285. */
  40286. static Enabled: boolean;
  40287. /**
  40288. * Returns the smallest value ever
  40289. */
  40290. get min(): number;
  40291. /**
  40292. * Returns the biggest value ever
  40293. */
  40294. get max(): number;
  40295. /**
  40296. * Returns the average value since the performance counter is running
  40297. */
  40298. get average(): number;
  40299. /**
  40300. * Returns the average value of the last second the counter was monitored
  40301. */
  40302. get lastSecAverage(): number;
  40303. /**
  40304. * Returns the current value
  40305. */
  40306. get current(): number;
  40307. /**
  40308. * Gets the accumulated total
  40309. */
  40310. get total(): number;
  40311. /**
  40312. * Gets the total value count
  40313. */
  40314. get count(): number;
  40315. /**
  40316. * Creates a new counter
  40317. */
  40318. constructor();
  40319. /**
  40320. * Call this method to start monitoring a new frame.
  40321. * 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.
  40322. */
  40323. fetchNewFrame(): void;
  40324. /**
  40325. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40326. * @param newCount the count value to add to the monitored count
  40327. * @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.
  40328. */
  40329. addCount(newCount: number, fetchResult: boolean): void;
  40330. /**
  40331. * Start monitoring this performance counter
  40332. */
  40333. beginMonitoring(): void;
  40334. /**
  40335. * Compute the time lapsed since the previous beginMonitoring() call.
  40336. * @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
  40337. */
  40338. endMonitoring(newFrame?: boolean): void;
  40339. private _fetchResult;
  40340. private _startMonitoringTime;
  40341. private _min;
  40342. private _max;
  40343. private _average;
  40344. private _current;
  40345. private _totalValueCount;
  40346. private _totalAccumulated;
  40347. private _lastSecAverage;
  40348. private _lastSecAccumulated;
  40349. private _lastSecTime;
  40350. private _lastSecValueCount;
  40351. }
  40352. }
  40353. declare module BABYLON {
  40354. interface ThinEngine {
  40355. /** @hidden */
  40356. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40357. }
  40358. }
  40359. declare module BABYLON {
  40360. /**
  40361. * Defines the interface used by display changed events
  40362. */
  40363. export interface IDisplayChangedEventArgs {
  40364. /** Gets the vrDisplay object (if any) */
  40365. vrDisplay: Nullable<any>;
  40366. /** Gets a boolean indicating if webVR is supported */
  40367. vrSupported: boolean;
  40368. }
  40369. /**
  40370. * Defines the interface used by objects containing a viewport (like a camera)
  40371. */
  40372. interface IViewportOwnerLike {
  40373. /**
  40374. * Gets or sets the viewport
  40375. */
  40376. viewport: IViewportLike;
  40377. }
  40378. /**
  40379. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40380. */
  40381. export class Engine extends ThinEngine {
  40382. /** Defines that alpha blending is disabled */
  40383. static readonly ALPHA_DISABLE: number;
  40384. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40385. static readonly ALPHA_ADD: number;
  40386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40387. static readonly ALPHA_COMBINE: number;
  40388. /** Defines that alpha blending to DEST - SRC * DEST */
  40389. static readonly ALPHA_SUBTRACT: number;
  40390. /** Defines that alpha blending to SRC * DEST */
  40391. static readonly ALPHA_MULTIPLY: number;
  40392. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40393. static readonly ALPHA_MAXIMIZED: number;
  40394. /** Defines that alpha blending to SRC + DEST */
  40395. static readonly ALPHA_ONEONE: number;
  40396. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40397. static readonly ALPHA_PREMULTIPLIED: number;
  40398. /**
  40399. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40400. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40401. */
  40402. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40403. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40404. static readonly ALPHA_INTERPOLATE: number;
  40405. /**
  40406. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40407. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40408. */
  40409. static readonly ALPHA_SCREENMODE: number;
  40410. /** Defines that the ressource is not delayed*/
  40411. static readonly DELAYLOADSTATE_NONE: number;
  40412. /** Defines that the ressource was successfully delay loaded */
  40413. static readonly DELAYLOADSTATE_LOADED: number;
  40414. /** Defines that the ressource is currently delay loading */
  40415. static readonly DELAYLOADSTATE_LOADING: number;
  40416. /** Defines that the ressource is delayed and has not started loading */
  40417. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40419. static readonly NEVER: number;
  40420. /** 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 */
  40421. static readonly ALWAYS: number;
  40422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40423. static readonly LESS: number;
  40424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40425. static readonly EQUAL: number;
  40426. /** 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 */
  40427. static readonly LEQUAL: number;
  40428. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40429. static readonly GREATER: number;
  40430. /** 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 */
  40431. static readonly GEQUAL: number;
  40432. /** 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 */
  40433. static readonly NOTEQUAL: number;
  40434. /** Passed to stencilOperation to specify that stencil value must be kept */
  40435. static readonly KEEP: number;
  40436. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40437. static readonly REPLACE: number;
  40438. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40439. static readonly INCR: number;
  40440. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40441. static readonly DECR: number;
  40442. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40443. static readonly INVERT: number;
  40444. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40445. static readonly INCR_WRAP: number;
  40446. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40447. static readonly DECR_WRAP: number;
  40448. /** Texture is not repeating outside of 0..1 UVs */
  40449. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40450. /** Texture is repeating outside of 0..1 UVs */
  40451. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40452. /** Texture is repeating and mirrored */
  40453. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40454. /** ALPHA */
  40455. static readonly TEXTUREFORMAT_ALPHA: number;
  40456. /** LUMINANCE */
  40457. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40458. /** LUMINANCE_ALPHA */
  40459. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40460. /** RGB */
  40461. static readonly TEXTUREFORMAT_RGB: number;
  40462. /** RGBA */
  40463. static readonly TEXTUREFORMAT_RGBA: number;
  40464. /** RED */
  40465. static readonly TEXTUREFORMAT_RED: number;
  40466. /** RED (2nd reference) */
  40467. static readonly TEXTUREFORMAT_R: number;
  40468. /** RG */
  40469. static readonly TEXTUREFORMAT_RG: number;
  40470. /** RED_INTEGER */
  40471. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40472. /** RED_INTEGER (2nd reference) */
  40473. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40474. /** RG_INTEGER */
  40475. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40476. /** RGB_INTEGER */
  40477. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40478. /** RGBA_INTEGER */
  40479. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40480. /** UNSIGNED_BYTE */
  40481. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40482. /** UNSIGNED_BYTE (2nd reference) */
  40483. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40484. /** FLOAT */
  40485. static readonly TEXTURETYPE_FLOAT: number;
  40486. /** HALF_FLOAT */
  40487. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40488. /** BYTE */
  40489. static readonly TEXTURETYPE_BYTE: number;
  40490. /** SHORT */
  40491. static readonly TEXTURETYPE_SHORT: number;
  40492. /** UNSIGNED_SHORT */
  40493. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40494. /** INT */
  40495. static readonly TEXTURETYPE_INT: number;
  40496. /** UNSIGNED_INT */
  40497. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40498. /** UNSIGNED_SHORT_4_4_4_4 */
  40499. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40500. /** UNSIGNED_SHORT_5_5_5_1 */
  40501. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40502. /** UNSIGNED_SHORT_5_6_5 */
  40503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40504. /** UNSIGNED_INT_2_10_10_10_REV */
  40505. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40506. /** UNSIGNED_INT_24_8 */
  40507. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40508. /** UNSIGNED_INT_10F_11F_11F_REV */
  40509. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40510. /** UNSIGNED_INT_5_9_9_9_REV */
  40511. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40512. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40513. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40514. /** nearest is mag = nearest and min = nearest and mip = linear */
  40515. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40517. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40518. /** Trilinear is mag = linear and min = linear and mip = linear */
  40519. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40520. /** nearest is mag = nearest and min = nearest and mip = linear */
  40521. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40523. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40524. /** Trilinear is mag = linear and min = linear and mip = linear */
  40525. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40526. /** mag = nearest and min = nearest and mip = nearest */
  40527. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40528. /** mag = nearest and min = linear and mip = nearest */
  40529. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40530. /** mag = nearest and min = linear and mip = linear */
  40531. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40532. /** mag = nearest and min = linear and mip = none */
  40533. static readonly TEXTURE_NEAREST_LINEAR: number;
  40534. /** mag = nearest and min = nearest and mip = none */
  40535. static readonly TEXTURE_NEAREST_NEAREST: number;
  40536. /** mag = linear and min = nearest and mip = nearest */
  40537. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40538. /** mag = linear and min = nearest and mip = linear */
  40539. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40540. /** mag = linear and min = linear and mip = none */
  40541. static readonly TEXTURE_LINEAR_LINEAR: number;
  40542. /** mag = linear and min = nearest and mip = none */
  40543. static readonly TEXTURE_LINEAR_NEAREST: number;
  40544. /** Explicit coordinates mode */
  40545. static readonly TEXTURE_EXPLICIT_MODE: number;
  40546. /** Spherical coordinates mode */
  40547. static readonly TEXTURE_SPHERICAL_MODE: number;
  40548. /** Planar coordinates mode */
  40549. static readonly TEXTURE_PLANAR_MODE: number;
  40550. /** Cubic coordinates mode */
  40551. static readonly TEXTURE_CUBIC_MODE: number;
  40552. /** Projection coordinates mode */
  40553. static readonly TEXTURE_PROJECTION_MODE: number;
  40554. /** Skybox coordinates mode */
  40555. static readonly TEXTURE_SKYBOX_MODE: number;
  40556. /** Inverse Cubic coordinates mode */
  40557. static readonly TEXTURE_INVCUBIC_MODE: number;
  40558. /** Equirectangular coordinates mode */
  40559. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40560. /** Equirectangular Fixed coordinates mode */
  40561. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40562. /** Equirectangular Fixed Mirrored coordinates mode */
  40563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40564. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40565. static readonly SCALEMODE_FLOOR: number;
  40566. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40567. static readonly SCALEMODE_NEAREST: number;
  40568. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40569. static readonly SCALEMODE_CEILING: number;
  40570. /**
  40571. * Returns the current npm package of the sdk
  40572. */
  40573. static get NpmPackage(): string;
  40574. /**
  40575. * Returns the current version of the framework
  40576. */
  40577. static get Version(): string;
  40578. /** Gets the list of created engines */
  40579. static get Instances(): Engine[];
  40580. /**
  40581. * Gets the latest created engine
  40582. */
  40583. static get LastCreatedEngine(): Nullable<Engine>;
  40584. /**
  40585. * Gets the latest created scene
  40586. */
  40587. static get LastCreatedScene(): Nullable<Scene>;
  40588. /**
  40589. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40590. * @param flag defines which part of the materials must be marked as dirty
  40591. * @param predicate defines a predicate used to filter which materials should be affected
  40592. */
  40593. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40594. /**
  40595. * Method called to create the default loading screen.
  40596. * This can be overriden in your own app.
  40597. * @param canvas The rendering canvas element
  40598. * @returns The loading screen
  40599. */
  40600. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40601. /**
  40602. * Method called to create the default rescale post process on each engine.
  40603. */
  40604. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40605. /**
  40606. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40607. **/
  40608. enableOfflineSupport: boolean;
  40609. /**
  40610. * 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)
  40611. **/
  40612. disableManifestCheck: boolean;
  40613. /**
  40614. * Gets the list of created scenes
  40615. */
  40616. scenes: Scene[];
  40617. /**
  40618. * Event raised when a new scene is created
  40619. */
  40620. onNewSceneAddedObservable: Observable<Scene>;
  40621. /**
  40622. * Gets the list of created postprocesses
  40623. */
  40624. postProcesses: PostProcess[];
  40625. /**
  40626. * Gets a boolean indicating if the pointer is currently locked
  40627. */
  40628. isPointerLock: boolean;
  40629. /**
  40630. * Observable event triggered each time the rendering canvas is resized
  40631. */
  40632. onResizeObservable: Observable<Engine>;
  40633. /**
  40634. * Observable event triggered each time the canvas loses focus
  40635. */
  40636. onCanvasBlurObservable: Observable<Engine>;
  40637. /**
  40638. * Observable event triggered each time the canvas gains focus
  40639. */
  40640. onCanvasFocusObservable: Observable<Engine>;
  40641. /**
  40642. * Observable event triggered each time the canvas receives pointerout event
  40643. */
  40644. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40645. /**
  40646. * Observable raised when the engine begins a new frame
  40647. */
  40648. onBeginFrameObservable: Observable<Engine>;
  40649. /**
  40650. * If set, will be used to request the next animation frame for the render loop
  40651. */
  40652. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40653. /**
  40654. * Observable raised when the engine ends the current frame
  40655. */
  40656. onEndFrameObservable: Observable<Engine>;
  40657. /**
  40658. * Observable raised when the engine is about to compile a shader
  40659. */
  40660. onBeforeShaderCompilationObservable: Observable<Engine>;
  40661. /**
  40662. * Observable raised when the engine has jsut compiled a shader
  40663. */
  40664. onAfterShaderCompilationObservable: Observable<Engine>;
  40665. /**
  40666. * Gets the audio engine
  40667. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40668. * @ignorenaming
  40669. */
  40670. static audioEngine: IAudioEngine;
  40671. /**
  40672. * Default AudioEngine factory responsible of creating the Audio Engine.
  40673. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40674. */
  40675. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40676. /**
  40677. * Default offline support factory responsible of creating a tool used to store data locally.
  40678. * By default, this will create a Database object if the workload has been embedded.
  40679. */
  40680. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40681. private _loadingScreen;
  40682. private _pointerLockRequested;
  40683. private _rescalePostProcess;
  40684. private _deterministicLockstep;
  40685. private _lockstepMaxSteps;
  40686. private _timeStep;
  40687. protected get _supportsHardwareTextureRescaling(): boolean;
  40688. private _fps;
  40689. private _deltaTime;
  40690. /** @hidden */
  40691. _drawCalls: PerfCounter;
  40692. /** 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 */
  40693. canvasTabIndex: number;
  40694. /**
  40695. * Turn this value on if you want to pause FPS computation when in background
  40696. */
  40697. disablePerformanceMonitorInBackground: boolean;
  40698. private _performanceMonitor;
  40699. /**
  40700. * Gets the performance monitor attached to this engine
  40701. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40702. */
  40703. get performanceMonitor(): PerformanceMonitor;
  40704. private _onFocus;
  40705. private _onBlur;
  40706. private _onCanvasPointerOut;
  40707. private _onCanvasBlur;
  40708. private _onCanvasFocus;
  40709. private _onFullscreenChange;
  40710. private _onPointerLockChange;
  40711. /**
  40712. * Gets the HTML element used to attach event listeners
  40713. * @returns a HTML element
  40714. */
  40715. getInputElement(): Nullable<HTMLElement>;
  40716. /**
  40717. * Creates a new engine
  40718. * @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
  40719. * @param antialias defines enable antialiasing (default: false)
  40720. * @param options defines further options to be sent to the getContext() function
  40721. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40722. */
  40723. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40724. /**
  40725. * Gets current aspect ratio
  40726. * @param viewportOwner defines the camera to use to get the aspect ratio
  40727. * @param useScreen defines if screen size must be used (or the current render target if any)
  40728. * @returns a number defining the aspect ratio
  40729. */
  40730. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40731. /**
  40732. * Gets current screen aspect ratio
  40733. * @returns a number defining the aspect ratio
  40734. */
  40735. getScreenAspectRatio(): number;
  40736. /**
  40737. * Gets the client rect of the HTML canvas attached with the current webGL context
  40738. * @returns a client rectanglee
  40739. */
  40740. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40741. /**
  40742. * Gets the client rect of the HTML element used for events
  40743. * @returns a client rectanglee
  40744. */
  40745. getInputElementClientRect(): Nullable<ClientRect>;
  40746. /**
  40747. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40748. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40749. * @returns true if engine is in deterministic lock step mode
  40750. */
  40751. isDeterministicLockStep(): boolean;
  40752. /**
  40753. * Gets the max steps when engine is running in deterministic lock step
  40754. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40755. * @returns the max steps
  40756. */
  40757. getLockstepMaxSteps(): number;
  40758. /**
  40759. * Returns the time in ms between steps when using deterministic lock step.
  40760. * @returns time step in (ms)
  40761. */
  40762. getTimeStep(): number;
  40763. /**
  40764. * Force the mipmap generation for the given render target texture
  40765. * @param texture defines the render target texture to use
  40766. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40767. */
  40768. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40769. /** States */
  40770. /**
  40771. * Set various states to the webGL context
  40772. * @param culling defines backface culling state
  40773. * @param zOffset defines the value to apply to zOffset (0 by default)
  40774. * @param force defines if states must be applied even if cache is up to date
  40775. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40776. */
  40777. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40778. /**
  40779. * Set the z offset to apply to current rendering
  40780. * @param value defines the offset to apply
  40781. */
  40782. setZOffset(value: number): void;
  40783. /**
  40784. * Gets the current value of the zOffset
  40785. * @returns the current zOffset state
  40786. */
  40787. getZOffset(): number;
  40788. /**
  40789. * Enable or disable depth buffering
  40790. * @param enable defines the state to set
  40791. */
  40792. setDepthBuffer(enable: boolean): void;
  40793. /**
  40794. * Gets a boolean indicating if depth writing is enabled
  40795. * @returns the current depth writing state
  40796. */
  40797. getDepthWrite(): boolean;
  40798. /**
  40799. * Enable or disable depth writing
  40800. * @param enable defines the state to set
  40801. */
  40802. setDepthWrite(enable: boolean): void;
  40803. /**
  40804. * Gets a boolean indicating if stencil buffer is enabled
  40805. * @returns the current stencil buffer state
  40806. */
  40807. getStencilBuffer(): boolean;
  40808. /**
  40809. * Enable or disable the stencil buffer
  40810. * @param enable defines if the stencil buffer must be enabled or disabled
  40811. */
  40812. setStencilBuffer(enable: boolean): void;
  40813. /**
  40814. * Gets the current stencil mask
  40815. * @returns a number defining the new stencil mask to use
  40816. */
  40817. getStencilMask(): number;
  40818. /**
  40819. * Sets the current stencil mask
  40820. * @param mask defines the new stencil mask to use
  40821. */
  40822. setStencilMask(mask: number): void;
  40823. /**
  40824. * Gets the current stencil function
  40825. * @returns a number defining the stencil function to use
  40826. */
  40827. getStencilFunction(): number;
  40828. /**
  40829. * Gets the current stencil reference value
  40830. * @returns a number defining the stencil reference value to use
  40831. */
  40832. getStencilFunctionReference(): number;
  40833. /**
  40834. * Gets the current stencil mask
  40835. * @returns a number defining the stencil mask to use
  40836. */
  40837. getStencilFunctionMask(): number;
  40838. /**
  40839. * Sets the current stencil function
  40840. * @param stencilFunc defines the new stencil function to use
  40841. */
  40842. setStencilFunction(stencilFunc: number): void;
  40843. /**
  40844. * Sets the current stencil reference
  40845. * @param reference defines the new stencil reference to use
  40846. */
  40847. setStencilFunctionReference(reference: number): void;
  40848. /**
  40849. * Sets the current stencil mask
  40850. * @param mask defines the new stencil mask to use
  40851. */
  40852. setStencilFunctionMask(mask: number): void;
  40853. /**
  40854. * Gets the current stencil operation when stencil fails
  40855. * @returns a number defining stencil operation to use when stencil fails
  40856. */
  40857. getStencilOperationFail(): number;
  40858. /**
  40859. * Gets the current stencil operation when depth fails
  40860. * @returns a number defining stencil operation to use when depth fails
  40861. */
  40862. getStencilOperationDepthFail(): number;
  40863. /**
  40864. * Gets the current stencil operation when stencil passes
  40865. * @returns a number defining stencil operation to use when stencil passes
  40866. */
  40867. getStencilOperationPass(): number;
  40868. /**
  40869. * Sets the stencil operation to use when stencil fails
  40870. * @param operation defines the stencil operation to use when stencil fails
  40871. */
  40872. setStencilOperationFail(operation: number): void;
  40873. /**
  40874. * Sets the stencil operation to use when depth fails
  40875. * @param operation defines the stencil operation to use when depth fails
  40876. */
  40877. setStencilOperationDepthFail(operation: number): void;
  40878. /**
  40879. * Sets the stencil operation to use when stencil passes
  40880. * @param operation defines the stencil operation to use when stencil passes
  40881. */
  40882. setStencilOperationPass(operation: number): void;
  40883. /**
  40884. * Sets a boolean indicating if the dithering state is enabled or disabled
  40885. * @param value defines the dithering state
  40886. */
  40887. setDitheringState(value: boolean): void;
  40888. /**
  40889. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  40890. * @param value defines the rasterizer state
  40891. */
  40892. setRasterizerState(value: boolean): void;
  40893. /**
  40894. * Gets the current depth function
  40895. * @returns a number defining the depth function
  40896. */
  40897. getDepthFunction(): Nullable<number>;
  40898. /**
  40899. * Sets the current depth function
  40900. * @param depthFunc defines the function to use
  40901. */
  40902. setDepthFunction(depthFunc: number): void;
  40903. /**
  40904. * Sets the current depth function to GREATER
  40905. */
  40906. setDepthFunctionToGreater(): void;
  40907. /**
  40908. * Sets the current depth function to GEQUAL
  40909. */
  40910. setDepthFunctionToGreaterOrEqual(): void;
  40911. /**
  40912. * Sets the current depth function to LESS
  40913. */
  40914. setDepthFunctionToLess(): void;
  40915. /**
  40916. * Sets the current depth function to LEQUAL
  40917. */
  40918. setDepthFunctionToLessOrEqual(): void;
  40919. private _cachedStencilBuffer;
  40920. private _cachedStencilFunction;
  40921. private _cachedStencilMask;
  40922. private _cachedStencilOperationPass;
  40923. private _cachedStencilOperationFail;
  40924. private _cachedStencilOperationDepthFail;
  40925. private _cachedStencilReference;
  40926. /**
  40927. * Caches the the state of the stencil buffer
  40928. */
  40929. cacheStencilState(): void;
  40930. /**
  40931. * Restores the state of the stencil buffer
  40932. */
  40933. restoreStencilState(): void;
  40934. /**
  40935. * Directly set the WebGL Viewport
  40936. * @param x defines the x coordinate of the viewport (in screen space)
  40937. * @param y defines the y coordinate of the viewport (in screen space)
  40938. * @param width defines the width of the viewport (in screen space)
  40939. * @param height defines the height of the viewport (in screen space)
  40940. * @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
  40941. */
  40942. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  40943. /**
  40944. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  40945. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40946. * @param y defines the y-coordinate of the corner of the clear rectangle
  40947. * @param width defines the width of the clear rectangle
  40948. * @param height defines the height of the clear rectangle
  40949. * @param clearColor defines the clear color
  40950. */
  40951. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  40952. /**
  40953. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  40954. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40955. * @param y defines the y-coordinate of the corner of the clear rectangle
  40956. * @param width defines the width of the clear rectangle
  40957. * @param height defines the height of the clear rectangle
  40958. */
  40959. enableScissor(x: number, y: number, width: number, height: number): void;
  40960. /**
  40961. * Disable previously set scissor test rectangle
  40962. */
  40963. disableScissor(): void;
  40964. protected _reportDrawCall(): void;
  40965. /**
  40966. * Initializes a webVR display and starts listening to display change events
  40967. * The onVRDisplayChangedObservable will be notified upon these changes
  40968. * @returns The onVRDisplayChangedObservable
  40969. */
  40970. initWebVR(): Observable<IDisplayChangedEventArgs>;
  40971. /** @hidden */
  40972. _prepareVRComponent(): void;
  40973. /** @hidden */
  40974. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  40975. /** @hidden */
  40976. _submitVRFrame(): void;
  40977. /**
  40978. * Call this function to leave webVR mode
  40979. * Will do nothing if webVR is not supported or if there is no webVR device
  40980. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40981. */
  40982. disableVR(): void;
  40983. /**
  40984. * Gets a boolean indicating that the system is in VR mode and is presenting
  40985. * @returns true if VR mode is engaged
  40986. */
  40987. isVRPresenting(): boolean;
  40988. /** @hidden */
  40989. _requestVRFrame(): void;
  40990. /** @hidden */
  40991. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40992. /**
  40993. * Gets the source code of the vertex shader associated with a specific webGL program
  40994. * @param program defines the program to use
  40995. * @returns a string containing the source code of the vertex shader associated with the program
  40996. */
  40997. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  40998. /**
  40999. * Gets the source code of the fragment shader associated with a specific webGL program
  41000. * @param program defines the program to use
  41001. * @returns a string containing the source code of the fragment shader associated with the program
  41002. */
  41003. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41004. /**
  41005. * Sets a depth stencil texture from a render target to the according uniform.
  41006. * @param channel The texture channel
  41007. * @param uniform The uniform to set
  41008. * @param texture The render target texture containing the depth stencil texture to apply
  41009. */
  41010. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41011. /**
  41012. * Sets a texture to the webGL context from a postprocess
  41013. * @param channel defines the channel to use
  41014. * @param postProcess defines the source postprocess
  41015. */
  41016. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41017. /**
  41018. * Binds the output of the passed in post process to the texture channel specified
  41019. * @param channel The channel the texture should be bound to
  41020. * @param postProcess The post process which's output should be bound
  41021. */
  41022. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41023. protected _rebuildBuffers(): void;
  41024. /** @hidden */
  41025. _renderFrame(): void;
  41026. _renderLoop(): void;
  41027. /** @hidden */
  41028. _renderViews(): boolean;
  41029. /**
  41030. * Toggle full screen mode
  41031. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41032. */
  41033. switchFullscreen(requestPointerLock: boolean): void;
  41034. /**
  41035. * Enters full screen mode
  41036. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41037. */
  41038. enterFullscreen(requestPointerLock: boolean): void;
  41039. /**
  41040. * Exits full screen mode
  41041. */
  41042. exitFullscreen(): void;
  41043. /**
  41044. * Enters Pointerlock mode
  41045. */
  41046. enterPointerlock(): void;
  41047. /**
  41048. * Exits Pointerlock mode
  41049. */
  41050. exitPointerlock(): void;
  41051. /**
  41052. * Begin a new frame
  41053. */
  41054. beginFrame(): void;
  41055. /**
  41056. * Enf the current frame
  41057. */
  41058. endFrame(): void;
  41059. resize(): void;
  41060. /**
  41061. * Force a specific size of the canvas
  41062. * @param width defines the new canvas' width
  41063. * @param height defines the new canvas' height
  41064. * @returns true if the size was changed
  41065. */
  41066. setSize(width: number, height: number): boolean;
  41067. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41068. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41069. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41070. _releaseTexture(texture: InternalTexture): void;
  41071. /**
  41072. * @hidden
  41073. * Rescales a texture
  41074. * @param source input texutre
  41075. * @param destination destination texture
  41076. * @param scene scene to use to render the resize
  41077. * @param internalFormat format to use when resizing
  41078. * @param onComplete callback to be called when resize has completed
  41079. */
  41080. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41081. /**
  41082. * Gets the current framerate
  41083. * @returns a number representing the framerate
  41084. */
  41085. getFps(): number;
  41086. /**
  41087. * Gets the time spent between current and previous frame
  41088. * @returns a number representing the delta time in ms
  41089. */
  41090. getDeltaTime(): number;
  41091. private _measureFps;
  41092. /** @hidden */
  41093. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41094. /**
  41095. * Updates the sample count of a render target texture
  41096. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41097. * @param texture defines the texture to update
  41098. * @param samples defines the sample count to set
  41099. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41100. */
  41101. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41102. /**
  41103. * Updates a depth texture Comparison Mode and Function.
  41104. * If the comparison Function is equal to 0, the mode will be set to none.
  41105. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41106. * @param texture The texture to set the comparison function for
  41107. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41108. */
  41109. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41110. /**
  41111. * Creates a webGL buffer to use with instanciation
  41112. * @param capacity defines the size of the buffer
  41113. * @returns the webGL buffer
  41114. */
  41115. createInstancesBuffer(capacity: number): DataBuffer;
  41116. /**
  41117. * Delete a webGL buffer used with instanciation
  41118. * @param buffer defines the webGL buffer to delete
  41119. */
  41120. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41121. private _clientWaitAsync;
  41122. /** @hidden */
  41123. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41124. dispose(): void;
  41125. private _disableTouchAction;
  41126. /**
  41127. * Display the loading screen
  41128. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41129. */
  41130. displayLoadingUI(): void;
  41131. /**
  41132. * Hide the loading screen
  41133. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41134. */
  41135. hideLoadingUI(): void;
  41136. /**
  41137. * Gets the current loading screen object
  41138. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41139. */
  41140. get loadingScreen(): ILoadingScreen;
  41141. /**
  41142. * Sets the current loading screen object
  41143. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41144. */
  41145. set loadingScreen(loadingScreen: ILoadingScreen);
  41146. /**
  41147. * Sets the current loading screen text
  41148. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41149. */
  41150. set loadingUIText(text: string);
  41151. /**
  41152. * Sets the current loading screen background color
  41153. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41154. */
  41155. set loadingUIBackgroundColor(color: string);
  41156. /** Pointerlock and fullscreen */
  41157. /**
  41158. * Ask the browser to promote the current element to pointerlock mode
  41159. * @param element defines the DOM element to promote
  41160. */
  41161. static _RequestPointerlock(element: HTMLElement): void;
  41162. /**
  41163. * Asks the browser to exit pointerlock mode
  41164. */
  41165. static _ExitPointerlock(): void;
  41166. /**
  41167. * Ask the browser to promote the current element to fullscreen rendering mode
  41168. * @param element defines the DOM element to promote
  41169. */
  41170. static _RequestFullscreen(element: HTMLElement): void;
  41171. /**
  41172. * Asks the browser to exit fullscreen mode
  41173. */
  41174. static _ExitFullscreen(): void;
  41175. }
  41176. }
  41177. declare module BABYLON {
  41178. /**
  41179. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41180. * during the life time of the application.
  41181. */
  41182. export class EngineStore {
  41183. /** Gets the list of created engines */
  41184. static Instances: Engine[];
  41185. /** @hidden */
  41186. static _LastCreatedScene: Nullable<Scene>;
  41187. /**
  41188. * Gets the latest created engine
  41189. */
  41190. static get LastCreatedEngine(): Nullable<Engine>;
  41191. /**
  41192. * Gets the latest created scene
  41193. */
  41194. static get LastCreatedScene(): Nullable<Scene>;
  41195. /**
  41196. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41197. * @ignorenaming
  41198. */
  41199. static UseFallbackTexture: boolean;
  41200. /**
  41201. * Texture content used if a texture cannot loaded
  41202. * @ignorenaming
  41203. */
  41204. static FallbackTexture: string;
  41205. }
  41206. }
  41207. declare module BABYLON {
  41208. /**
  41209. * Helper class that provides a small promise polyfill
  41210. */
  41211. export class PromisePolyfill {
  41212. /**
  41213. * Static function used to check if the polyfill is required
  41214. * If this is the case then the function will inject the polyfill to window.Promise
  41215. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41216. */
  41217. static Apply(force?: boolean): void;
  41218. }
  41219. }
  41220. declare module BABYLON {
  41221. /**
  41222. * Interface for screenshot methods with describe argument called `size` as object with options
  41223. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41224. */
  41225. export interface IScreenshotSize {
  41226. /**
  41227. * number in pixels for canvas height
  41228. */
  41229. height?: number;
  41230. /**
  41231. * multiplier allowing render at a higher or lower resolution
  41232. * If value is defined then height and width will be ignored and taken from camera
  41233. */
  41234. precision?: number;
  41235. /**
  41236. * number in pixels for canvas width
  41237. */
  41238. width?: number;
  41239. }
  41240. }
  41241. declare module BABYLON {
  41242. interface IColor4Like {
  41243. r: float;
  41244. g: float;
  41245. b: float;
  41246. a: float;
  41247. }
  41248. /**
  41249. * Class containing a set of static utilities functions
  41250. */
  41251. export class Tools {
  41252. /**
  41253. * Gets or sets the base URL to use to load assets
  41254. */
  41255. static get BaseUrl(): string;
  41256. static set BaseUrl(value: string);
  41257. /**
  41258. * Enable/Disable Custom HTTP Request Headers globally.
  41259. * default = false
  41260. * @see CustomRequestHeaders
  41261. */
  41262. static UseCustomRequestHeaders: boolean;
  41263. /**
  41264. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41265. * i.e. when loading files, where the server/service expects an Authorization header
  41266. */
  41267. static CustomRequestHeaders: {
  41268. [key: string]: string;
  41269. };
  41270. /**
  41271. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41272. */
  41273. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41274. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41275. /**
  41276. * Default behaviour for cors in the application.
  41277. * It can be a string if the expected behavior is identical in the entire app.
  41278. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41279. */
  41280. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41281. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41282. /**
  41283. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41284. * @ignorenaming
  41285. */
  41286. static get UseFallbackTexture(): boolean;
  41287. static set UseFallbackTexture(value: boolean);
  41288. /**
  41289. * Use this object to register external classes like custom textures or material
  41290. * to allow the laoders to instantiate them
  41291. */
  41292. static get RegisteredExternalClasses(): {
  41293. [key: string]: Object;
  41294. };
  41295. static set RegisteredExternalClasses(classes: {
  41296. [key: string]: Object;
  41297. });
  41298. /**
  41299. * Texture content used if a texture cannot loaded
  41300. * @ignorenaming
  41301. */
  41302. static get fallbackTexture(): string;
  41303. static set fallbackTexture(value: string);
  41304. /**
  41305. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41306. * @param u defines the coordinate on X axis
  41307. * @param v defines the coordinate on Y axis
  41308. * @param width defines the width of the source data
  41309. * @param height defines the height of the source data
  41310. * @param pixels defines the source byte array
  41311. * @param color defines the output color
  41312. */
  41313. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41314. /**
  41315. * Interpolates between a and b via alpha
  41316. * @param a The lower value (returned when alpha = 0)
  41317. * @param b The upper value (returned when alpha = 1)
  41318. * @param alpha The interpolation-factor
  41319. * @return The mixed value
  41320. */
  41321. static Mix(a: number, b: number, alpha: number): number;
  41322. /**
  41323. * Tries to instantiate a new object from a given class name
  41324. * @param className defines the class name to instantiate
  41325. * @returns the new object or null if the system was not able to do the instantiation
  41326. */
  41327. static Instantiate(className: string): any;
  41328. /**
  41329. * Provides a slice function that will work even on IE
  41330. * @param data defines the array to slice
  41331. * @param start defines the start of the data (optional)
  41332. * @param end defines the end of the data (optional)
  41333. * @returns the new sliced array
  41334. */
  41335. static Slice<T>(data: T, start?: number, end?: number): T;
  41336. /**
  41337. * Polyfill for setImmediate
  41338. * @param action defines the action to execute after the current execution block
  41339. */
  41340. static SetImmediate(action: () => void): void;
  41341. /**
  41342. * Function indicating if a number is an exponent of 2
  41343. * @param value defines the value to test
  41344. * @returns true if the value is an exponent of 2
  41345. */
  41346. static IsExponentOfTwo(value: number): boolean;
  41347. private static _tmpFloatArray;
  41348. /**
  41349. * Returns the nearest 32-bit single precision float representation of a Number
  41350. * @param value A Number. If the parameter is of a different type, it will get converted
  41351. * to a number or to NaN if it cannot be converted
  41352. * @returns number
  41353. */
  41354. static FloatRound(value: number): number;
  41355. /**
  41356. * Extracts the filename from a path
  41357. * @param path defines the path to use
  41358. * @returns the filename
  41359. */
  41360. static GetFilename(path: string): string;
  41361. /**
  41362. * Extracts the "folder" part of a path (everything before the filename).
  41363. * @param uri The URI to extract the info from
  41364. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41365. * @returns The "folder" part of the path
  41366. */
  41367. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41368. /**
  41369. * Extracts text content from a DOM element hierarchy
  41370. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41371. */
  41372. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41373. /**
  41374. * Convert an angle in radians to degrees
  41375. * @param angle defines the angle to convert
  41376. * @returns the angle in degrees
  41377. */
  41378. static ToDegrees(angle: number): number;
  41379. /**
  41380. * Convert an angle in degrees to radians
  41381. * @param angle defines the angle to convert
  41382. * @returns the angle in radians
  41383. */
  41384. static ToRadians(angle: number): number;
  41385. /**
  41386. * Returns an array if obj is not an array
  41387. * @param obj defines the object to evaluate as an array
  41388. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41389. * @returns either obj directly if obj is an array or a new array containing obj
  41390. */
  41391. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41392. /**
  41393. * Gets the pointer prefix to use
  41394. * @param engine defines the engine we are finding the prefix for
  41395. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41396. */
  41397. static GetPointerPrefix(engine: Engine): string;
  41398. /**
  41399. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41400. * @param url define the url we are trying
  41401. * @param element define the dom element where to configure the cors policy
  41402. */
  41403. static SetCorsBehavior(url: string | string[], element: {
  41404. crossOrigin: string | null;
  41405. }): void;
  41406. /**
  41407. * Removes unwanted characters from an url
  41408. * @param url defines the url to clean
  41409. * @returns the cleaned url
  41410. */
  41411. static CleanUrl(url: string): string;
  41412. /**
  41413. * Gets or sets a function used to pre-process url before using them to load assets
  41414. */
  41415. static get PreprocessUrl(): (url: string) => string;
  41416. static set PreprocessUrl(processor: (url: string) => string);
  41417. /**
  41418. * Loads an image as an HTMLImageElement.
  41419. * @param input url string, ArrayBuffer, or Blob to load
  41420. * @param onLoad callback called when the image successfully loads
  41421. * @param onError callback called when the image fails to load
  41422. * @param offlineProvider offline provider for caching
  41423. * @param mimeType optional mime type
  41424. * @returns the HTMLImageElement of the loaded image
  41425. */
  41426. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41427. /**
  41428. * Loads a file from a url
  41429. * @param url url string, ArrayBuffer, or Blob to load
  41430. * @param onSuccess callback called when the file successfully loads
  41431. * @param onProgress callback called while file is loading (if the server supports this mode)
  41432. * @param offlineProvider defines the offline provider for caching
  41433. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41434. * @param onError callback called when the file fails to load
  41435. * @returns a file request object
  41436. */
  41437. 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;
  41438. /**
  41439. * Loads a file from a url
  41440. * @param url the file url to load
  41441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41442. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41443. */
  41444. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41445. /**
  41446. * Load a script (identified by an url). When the url returns, the
  41447. * content of this file is added into a new script element, attached to the DOM (body element)
  41448. * @param scriptUrl defines the url of the script to laod
  41449. * @param onSuccess defines the callback called when the script is loaded
  41450. * @param onError defines the callback to call if an error occurs
  41451. * @param scriptId defines the id of the script element
  41452. */
  41453. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41454. /**
  41455. * Load an asynchronous script (identified by an url). When the url returns, the
  41456. * content of this file is added into a new script element, attached to the DOM (body element)
  41457. * @param scriptUrl defines the url of the script to laod
  41458. * @param scriptId defines the id of the script element
  41459. * @returns a promise request object
  41460. */
  41461. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41462. /**
  41463. * Loads a file from a blob
  41464. * @param fileToLoad defines the blob to use
  41465. * @param callback defines the callback to call when data is loaded
  41466. * @param progressCallback defines the callback to call during loading process
  41467. * @returns a file request object
  41468. */
  41469. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41470. /**
  41471. * Reads a file from a File object
  41472. * @param file defines the file to load
  41473. * @param onSuccess defines the callback to call when data is loaded
  41474. * @param onProgress defines the callback to call during loading process
  41475. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41476. * @param onError defines the callback to call when an error occurs
  41477. * @returns a file request object
  41478. */
  41479. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41480. /**
  41481. * Creates a data url from a given string content
  41482. * @param content defines the content to convert
  41483. * @returns the new data url link
  41484. */
  41485. static FileAsURL(content: string): string;
  41486. /**
  41487. * Format the given number to a specific decimal format
  41488. * @param value defines the number to format
  41489. * @param decimals defines the number of decimals to use
  41490. * @returns the formatted string
  41491. */
  41492. static Format(value: number, decimals?: number): string;
  41493. /**
  41494. * Tries to copy an object by duplicating every property
  41495. * @param source defines the source object
  41496. * @param destination defines the target object
  41497. * @param doNotCopyList defines a list of properties to avoid
  41498. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41499. */
  41500. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41501. /**
  41502. * Gets a boolean indicating if the given object has no own property
  41503. * @param obj defines the object to test
  41504. * @returns true if object has no own property
  41505. */
  41506. static IsEmpty(obj: any): boolean;
  41507. /**
  41508. * Function used to register events at window level
  41509. * @param windowElement defines the Window object to use
  41510. * @param events defines the events to register
  41511. */
  41512. static RegisterTopRootEvents(windowElement: Window, events: {
  41513. name: string;
  41514. handler: Nullable<(e: FocusEvent) => any>;
  41515. }[]): void;
  41516. /**
  41517. * Function used to unregister events from window level
  41518. * @param windowElement defines the Window object to use
  41519. * @param events defines the events to unregister
  41520. */
  41521. static UnregisterTopRootEvents(windowElement: Window, events: {
  41522. name: string;
  41523. handler: Nullable<(e: FocusEvent) => any>;
  41524. }[]): void;
  41525. /**
  41526. * @ignore
  41527. */
  41528. static _ScreenshotCanvas: HTMLCanvasElement;
  41529. /**
  41530. * Dumps the current bound framebuffer
  41531. * @param width defines the rendering width
  41532. * @param height defines the rendering height
  41533. * @param engine defines the hosting engine
  41534. * @param successCallback defines the callback triggered once the data are available
  41535. * @param mimeType defines the mime type of the result
  41536. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41537. */
  41538. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41539. /**
  41540. * Converts the canvas data to blob.
  41541. * This acts as a polyfill for browsers not supporting the to blob function.
  41542. * @param canvas Defines the canvas to extract the data from
  41543. * @param successCallback Defines the callback triggered once the data are available
  41544. * @param mimeType Defines the mime type of the result
  41545. */
  41546. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41547. /**
  41548. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41549. * @param successCallback defines the callback triggered once the data are available
  41550. * @param mimeType defines the mime type of the result
  41551. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41552. */
  41553. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41554. /**
  41555. * Downloads a blob in the browser
  41556. * @param blob defines the blob to download
  41557. * @param fileName defines the name of the downloaded file
  41558. */
  41559. static Download(blob: Blob, fileName: string): void;
  41560. /**
  41561. * Captures a screenshot of the current rendering
  41562. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41563. * @param engine defines the rendering engine
  41564. * @param camera defines the source camera
  41565. * @param size This parameter can be set to a single number or to an object with the
  41566. * following (optional) properties: precision, width, height. If a single number is passed,
  41567. * it will be used for both width and height. If an object is passed, the screenshot size
  41568. * will be derived from the parameters. The precision property is a multiplier allowing
  41569. * rendering at a higher or lower resolution
  41570. * @param successCallback defines the callback receives a single parameter which contains the
  41571. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41572. * src parameter of an <img> to display it
  41573. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41574. * Check your browser for supported MIME types
  41575. */
  41576. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41577. /**
  41578. * Captures a screenshot of the current rendering
  41579. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41580. * @param engine defines the rendering engine
  41581. * @param camera defines the source camera
  41582. * @param size This parameter can be set to a single number or to an object with the
  41583. * following (optional) properties: precision, width, height. If a single number is passed,
  41584. * it will be used for both width and height. If an object is passed, the screenshot size
  41585. * will be derived from the parameters. The precision property is a multiplier allowing
  41586. * rendering at a higher or lower resolution
  41587. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41588. * Check your browser for supported MIME types
  41589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41590. * to the src parameter of an <img> to display it
  41591. */
  41592. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41593. /**
  41594. * Generates an image screenshot from the specified camera.
  41595. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41596. * @param engine The engine to use for rendering
  41597. * @param camera The camera to use for rendering
  41598. * @param size This parameter can be set to a single number or to an object with the
  41599. * following (optional) properties: precision, width, height. If a single number is passed,
  41600. * it will be used for both width and height. If an object is passed, the screenshot size
  41601. * will be derived from the parameters. The precision property is a multiplier allowing
  41602. * rendering at a higher or lower resolution
  41603. * @param successCallback The callback receives a single parameter which contains the
  41604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41605. * src parameter of an <img> to display it
  41606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41607. * Check your browser for supported MIME types
  41608. * @param samples Texture samples (default: 1)
  41609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41610. * @param fileName A name for for the downloaded file.
  41611. */
  41612. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41613. /**
  41614. * Generates an image screenshot from the specified camera.
  41615. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41616. * @param engine The engine to use for rendering
  41617. * @param camera The camera to use for rendering
  41618. * @param size This parameter can be set to a single number or to an object with the
  41619. * following (optional) properties: precision, width, height. If a single number is passed,
  41620. * it will be used for both width and height. If an object is passed, the screenshot size
  41621. * will be derived from the parameters. The precision property is a multiplier allowing
  41622. * rendering at a higher or lower resolution
  41623. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41624. * Check your browser for supported MIME types
  41625. * @param samples Texture samples (default: 1)
  41626. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41627. * @param fileName A name for for the downloaded file.
  41628. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41629. * to the src parameter of an <img> to display it
  41630. */
  41631. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41632. /**
  41633. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41634. * Be aware Math.random() could cause collisions, but:
  41635. * "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"
  41636. * @returns a pseudo random id
  41637. */
  41638. static RandomId(): string;
  41639. /**
  41640. * Test if the given uri is a base64 string
  41641. * @param uri The uri to test
  41642. * @return True if the uri is a base64 string or false otherwise
  41643. */
  41644. static IsBase64(uri: string): boolean;
  41645. /**
  41646. * Decode the given base64 uri.
  41647. * @param uri The uri to decode
  41648. * @return The decoded base64 data.
  41649. */
  41650. static DecodeBase64(uri: string): ArrayBuffer;
  41651. /**
  41652. * Gets the absolute url.
  41653. * @param url the input url
  41654. * @return the absolute url
  41655. */
  41656. static GetAbsoluteUrl(url: string): string;
  41657. /**
  41658. * No log
  41659. */
  41660. static readonly NoneLogLevel: number;
  41661. /**
  41662. * Only message logs
  41663. */
  41664. static readonly MessageLogLevel: number;
  41665. /**
  41666. * Only warning logs
  41667. */
  41668. static readonly WarningLogLevel: number;
  41669. /**
  41670. * Only error logs
  41671. */
  41672. static readonly ErrorLogLevel: number;
  41673. /**
  41674. * All logs
  41675. */
  41676. static readonly AllLogLevel: number;
  41677. /**
  41678. * Gets a value indicating the number of loading errors
  41679. * @ignorenaming
  41680. */
  41681. static get errorsCount(): number;
  41682. /**
  41683. * Callback called when a new log is added
  41684. */
  41685. static OnNewCacheEntry: (entry: string) => void;
  41686. /**
  41687. * Log a message to the console
  41688. * @param message defines the message to log
  41689. */
  41690. static Log(message: string): void;
  41691. /**
  41692. * Write a warning message to the console
  41693. * @param message defines the message to log
  41694. */
  41695. static Warn(message: string): void;
  41696. /**
  41697. * Write an error message to the console
  41698. * @param message defines the message to log
  41699. */
  41700. static Error(message: string): void;
  41701. /**
  41702. * Gets current log cache (list of logs)
  41703. */
  41704. static get LogCache(): string;
  41705. /**
  41706. * Clears the log cache
  41707. */
  41708. static ClearLogCache(): void;
  41709. /**
  41710. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41711. */
  41712. static set LogLevels(level: number);
  41713. /**
  41714. * Checks if the window object exists
  41715. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41716. */
  41717. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41718. /**
  41719. * No performance log
  41720. */
  41721. static readonly PerformanceNoneLogLevel: number;
  41722. /**
  41723. * Use user marks to log performance
  41724. */
  41725. static readonly PerformanceUserMarkLogLevel: number;
  41726. /**
  41727. * Log performance to the console
  41728. */
  41729. static readonly PerformanceConsoleLogLevel: number;
  41730. private static _performance;
  41731. /**
  41732. * Sets the current performance log level
  41733. */
  41734. static set PerformanceLogLevel(level: number);
  41735. private static _StartPerformanceCounterDisabled;
  41736. private static _EndPerformanceCounterDisabled;
  41737. private static _StartUserMark;
  41738. private static _EndUserMark;
  41739. private static _StartPerformanceConsole;
  41740. private static _EndPerformanceConsole;
  41741. /**
  41742. * Starts a performance counter
  41743. */
  41744. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41745. /**
  41746. * Ends a specific performance coutner
  41747. */
  41748. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41749. /**
  41750. * Gets either window.performance.now() if supported or Date.now() else
  41751. */
  41752. static get Now(): number;
  41753. /**
  41754. * This method will return the name of the class used to create the instance of the given object.
  41755. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41756. * @param object the object to get the class name from
  41757. * @param isType defines if the object is actually a type
  41758. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41759. */
  41760. static GetClassName(object: any, isType?: boolean): string;
  41761. /**
  41762. * Gets the first element of an array satisfying a given predicate
  41763. * @param array defines the array to browse
  41764. * @param predicate defines the predicate to use
  41765. * @returns null if not found or the element
  41766. */
  41767. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41768. /**
  41769. * This method will return the name of the full name of the class, including its owning module (if any).
  41770. * 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).
  41771. * @param object the object to get the class name from
  41772. * @param isType defines if the object is actually a type
  41773. * @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.
  41774. * @ignorenaming
  41775. */
  41776. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41777. /**
  41778. * Returns a promise that resolves after the given amount of time.
  41779. * @param delay Number of milliseconds to delay
  41780. * @returns Promise that resolves after the given amount of time
  41781. */
  41782. static DelayAsync(delay: number): Promise<void>;
  41783. /**
  41784. * Utility function to detect if the current user agent is Safari
  41785. * @returns whether or not the current user agent is safari
  41786. */
  41787. static IsSafari(): boolean;
  41788. }
  41789. /**
  41790. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  41791. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  41792. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  41793. * @param name The name of the class, case should be preserved
  41794. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  41795. */
  41796. export function className(name: string, module?: string): (target: Object) => void;
  41797. /**
  41798. * An implementation of a loop for asynchronous functions.
  41799. */
  41800. export class AsyncLoop {
  41801. /**
  41802. * Defines the number of iterations for the loop
  41803. */
  41804. iterations: number;
  41805. /**
  41806. * Defines the current index of the loop.
  41807. */
  41808. index: number;
  41809. private _done;
  41810. private _fn;
  41811. private _successCallback;
  41812. /**
  41813. * Constructor.
  41814. * @param iterations the number of iterations.
  41815. * @param func the function to run each iteration
  41816. * @param successCallback the callback that will be called upon succesful execution
  41817. * @param offset starting offset.
  41818. */
  41819. constructor(
  41820. /**
  41821. * Defines the number of iterations for the loop
  41822. */
  41823. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  41824. /**
  41825. * Execute the next iteration. Must be called after the last iteration was finished.
  41826. */
  41827. executeNext(): void;
  41828. /**
  41829. * Break the loop and run the success callback.
  41830. */
  41831. breakLoop(): void;
  41832. /**
  41833. * Create and run an async loop.
  41834. * @param iterations the number of iterations.
  41835. * @param fn the function to run each iteration
  41836. * @param successCallback the callback that will be called upon succesful execution
  41837. * @param offset starting offset.
  41838. * @returns the created async loop object
  41839. */
  41840. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  41841. /**
  41842. * A for-loop that will run a given number of iterations synchronous and the rest async.
  41843. * @param iterations total number of iterations
  41844. * @param syncedIterations number of synchronous iterations in each async iteration.
  41845. * @param fn the function to call each iteration.
  41846. * @param callback a success call back that will be called when iterating stops.
  41847. * @param breakFunction a break condition (optional)
  41848. * @param timeout timeout settings for the setTimeout function. default - 0.
  41849. * @returns the created async loop object
  41850. */
  41851. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  41852. }
  41853. }
  41854. declare module BABYLON {
  41855. /**
  41856. * This class implement a typical dictionary using a string as key and the generic type T as value.
  41857. * The underlying implementation relies on an associative array to ensure the best performances.
  41858. * The value can be anything including 'null' but except 'undefined'
  41859. */
  41860. export class StringDictionary<T> {
  41861. /**
  41862. * This will clear this dictionary and copy the content from the 'source' one.
  41863. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  41864. * @param source the dictionary to take the content from and copy to this dictionary
  41865. */
  41866. copyFrom(source: StringDictionary<T>): void;
  41867. /**
  41868. * Get a value based from its key
  41869. * @param key the given key to get the matching value from
  41870. * @return the value if found, otherwise undefined is returned
  41871. */
  41872. get(key: string): T | undefined;
  41873. /**
  41874. * Get a value from its key or add it if it doesn't exist.
  41875. * This method will ensure you that a given key/data will be present in the dictionary.
  41876. * @param key the given key to get the matching value from
  41877. * @param factory the factory that will create the value if the key is not present in the dictionary.
  41878. * The factory will only be invoked if there's no data for the given key.
  41879. * @return the value corresponding to the key.
  41880. */
  41881. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  41882. /**
  41883. * Get a value from its key if present in the dictionary otherwise add it
  41884. * @param key the key to get the value from
  41885. * @param val if there's no such key/value pair in the dictionary add it with this value
  41886. * @return the value corresponding to the key
  41887. */
  41888. getOrAdd(key: string, val: T): T;
  41889. /**
  41890. * Check if there's a given key in the dictionary
  41891. * @param key the key to check for
  41892. * @return true if the key is present, false otherwise
  41893. */
  41894. contains(key: string): boolean;
  41895. /**
  41896. * Add a new key and its corresponding value
  41897. * @param key the key to add
  41898. * @param value the value corresponding to the key
  41899. * @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
  41900. */
  41901. add(key: string, value: T): boolean;
  41902. /**
  41903. * Update a specific value associated to a key
  41904. * @param key defines the key to use
  41905. * @param value defines the value to store
  41906. * @returns true if the value was updated (or false if the key was not found)
  41907. */
  41908. set(key: string, value: T): boolean;
  41909. /**
  41910. * Get the element of the given key and remove it from the dictionary
  41911. * @param key defines the key to search
  41912. * @returns the value associated with the key or null if not found
  41913. */
  41914. getAndRemove(key: string): Nullable<T>;
  41915. /**
  41916. * Remove a key/value from the dictionary.
  41917. * @param key the key to remove
  41918. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  41919. */
  41920. remove(key: string): boolean;
  41921. /**
  41922. * Clear the whole content of the dictionary
  41923. */
  41924. clear(): void;
  41925. /**
  41926. * Gets the current count
  41927. */
  41928. get count(): number;
  41929. /**
  41930. * Execute a callback on each key/val of the dictionary.
  41931. * Note that you can remove any element in this dictionary in the callback implementation
  41932. * @param callback the callback to execute on a given key/value pair
  41933. */
  41934. forEach(callback: (key: string, val: T) => void): void;
  41935. /**
  41936. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  41937. * If the callback returns null or undefined the method will iterate to the next key/value pair
  41938. * Note that you can remove any element in this dictionary in the callback implementation
  41939. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  41940. * @returns the first item
  41941. */
  41942. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  41943. private _count;
  41944. private _data;
  41945. }
  41946. }
  41947. declare module BABYLON {
  41948. /** @hidden */
  41949. export interface ICollisionCoordinator {
  41950. createCollider(): Collider;
  41951. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41952. init(scene: Scene): void;
  41953. }
  41954. /** @hidden */
  41955. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  41956. private _scene;
  41957. private _scaledPosition;
  41958. private _scaledVelocity;
  41959. private _finalPosition;
  41960. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41961. createCollider(): Collider;
  41962. init(scene: Scene): void;
  41963. private _collideWithWorld;
  41964. }
  41965. }
  41966. declare module BABYLON {
  41967. /**
  41968. * Class used to manage all inputs for the scene.
  41969. */
  41970. export class InputManager {
  41971. /** The distance in pixel that you have to move to prevent some events */
  41972. static DragMovementThreshold: number;
  41973. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  41974. static LongPressDelay: number;
  41975. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  41976. static DoubleClickDelay: number;
  41977. /** If you need to check double click without raising a single click at first click, enable this flag */
  41978. static ExclusiveDoubleClickMode: boolean;
  41979. /** 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. */
  41980. private _alreadyAttached;
  41981. private _wheelEventName;
  41982. private _onPointerMove;
  41983. private _onPointerDown;
  41984. private _onPointerUp;
  41985. private _initClickEvent;
  41986. private _initActionManager;
  41987. private _delayedSimpleClick;
  41988. private _delayedSimpleClickTimeout;
  41989. private _previousDelayedSimpleClickTimeout;
  41990. private _meshPickProceed;
  41991. private _previousButtonPressed;
  41992. private _currentPickResult;
  41993. private _previousPickResult;
  41994. private _totalPointersPressed;
  41995. private _doubleClickOccured;
  41996. private _pointerOverMesh;
  41997. private _pickedDownMesh;
  41998. private _pickedUpMesh;
  41999. private _pointerX;
  42000. private _pointerY;
  42001. private _unTranslatedPointerX;
  42002. private _unTranslatedPointerY;
  42003. private _startingPointerPosition;
  42004. private _previousStartingPointerPosition;
  42005. private _startingPointerTime;
  42006. private _previousStartingPointerTime;
  42007. private _pointerCaptures;
  42008. private _meshUnderPointerId;
  42009. private _onKeyDown;
  42010. private _onKeyUp;
  42011. private _onCanvasFocusObserver;
  42012. private _onCanvasBlurObserver;
  42013. private _scene;
  42014. /**
  42015. * Creates a new InputManager
  42016. * @param scene defines the hosting scene
  42017. */
  42018. constructor(scene: Scene);
  42019. /**
  42020. * Gets the mesh that is currently under the pointer
  42021. */
  42022. get meshUnderPointer(): Nullable<AbstractMesh>;
  42023. /**
  42024. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42025. * @param pointerId the pointer id to use
  42026. * @returns The mesh under this pointer id or null if not found
  42027. */
  42028. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42029. /**
  42030. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42031. */
  42032. get unTranslatedPointer(): Vector2;
  42033. /**
  42034. * Gets or sets the current on-screen X position of the pointer
  42035. */
  42036. get pointerX(): number;
  42037. set pointerX(value: number);
  42038. /**
  42039. * Gets or sets the current on-screen Y position of the pointer
  42040. */
  42041. get pointerY(): number;
  42042. set pointerY(value: number);
  42043. private _updatePointerPosition;
  42044. private _processPointerMove;
  42045. private _setRayOnPointerInfo;
  42046. private _checkPrePointerObservable;
  42047. /**
  42048. * Use this method to simulate a pointer move on a mesh
  42049. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42050. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42051. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42052. */
  42053. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42054. /**
  42055. * Use this method to simulate a pointer down on a mesh
  42056. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42057. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42058. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42059. */
  42060. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42061. private _processPointerDown;
  42062. /** @hidden */
  42063. _isPointerSwiping(): boolean;
  42064. /**
  42065. * Use this method to simulate a pointer up on a mesh
  42066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42069. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42070. */
  42071. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42072. private _processPointerUp;
  42073. /**
  42074. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42075. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42076. * @returns true if the pointer was captured
  42077. */
  42078. isPointerCaptured(pointerId?: number): boolean;
  42079. /**
  42080. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42081. * @param attachUp defines if you want to attach events to pointerup
  42082. * @param attachDown defines if you want to attach events to pointerdown
  42083. * @param attachMove defines if you want to attach events to pointermove
  42084. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42085. */
  42086. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42087. /**
  42088. * Detaches all event handlers
  42089. */
  42090. detachControl(): void;
  42091. /**
  42092. * Force the value of meshUnderPointer
  42093. * @param mesh defines the mesh to use
  42094. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42095. */
  42096. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42097. /**
  42098. * Gets the mesh under the pointer
  42099. * @returns a Mesh or null if no mesh is under the pointer
  42100. */
  42101. getPointerOverMesh(): Nullable<AbstractMesh>;
  42102. }
  42103. }
  42104. declare module BABYLON {
  42105. /**
  42106. * This class defines the direct association between an animation and a target
  42107. */
  42108. export class TargetedAnimation {
  42109. /**
  42110. * Animation to perform
  42111. */
  42112. animation: Animation;
  42113. /**
  42114. * Target to animate
  42115. */
  42116. target: any;
  42117. /**
  42118. * Returns the string "TargetedAnimation"
  42119. * @returns "TargetedAnimation"
  42120. */
  42121. getClassName(): string;
  42122. /**
  42123. * Serialize the object
  42124. * @returns the JSON object representing the current entity
  42125. */
  42126. serialize(): any;
  42127. }
  42128. /**
  42129. * Use this class to create coordinated animations on multiple targets
  42130. */
  42131. export class AnimationGroup implements IDisposable {
  42132. /** The name of the animation group */
  42133. name: string;
  42134. private _scene;
  42135. private _targetedAnimations;
  42136. private _animatables;
  42137. private _from;
  42138. private _to;
  42139. private _isStarted;
  42140. private _isPaused;
  42141. private _speedRatio;
  42142. private _loopAnimation;
  42143. private _isAdditive;
  42144. /**
  42145. * Gets or sets the unique id of the node
  42146. */
  42147. uniqueId: number;
  42148. /**
  42149. * This observable will notify when one animation have ended
  42150. */
  42151. onAnimationEndObservable: Observable<TargetedAnimation>;
  42152. /**
  42153. * Observer raised when one animation loops
  42154. */
  42155. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42156. /**
  42157. * Observer raised when all animations have looped
  42158. */
  42159. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42160. /**
  42161. * This observable will notify when all animations have ended.
  42162. */
  42163. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42164. /**
  42165. * This observable will notify when all animations have paused.
  42166. */
  42167. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42168. /**
  42169. * This observable will notify when all animations are playing.
  42170. */
  42171. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42172. /**
  42173. * Gets the first frame
  42174. */
  42175. get from(): number;
  42176. /**
  42177. * Gets the last frame
  42178. */
  42179. get to(): number;
  42180. /**
  42181. * Define if the animations are started
  42182. */
  42183. get isStarted(): boolean;
  42184. /**
  42185. * Gets a value indicating that the current group is playing
  42186. */
  42187. get isPlaying(): boolean;
  42188. /**
  42189. * Gets or sets the speed ratio to use for all animations
  42190. */
  42191. get speedRatio(): number;
  42192. /**
  42193. * Gets or sets the speed ratio to use for all animations
  42194. */
  42195. set speedRatio(value: number);
  42196. /**
  42197. * Gets or sets if all animations should loop or not
  42198. */
  42199. get loopAnimation(): boolean;
  42200. set loopAnimation(value: boolean);
  42201. /**
  42202. * Gets or sets if all animations should be evaluated additively
  42203. */
  42204. get isAdditive(): boolean;
  42205. set isAdditive(value: boolean);
  42206. /**
  42207. * Gets the targeted animations for this animation group
  42208. */
  42209. get targetedAnimations(): Array<TargetedAnimation>;
  42210. /**
  42211. * returning the list of animatables controlled by this animation group.
  42212. */
  42213. get animatables(): Array<Animatable>;
  42214. /**
  42215. * Gets the list of target animations
  42216. */
  42217. get children(): TargetedAnimation[];
  42218. /**
  42219. * Instantiates a new Animation Group.
  42220. * This helps managing several animations at once.
  42221. * @see https://doc.babylonjs.com/how_to/group
  42222. * @param name Defines the name of the group
  42223. * @param scene Defines the scene the group belongs to
  42224. */
  42225. constructor(
  42226. /** The name of the animation group */
  42227. name: string, scene?: Nullable<Scene>);
  42228. /**
  42229. * Add an animation (with its target) in the group
  42230. * @param animation defines the animation we want to add
  42231. * @param target defines the target of the animation
  42232. * @returns the TargetedAnimation object
  42233. */
  42234. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42235. /**
  42236. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42237. * It can add constant keys at begin or end
  42238. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42239. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42240. * @returns the animation group
  42241. */
  42242. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42243. private _animationLoopCount;
  42244. private _animationLoopFlags;
  42245. private _processLoop;
  42246. /**
  42247. * Start all animations on given targets
  42248. * @param loop defines if animations must loop
  42249. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42250. * @param from defines the from key (optional)
  42251. * @param to defines the to key (optional)
  42252. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42253. * @returns the current animation group
  42254. */
  42255. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42256. /**
  42257. * Pause all animations
  42258. * @returns the animation group
  42259. */
  42260. pause(): AnimationGroup;
  42261. /**
  42262. * Play all animations to initial state
  42263. * This function will start() the animations if they were not started or will restart() them if they were paused
  42264. * @param loop defines if animations must loop
  42265. * @returns the animation group
  42266. */
  42267. play(loop?: boolean): AnimationGroup;
  42268. /**
  42269. * Reset all animations to initial state
  42270. * @returns the animation group
  42271. */
  42272. reset(): AnimationGroup;
  42273. /**
  42274. * Restart animations from key 0
  42275. * @returns the animation group
  42276. */
  42277. restart(): AnimationGroup;
  42278. /**
  42279. * Stop all animations
  42280. * @returns the animation group
  42281. */
  42282. stop(): AnimationGroup;
  42283. /**
  42284. * Set animation weight for all animatables
  42285. * @param weight defines the weight to use
  42286. * @return the animationGroup
  42287. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42288. */
  42289. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42290. /**
  42291. * Synchronize and normalize all animatables with a source animatable
  42292. * @param root defines the root animatable to synchronize with
  42293. * @return the animationGroup
  42294. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42295. */
  42296. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42297. /**
  42298. * Goes to a specific frame in this animation group
  42299. * @param frame the frame number to go to
  42300. * @return the animationGroup
  42301. */
  42302. goToFrame(frame: number): AnimationGroup;
  42303. /**
  42304. * Dispose all associated resources
  42305. */
  42306. dispose(): void;
  42307. private _checkAnimationGroupEnded;
  42308. /**
  42309. * Clone the current animation group and returns a copy
  42310. * @param newName defines the name of the new group
  42311. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42312. * @returns the new aniamtion group
  42313. */
  42314. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42315. /**
  42316. * Serializes the animationGroup to an object
  42317. * @returns Serialized object
  42318. */
  42319. serialize(): any;
  42320. /**
  42321. * Returns a new AnimationGroup object parsed from the source provided.
  42322. * @param parsedAnimationGroup defines the source
  42323. * @param scene defines the scene that will receive the animationGroup
  42324. * @returns a new AnimationGroup
  42325. */
  42326. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42327. /**
  42328. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42329. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42330. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42331. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42332. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42333. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42334. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42335. */
  42336. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42337. /**
  42338. * Returns the string "AnimationGroup"
  42339. * @returns "AnimationGroup"
  42340. */
  42341. getClassName(): string;
  42342. /**
  42343. * Creates a detailled string about the object
  42344. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42345. * @returns a string representing the object
  42346. */
  42347. toString(fullDetails?: boolean): string;
  42348. }
  42349. }
  42350. declare module BABYLON {
  42351. /**
  42352. * Define an interface for all classes that will hold resources
  42353. */
  42354. export interface IDisposable {
  42355. /**
  42356. * Releases all held resources
  42357. */
  42358. dispose(): void;
  42359. }
  42360. /** Interface defining initialization parameters for Scene class */
  42361. export interface SceneOptions {
  42362. /**
  42363. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42364. * It will improve performance when the number of geometries becomes important.
  42365. */
  42366. useGeometryUniqueIdsMap?: boolean;
  42367. /**
  42368. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42369. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42370. */
  42371. useMaterialMeshMap?: boolean;
  42372. /**
  42373. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42374. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42375. */
  42376. useClonedMeshMap?: boolean;
  42377. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42378. virtual?: boolean;
  42379. }
  42380. /**
  42381. * Represents a scene to be rendered by the engine.
  42382. * @see https://doc.babylonjs.com/features/scene
  42383. */
  42384. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42385. /** The fog is deactivated */
  42386. static readonly FOGMODE_NONE: number;
  42387. /** The fog density is following an exponential function */
  42388. static readonly FOGMODE_EXP: number;
  42389. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42390. static readonly FOGMODE_EXP2: number;
  42391. /** The fog density is following a linear function. */
  42392. static readonly FOGMODE_LINEAR: number;
  42393. /**
  42394. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42395. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42396. */
  42397. static MinDeltaTime: number;
  42398. /**
  42399. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42401. */
  42402. static MaxDeltaTime: number;
  42403. /**
  42404. * Factory used to create the default material.
  42405. * @param name The name of the material to create
  42406. * @param scene The scene to create the material for
  42407. * @returns The default material
  42408. */
  42409. static DefaultMaterialFactory(scene: Scene): Material;
  42410. /**
  42411. * Factory used to create the a collision coordinator.
  42412. * @returns The collision coordinator
  42413. */
  42414. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42415. /** @hidden */
  42416. _inputManager: InputManager;
  42417. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42418. cameraToUseForPointers: Nullable<Camera>;
  42419. /** @hidden */
  42420. readonly _isScene: boolean;
  42421. /** @hidden */
  42422. _blockEntityCollection: boolean;
  42423. /**
  42424. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42425. */
  42426. autoClear: boolean;
  42427. /**
  42428. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42429. */
  42430. autoClearDepthAndStencil: boolean;
  42431. /**
  42432. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42433. */
  42434. clearColor: Color4;
  42435. /**
  42436. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42437. */
  42438. ambientColor: Color3;
  42439. /**
  42440. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42441. * It should only be one of the following (if not the default embedded one):
  42442. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42443. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42444. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42445. * The material properties need to be setup according to the type of texture in use.
  42446. */
  42447. environmentBRDFTexture: BaseTexture;
  42448. /**
  42449. * Texture used in all pbr material as the reflection texture.
  42450. * As in the majority of the scene they are the same (exception for multi room and so on),
  42451. * this is easier to reference from here than from all the materials.
  42452. */
  42453. get environmentTexture(): Nullable<BaseTexture>;
  42454. /**
  42455. * Texture used in all pbr material as the reflection texture.
  42456. * As in the majority of the scene they are the same (exception for multi room and so on),
  42457. * this is easier to set here than in all the materials.
  42458. */
  42459. set environmentTexture(value: Nullable<BaseTexture>);
  42460. /** @hidden */
  42461. protected _environmentIntensity: number;
  42462. /**
  42463. * Intensity of the environment in all pbr material.
  42464. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42465. * As in the majority of the scene they are the same (exception for multi room and so on),
  42466. * this is easier to reference from here than from all the materials.
  42467. */
  42468. get environmentIntensity(): number;
  42469. /**
  42470. * Intensity of the environment in all pbr material.
  42471. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42472. * As in the majority of the scene they are the same (exception for multi room and so on),
  42473. * this is easier to set here than in all the materials.
  42474. */
  42475. set environmentIntensity(value: number);
  42476. /** @hidden */
  42477. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42478. /**
  42479. * Default image processing configuration used either in the rendering
  42480. * Forward main pass or through the imageProcessingPostProcess if present.
  42481. * As in the majority of the scene they are the same (exception for multi camera),
  42482. * this is easier to reference from here than from all the materials and post process.
  42483. *
  42484. * No setter as we it is a shared configuration, you can set the values instead.
  42485. */
  42486. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42487. private _forceWireframe;
  42488. /**
  42489. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42490. */
  42491. set forceWireframe(value: boolean);
  42492. get forceWireframe(): boolean;
  42493. private _skipFrustumClipping;
  42494. /**
  42495. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42496. */
  42497. set skipFrustumClipping(value: boolean);
  42498. get skipFrustumClipping(): boolean;
  42499. private _forcePointsCloud;
  42500. /**
  42501. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42502. */
  42503. set forcePointsCloud(value: boolean);
  42504. get forcePointsCloud(): boolean;
  42505. /**
  42506. * Gets or sets the active clipplane 1
  42507. */
  42508. clipPlane: Nullable<Plane>;
  42509. /**
  42510. * Gets or sets the active clipplane 2
  42511. */
  42512. clipPlane2: Nullable<Plane>;
  42513. /**
  42514. * Gets or sets the active clipplane 3
  42515. */
  42516. clipPlane3: Nullable<Plane>;
  42517. /**
  42518. * Gets or sets the active clipplane 4
  42519. */
  42520. clipPlane4: Nullable<Plane>;
  42521. /**
  42522. * Gets or sets the active clipplane 5
  42523. */
  42524. clipPlane5: Nullable<Plane>;
  42525. /**
  42526. * Gets or sets the active clipplane 6
  42527. */
  42528. clipPlane6: Nullable<Plane>;
  42529. /**
  42530. * Gets or sets a boolean indicating if animations are enabled
  42531. */
  42532. animationsEnabled: boolean;
  42533. private _animationPropertiesOverride;
  42534. /**
  42535. * Gets or sets the animation properties override
  42536. */
  42537. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42538. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42539. /**
  42540. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42541. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42542. */
  42543. useConstantAnimationDeltaTime: boolean;
  42544. /**
  42545. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42546. * Please note that it requires to run a ray cast through the scene on every frame
  42547. */
  42548. constantlyUpdateMeshUnderPointer: boolean;
  42549. /**
  42550. * Defines the HTML cursor to use when hovering over interactive elements
  42551. */
  42552. hoverCursor: string;
  42553. /**
  42554. * Defines the HTML default cursor to use (empty by default)
  42555. */
  42556. defaultCursor: string;
  42557. /**
  42558. * Defines whether cursors are handled by the scene.
  42559. */
  42560. doNotHandleCursors: boolean;
  42561. /**
  42562. * This is used to call preventDefault() on pointer down
  42563. * in order to block unwanted artifacts like system double clicks
  42564. */
  42565. preventDefaultOnPointerDown: boolean;
  42566. /**
  42567. * This is used to call preventDefault() on pointer up
  42568. * in order to block unwanted artifacts like system double clicks
  42569. */
  42570. preventDefaultOnPointerUp: boolean;
  42571. /**
  42572. * Gets or sets user defined metadata
  42573. */
  42574. metadata: any;
  42575. /**
  42576. * For internal use only. Please do not use.
  42577. */
  42578. reservedDataStore: any;
  42579. /**
  42580. * Gets the name of the plugin used to load this scene (null by default)
  42581. */
  42582. loadingPluginName: string;
  42583. /**
  42584. * Use this array to add regular expressions used to disable offline support for specific urls
  42585. */
  42586. disableOfflineSupportExceptionRules: RegExp[];
  42587. /**
  42588. * An event triggered when the scene is disposed.
  42589. */
  42590. onDisposeObservable: Observable<Scene>;
  42591. private _onDisposeObserver;
  42592. /** Sets a function to be executed when this scene is disposed. */
  42593. set onDispose(callback: () => void);
  42594. /**
  42595. * An event triggered before rendering the scene (right after animations and physics)
  42596. */
  42597. onBeforeRenderObservable: Observable<Scene>;
  42598. private _onBeforeRenderObserver;
  42599. /** Sets a function to be executed before rendering this scene */
  42600. set beforeRender(callback: Nullable<() => void>);
  42601. /**
  42602. * An event triggered after rendering the scene
  42603. */
  42604. onAfterRenderObservable: Observable<Scene>;
  42605. /**
  42606. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42607. */
  42608. onAfterRenderCameraObservable: Observable<Camera>;
  42609. private _onAfterRenderObserver;
  42610. /** Sets a function to be executed after rendering this scene */
  42611. set afterRender(callback: Nullable<() => void>);
  42612. /**
  42613. * An event triggered before animating the scene
  42614. */
  42615. onBeforeAnimationsObservable: Observable<Scene>;
  42616. /**
  42617. * An event triggered after animations processing
  42618. */
  42619. onAfterAnimationsObservable: Observable<Scene>;
  42620. /**
  42621. * An event triggered before draw calls are ready to be sent
  42622. */
  42623. onBeforeDrawPhaseObservable: Observable<Scene>;
  42624. /**
  42625. * An event triggered after draw calls have been sent
  42626. */
  42627. onAfterDrawPhaseObservable: Observable<Scene>;
  42628. /**
  42629. * An event triggered when the scene is ready
  42630. */
  42631. onReadyObservable: Observable<Scene>;
  42632. /**
  42633. * An event triggered before rendering a camera
  42634. */
  42635. onBeforeCameraRenderObservable: Observable<Camera>;
  42636. private _onBeforeCameraRenderObserver;
  42637. /** Sets a function to be executed before rendering a camera*/
  42638. set beforeCameraRender(callback: () => void);
  42639. /**
  42640. * An event triggered after rendering a camera
  42641. */
  42642. onAfterCameraRenderObservable: Observable<Camera>;
  42643. private _onAfterCameraRenderObserver;
  42644. /** Sets a function to be executed after rendering a camera*/
  42645. set afterCameraRender(callback: () => void);
  42646. /**
  42647. * An event triggered when active meshes evaluation is about to start
  42648. */
  42649. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42650. /**
  42651. * An event triggered when active meshes evaluation is done
  42652. */
  42653. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42654. /**
  42655. * An event triggered when particles rendering is about to start
  42656. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42657. */
  42658. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42659. /**
  42660. * An event triggered when particles rendering is done
  42661. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42662. */
  42663. onAfterParticlesRenderingObservable: Observable<Scene>;
  42664. /**
  42665. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42666. */
  42667. onDataLoadedObservable: Observable<Scene>;
  42668. /**
  42669. * An event triggered when a camera is created
  42670. */
  42671. onNewCameraAddedObservable: Observable<Camera>;
  42672. /**
  42673. * An event triggered when a camera is removed
  42674. */
  42675. onCameraRemovedObservable: Observable<Camera>;
  42676. /**
  42677. * An event triggered when a light is created
  42678. */
  42679. onNewLightAddedObservable: Observable<Light>;
  42680. /**
  42681. * An event triggered when a light is removed
  42682. */
  42683. onLightRemovedObservable: Observable<Light>;
  42684. /**
  42685. * An event triggered when a geometry is created
  42686. */
  42687. onNewGeometryAddedObservable: Observable<Geometry>;
  42688. /**
  42689. * An event triggered when a geometry is removed
  42690. */
  42691. onGeometryRemovedObservable: Observable<Geometry>;
  42692. /**
  42693. * An event triggered when a transform node is created
  42694. */
  42695. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42696. /**
  42697. * An event triggered when a transform node is removed
  42698. */
  42699. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42700. /**
  42701. * An event triggered when a mesh is created
  42702. */
  42703. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42704. /**
  42705. * An event triggered when a mesh is removed
  42706. */
  42707. onMeshRemovedObservable: Observable<AbstractMesh>;
  42708. /**
  42709. * An event triggered when a skeleton is created
  42710. */
  42711. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42712. /**
  42713. * An event triggered when a skeleton is removed
  42714. */
  42715. onSkeletonRemovedObservable: Observable<Skeleton>;
  42716. /**
  42717. * An event triggered when a material is created
  42718. */
  42719. onNewMaterialAddedObservable: Observable<Material>;
  42720. /**
  42721. * An event triggered when a material is removed
  42722. */
  42723. onMaterialRemovedObservable: Observable<Material>;
  42724. /**
  42725. * An event triggered when a texture is created
  42726. */
  42727. onNewTextureAddedObservable: Observable<BaseTexture>;
  42728. /**
  42729. * An event triggered when a texture is removed
  42730. */
  42731. onTextureRemovedObservable: Observable<BaseTexture>;
  42732. /**
  42733. * An event triggered when render targets are about to be rendered
  42734. * Can happen multiple times per frame.
  42735. */
  42736. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42737. /**
  42738. * An event triggered when render targets were rendered.
  42739. * Can happen multiple times per frame.
  42740. */
  42741. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42742. /**
  42743. * An event triggered before calculating deterministic simulation step
  42744. */
  42745. onBeforeStepObservable: Observable<Scene>;
  42746. /**
  42747. * An event triggered after calculating deterministic simulation step
  42748. */
  42749. onAfterStepObservable: Observable<Scene>;
  42750. /**
  42751. * An event triggered when the activeCamera property is updated
  42752. */
  42753. onActiveCameraChanged: Observable<Scene>;
  42754. /**
  42755. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42756. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42757. * 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)
  42758. */
  42759. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42760. /**
  42761. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42762. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42763. * 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)
  42764. */
  42765. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42766. /**
  42767. * This Observable will when a mesh has been imported into the scene.
  42768. */
  42769. onMeshImportedObservable: Observable<AbstractMesh>;
  42770. /**
  42771. * This Observable will when an animation file has been imported into the scene.
  42772. */
  42773. onAnimationFileImportedObservable: Observable<Scene>;
  42774. /**
  42775. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42776. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42777. */
  42778. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42779. /** @hidden */
  42780. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42781. /**
  42782. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42783. */
  42784. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  42785. /**
  42786. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  42787. */
  42788. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  42789. /**
  42790. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  42791. */
  42792. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  42793. /** Callback called when a pointer move is detected */
  42794. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42795. /** Callback called when a pointer down is detected */
  42796. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42797. /** Callback called when a pointer up is detected */
  42798. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  42799. /** Callback called when a pointer pick is detected */
  42800. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  42801. /**
  42802. * 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).
  42803. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  42804. */
  42805. onPrePointerObservable: Observable<PointerInfoPre>;
  42806. /**
  42807. * Observable event triggered each time an input event is received from the rendering canvas
  42808. */
  42809. onPointerObservable: Observable<PointerInfo>;
  42810. /**
  42811. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  42812. */
  42813. get unTranslatedPointer(): Vector2;
  42814. /**
  42815. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  42816. */
  42817. static get DragMovementThreshold(): number;
  42818. static set DragMovementThreshold(value: number);
  42819. /**
  42820. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  42821. */
  42822. static get LongPressDelay(): number;
  42823. static set LongPressDelay(value: number);
  42824. /**
  42825. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  42826. */
  42827. static get DoubleClickDelay(): number;
  42828. static set DoubleClickDelay(value: number);
  42829. /** If you need to check double click without raising a single click at first click, enable this flag */
  42830. static get ExclusiveDoubleClickMode(): boolean;
  42831. static set ExclusiveDoubleClickMode(value: boolean);
  42832. /** @hidden */
  42833. _mirroredCameraPosition: Nullable<Vector3>;
  42834. /**
  42835. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  42836. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  42837. */
  42838. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  42839. /**
  42840. * Observable event triggered each time an keyboard event is received from the hosting window
  42841. */
  42842. onKeyboardObservable: Observable<KeyboardInfo>;
  42843. private _useRightHandedSystem;
  42844. /**
  42845. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  42846. */
  42847. set useRightHandedSystem(value: boolean);
  42848. get useRightHandedSystem(): boolean;
  42849. private _timeAccumulator;
  42850. private _currentStepId;
  42851. private _currentInternalStep;
  42852. /**
  42853. * Sets the step Id used by deterministic lock step
  42854. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42855. * @param newStepId defines the step Id
  42856. */
  42857. setStepId(newStepId: number): void;
  42858. /**
  42859. * Gets the step Id used by deterministic lock step
  42860. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42861. * @returns the step Id
  42862. */
  42863. getStepId(): number;
  42864. /**
  42865. * Gets the internal step used by deterministic lock step
  42866. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42867. * @returns the internal step
  42868. */
  42869. getInternalStep(): number;
  42870. private _fogEnabled;
  42871. /**
  42872. * Gets or sets a boolean indicating if fog is enabled on this scene
  42873. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42874. * (Default is true)
  42875. */
  42876. set fogEnabled(value: boolean);
  42877. get fogEnabled(): boolean;
  42878. private _fogMode;
  42879. /**
  42880. * Gets or sets the fog mode to use
  42881. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42882. * | mode | value |
  42883. * | --- | --- |
  42884. * | FOGMODE_NONE | 0 |
  42885. * | FOGMODE_EXP | 1 |
  42886. * | FOGMODE_EXP2 | 2 |
  42887. * | FOGMODE_LINEAR | 3 |
  42888. */
  42889. set fogMode(value: number);
  42890. get fogMode(): number;
  42891. /**
  42892. * Gets or sets the fog color to use
  42893. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42894. * (Default is Color3(0.2, 0.2, 0.3))
  42895. */
  42896. fogColor: Color3;
  42897. /**
  42898. * Gets or sets the fog density to use
  42899. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42900. * (Default is 0.1)
  42901. */
  42902. fogDensity: number;
  42903. /**
  42904. * Gets or sets the fog start distance to use
  42905. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42906. * (Default is 0)
  42907. */
  42908. fogStart: number;
  42909. /**
  42910. * Gets or sets the fog end distance to use
  42911. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42912. * (Default is 1000)
  42913. */
  42914. fogEnd: number;
  42915. /**
  42916. * Flag indicating that the frame buffer binding is handled by another component
  42917. */
  42918. prePass: boolean;
  42919. private _shadowsEnabled;
  42920. /**
  42921. * Gets or sets a boolean indicating if shadows are enabled on this scene
  42922. */
  42923. set shadowsEnabled(value: boolean);
  42924. get shadowsEnabled(): boolean;
  42925. private _lightsEnabled;
  42926. /**
  42927. * Gets or sets a boolean indicating if lights are enabled on this scene
  42928. */
  42929. set lightsEnabled(value: boolean);
  42930. get lightsEnabled(): boolean;
  42931. /** All of the active cameras added to this scene. */
  42932. activeCameras: Camera[];
  42933. /** @hidden */
  42934. _activeCamera: Nullable<Camera>;
  42935. /** Gets or sets the current active camera */
  42936. get activeCamera(): Nullable<Camera>;
  42937. set activeCamera(value: Nullable<Camera>);
  42938. private _defaultMaterial;
  42939. /** The default material used on meshes when no material is affected */
  42940. get defaultMaterial(): Material;
  42941. /** The default material used on meshes when no material is affected */
  42942. set defaultMaterial(value: Material);
  42943. private _texturesEnabled;
  42944. /**
  42945. * Gets or sets a boolean indicating if textures are enabled on this scene
  42946. */
  42947. set texturesEnabled(value: boolean);
  42948. get texturesEnabled(): boolean;
  42949. /**
  42950. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  42951. */
  42952. physicsEnabled: boolean;
  42953. /**
  42954. * Gets or sets a boolean indicating if particles are enabled on this scene
  42955. */
  42956. particlesEnabled: boolean;
  42957. /**
  42958. * Gets or sets a boolean indicating if sprites are enabled on this scene
  42959. */
  42960. spritesEnabled: boolean;
  42961. private _skeletonsEnabled;
  42962. /**
  42963. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  42964. */
  42965. set skeletonsEnabled(value: boolean);
  42966. get skeletonsEnabled(): boolean;
  42967. /**
  42968. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  42969. */
  42970. lensFlaresEnabled: boolean;
  42971. /**
  42972. * Gets or sets a boolean indicating if collisions are enabled on this scene
  42973. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42974. */
  42975. collisionsEnabled: boolean;
  42976. private _collisionCoordinator;
  42977. /** @hidden */
  42978. get collisionCoordinator(): ICollisionCoordinator;
  42979. /**
  42980. * Defines the gravity applied to this scene (used only for collisions)
  42981. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42982. */
  42983. gravity: Vector3;
  42984. /**
  42985. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  42986. */
  42987. postProcessesEnabled: boolean;
  42988. /**
  42989. * Gets the current postprocess manager
  42990. */
  42991. postProcessManager: PostProcessManager;
  42992. /**
  42993. * Gets or sets a boolean indicating if render targets are enabled on this scene
  42994. */
  42995. renderTargetsEnabled: boolean;
  42996. /**
  42997. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  42998. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  42999. */
  43000. dumpNextRenderTargets: boolean;
  43001. /**
  43002. * The list of user defined render targets added to the scene
  43003. */
  43004. customRenderTargets: RenderTargetTexture[];
  43005. /**
  43006. * Defines if texture loading must be delayed
  43007. * If true, textures will only be loaded when they need to be rendered
  43008. */
  43009. useDelayedTextureLoading: boolean;
  43010. /**
  43011. * Gets the list of meshes imported to the scene through SceneLoader
  43012. */
  43013. importedMeshesFiles: String[];
  43014. /**
  43015. * Gets or sets a boolean indicating if probes are enabled on this scene
  43016. */
  43017. probesEnabled: boolean;
  43018. /**
  43019. * Gets or sets the current offline provider to use to store scene data
  43020. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43021. */
  43022. offlineProvider: IOfflineProvider;
  43023. /**
  43024. * Gets or sets the action manager associated with the scene
  43025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43026. */
  43027. actionManager: AbstractActionManager;
  43028. private _meshesForIntersections;
  43029. /**
  43030. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43031. */
  43032. proceduralTexturesEnabled: boolean;
  43033. private _engine;
  43034. private _totalVertices;
  43035. /** @hidden */
  43036. _activeIndices: PerfCounter;
  43037. /** @hidden */
  43038. _activeParticles: PerfCounter;
  43039. /** @hidden */
  43040. _activeBones: PerfCounter;
  43041. private _animationRatio;
  43042. /** @hidden */
  43043. _animationTimeLast: number;
  43044. /** @hidden */
  43045. _animationTime: number;
  43046. /**
  43047. * Gets or sets a general scale for animation speed
  43048. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43049. */
  43050. animationTimeScale: number;
  43051. /** @hidden */
  43052. _cachedMaterial: Nullable<Material>;
  43053. /** @hidden */
  43054. _cachedEffect: Nullable<Effect>;
  43055. /** @hidden */
  43056. _cachedVisibility: Nullable<number>;
  43057. private _renderId;
  43058. private _frameId;
  43059. private _executeWhenReadyTimeoutId;
  43060. private _intermediateRendering;
  43061. private _viewUpdateFlag;
  43062. private _projectionUpdateFlag;
  43063. /** @hidden */
  43064. _toBeDisposed: Nullable<IDisposable>[];
  43065. private _activeRequests;
  43066. /** @hidden */
  43067. _pendingData: any[];
  43068. private _isDisposed;
  43069. /**
  43070. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43071. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43072. */
  43073. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43074. private _activeMeshes;
  43075. private _processedMaterials;
  43076. private _renderTargets;
  43077. /** @hidden */
  43078. _activeParticleSystems: SmartArray<IParticleSystem>;
  43079. private _activeSkeletons;
  43080. private _softwareSkinnedMeshes;
  43081. private _renderingManager;
  43082. /** @hidden */
  43083. _activeAnimatables: Animatable[];
  43084. private _transformMatrix;
  43085. private _sceneUbo;
  43086. /** @hidden */
  43087. _viewMatrix: Matrix;
  43088. private _projectionMatrix;
  43089. /** @hidden */
  43090. _forcedViewPosition: Nullable<Vector3>;
  43091. /** @hidden */
  43092. _frustumPlanes: Plane[];
  43093. /**
  43094. * Gets the list of frustum planes (built from the active camera)
  43095. */
  43096. get frustumPlanes(): Plane[];
  43097. /**
  43098. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43099. * This is useful if there are more lights that the maximum simulteanous authorized
  43100. */
  43101. requireLightSorting: boolean;
  43102. /** @hidden */
  43103. readonly useMaterialMeshMap: boolean;
  43104. /** @hidden */
  43105. readonly useClonedMeshMap: boolean;
  43106. private _externalData;
  43107. private _uid;
  43108. /**
  43109. * @hidden
  43110. * Backing store of defined scene components.
  43111. */
  43112. _components: ISceneComponent[];
  43113. /**
  43114. * @hidden
  43115. * Backing store of defined scene components.
  43116. */
  43117. _serializableComponents: ISceneSerializableComponent[];
  43118. /**
  43119. * List of components to register on the next registration step.
  43120. */
  43121. private _transientComponents;
  43122. /**
  43123. * Registers the transient components if needed.
  43124. */
  43125. private _registerTransientComponents;
  43126. /**
  43127. * @hidden
  43128. * Add a component to the scene.
  43129. * Note that the ccomponent could be registered on th next frame if this is called after
  43130. * the register component stage.
  43131. * @param component Defines the component to add to the scene
  43132. */
  43133. _addComponent(component: ISceneComponent): void;
  43134. /**
  43135. * @hidden
  43136. * Gets a component from the scene.
  43137. * @param name defines the name of the component to retrieve
  43138. * @returns the component or null if not present
  43139. */
  43140. _getComponent(name: string): Nullable<ISceneComponent>;
  43141. /**
  43142. * @hidden
  43143. * Defines the actions happening before camera updates.
  43144. */
  43145. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43146. /**
  43147. * @hidden
  43148. * Defines the actions happening before clear the canvas.
  43149. */
  43150. _beforeClearStage: Stage<SimpleStageAction>;
  43151. /**
  43152. * @hidden
  43153. * Defines the actions when collecting render targets for the frame.
  43154. */
  43155. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43156. /**
  43157. * @hidden
  43158. * Defines the actions happening for one camera in the frame.
  43159. */
  43160. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43161. /**
  43162. * @hidden
  43163. * Defines the actions happening during the per mesh ready checks.
  43164. */
  43165. _isReadyForMeshStage: Stage<MeshStageAction>;
  43166. /**
  43167. * @hidden
  43168. * Defines the actions happening before evaluate active mesh checks.
  43169. */
  43170. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43171. /**
  43172. * @hidden
  43173. * Defines the actions happening during the evaluate sub mesh checks.
  43174. */
  43175. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43176. /**
  43177. * @hidden
  43178. * Defines the actions happening during the active mesh stage.
  43179. */
  43180. _activeMeshStage: Stage<ActiveMeshStageAction>;
  43181. /**
  43182. * @hidden
  43183. * Defines the actions happening during the per camera render target step.
  43184. */
  43185. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43186. /**
  43187. * @hidden
  43188. * Defines the actions happening just before the active camera is drawing.
  43189. */
  43190. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43191. /**
  43192. * @hidden
  43193. * Defines the actions happening just before a render target is drawing.
  43194. */
  43195. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43196. /**
  43197. * @hidden
  43198. * Defines the actions happening just before a rendering group is drawing.
  43199. */
  43200. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43201. /**
  43202. * @hidden
  43203. * Defines the actions happening just before a mesh is drawing.
  43204. */
  43205. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43206. /**
  43207. * @hidden
  43208. * Defines the actions happening just after a mesh has been drawn.
  43209. */
  43210. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43211. /**
  43212. * @hidden
  43213. * Defines the actions happening just after a rendering group has been drawn.
  43214. */
  43215. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43216. /**
  43217. * @hidden
  43218. * Defines the actions happening just after the active camera has been drawn.
  43219. */
  43220. _afterCameraDrawStage: Stage<CameraStageAction>;
  43221. /**
  43222. * @hidden
  43223. * Defines the actions happening just after a render target has been drawn.
  43224. */
  43225. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43226. /**
  43227. * @hidden
  43228. * Defines the actions happening just after rendering all cameras and computing intersections.
  43229. */
  43230. _afterRenderStage: Stage<SimpleStageAction>;
  43231. /**
  43232. * @hidden
  43233. * Defines the actions happening when a pointer move event happens.
  43234. */
  43235. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43236. /**
  43237. * @hidden
  43238. * Defines the actions happening when a pointer down event happens.
  43239. */
  43240. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43241. /**
  43242. * @hidden
  43243. * Defines the actions happening when a pointer up event happens.
  43244. */
  43245. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43246. /**
  43247. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43248. */
  43249. private geometriesByUniqueId;
  43250. /**
  43251. * Creates a new Scene
  43252. * @param engine defines the engine to use to render this scene
  43253. * @param options defines the scene options
  43254. */
  43255. constructor(engine: Engine, options?: SceneOptions);
  43256. /**
  43257. * Gets a string identifying the name of the class
  43258. * @returns "Scene" string
  43259. */
  43260. getClassName(): string;
  43261. private _defaultMeshCandidates;
  43262. /**
  43263. * @hidden
  43264. */
  43265. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43266. private _defaultSubMeshCandidates;
  43267. /**
  43268. * @hidden
  43269. */
  43270. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43271. /**
  43272. * Sets the default candidate providers for the scene.
  43273. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43274. * and getCollidingSubMeshCandidates to their default function
  43275. */
  43276. setDefaultCandidateProviders(): void;
  43277. /**
  43278. * Gets the mesh that is currently under the pointer
  43279. */
  43280. get meshUnderPointer(): Nullable<AbstractMesh>;
  43281. /**
  43282. * Gets or sets the current on-screen X position of the pointer
  43283. */
  43284. get pointerX(): number;
  43285. set pointerX(value: number);
  43286. /**
  43287. * Gets or sets the current on-screen Y position of the pointer
  43288. */
  43289. get pointerY(): number;
  43290. set pointerY(value: number);
  43291. /**
  43292. * Gets the cached material (ie. the latest rendered one)
  43293. * @returns the cached material
  43294. */
  43295. getCachedMaterial(): Nullable<Material>;
  43296. /**
  43297. * Gets the cached effect (ie. the latest rendered one)
  43298. * @returns the cached effect
  43299. */
  43300. getCachedEffect(): Nullable<Effect>;
  43301. /**
  43302. * Gets the cached visibility state (ie. the latest rendered one)
  43303. * @returns the cached visibility state
  43304. */
  43305. getCachedVisibility(): Nullable<number>;
  43306. /**
  43307. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43308. * @param material defines the current material
  43309. * @param effect defines the current effect
  43310. * @param visibility defines the current visibility state
  43311. * @returns true if one parameter is not cached
  43312. */
  43313. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43314. /**
  43315. * Gets the engine associated with the scene
  43316. * @returns an Engine
  43317. */
  43318. getEngine(): Engine;
  43319. /**
  43320. * Gets the total number of vertices rendered per frame
  43321. * @returns the total number of vertices rendered per frame
  43322. */
  43323. getTotalVertices(): number;
  43324. /**
  43325. * Gets the performance counter for total vertices
  43326. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43327. */
  43328. get totalVerticesPerfCounter(): PerfCounter;
  43329. /**
  43330. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43331. * @returns the total number of active indices rendered per frame
  43332. */
  43333. getActiveIndices(): number;
  43334. /**
  43335. * Gets the performance counter for active indices
  43336. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43337. */
  43338. get totalActiveIndicesPerfCounter(): PerfCounter;
  43339. /**
  43340. * Gets the total number of active particles rendered per frame
  43341. * @returns the total number of active particles rendered per frame
  43342. */
  43343. getActiveParticles(): number;
  43344. /**
  43345. * Gets the performance counter for active particles
  43346. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43347. */
  43348. get activeParticlesPerfCounter(): PerfCounter;
  43349. /**
  43350. * Gets the total number of active bones rendered per frame
  43351. * @returns the total number of active bones rendered per frame
  43352. */
  43353. getActiveBones(): number;
  43354. /**
  43355. * Gets the performance counter for active bones
  43356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43357. */
  43358. get activeBonesPerfCounter(): PerfCounter;
  43359. /**
  43360. * Gets the array of active meshes
  43361. * @returns an array of AbstractMesh
  43362. */
  43363. getActiveMeshes(): SmartArray<AbstractMesh>;
  43364. /**
  43365. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43366. * @returns a number
  43367. */
  43368. getAnimationRatio(): number;
  43369. /**
  43370. * Gets an unique Id for the current render phase
  43371. * @returns a number
  43372. */
  43373. getRenderId(): number;
  43374. /**
  43375. * Gets an unique Id for the current frame
  43376. * @returns a number
  43377. */
  43378. getFrameId(): number;
  43379. /** Call this function if you want to manually increment the render Id*/
  43380. incrementRenderId(): void;
  43381. private _createUbo;
  43382. /**
  43383. * Use this method to simulate a pointer move on a mesh
  43384. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43385. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43386. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43387. * @returns the current scene
  43388. */
  43389. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43390. /**
  43391. * Use this method to simulate a pointer down on a mesh
  43392. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43393. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43394. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43395. * @returns the current scene
  43396. */
  43397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43398. /**
  43399. * Use this method to simulate a pointer up on a mesh
  43400. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43401. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43402. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43403. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43404. * @returns the current scene
  43405. */
  43406. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43407. /**
  43408. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43409. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43410. * @returns true if the pointer was captured
  43411. */
  43412. isPointerCaptured(pointerId?: number): boolean;
  43413. /**
  43414. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43415. * @param attachUp defines if you want to attach events to pointerup
  43416. * @param attachDown defines if you want to attach events to pointerdown
  43417. * @param attachMove defines if you want to attach events to pointermove
  43418. */
  43419. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43420. /** Detaches all event handlers*/
  43421. detachControl(): void;
  43422. /**
  43423. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43424. * Delay loaded resources are not taking in account
  43425. * @return true if all required resources are ready
  43426. */
  43427. isReady(): boolean;
  43428. /** Resets all cached information relative to material (including effect and visibility) */
  43429. resetCachedMaterial(): void;
  43430. /**
  43431. * Registers a function to be called before every frame render
  43432. * @param func defines the function to register
  43433. */
  43434. registerBeforeRender(func: () => void): void;
  43435. /**
  43436. * Unregisters a function called before every frame render
  43437. * @param func defines the function to unregister
  43438. */
  43439. unregisterBeforeRender(func: () => void): void;
  43440. /**
  43441. * Registers a function to be called after every frame render
  43442. * @param func defines the function to register
  43443. */
  43444. registerAfterRender(func: () => void): void;
  43445. /**
  43446. * Unregisters a function called after every frame render
  43447. * @param func defines the function to unregister
  43448. */
  43449. unregisterAfterRender(func: () => void): void;
  43450. private _executeOnceBeforeRender;
  43451. /**
  43452. * The provided function will run before render once and will be disposed afterwards.
  43453. * A timeout delay can be provided so that the function will be executed in N ms.
  43454. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43455. * @param func The function to be executed.
  43456. * @param timeout optional delay in ms
  43457. */
  43458. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43459. /** @hidden */
  43460. _addPendingData(data: any): void;
  43461. /** @hidden */
  43462. _removePendingData(data: any): void;
  43463. /**
  43464. * Returns the number of items waiting to be loaded
  43465. * @returns the number of items waiting to be loaded
  43466. */
  43467. getWaitingItemsCount(): number;
  43468. /**
  43469. * Returns a boolean indicating if the scene is still loading data
  43470. */
  43471. get isLoading(): boolean;
  43472. /**
  43473. * Registers a function to be executed when the scene is ready
  43474. * @param {Function} func - the function to be executed
  43475. */
  43476. executeWhenReady(func: () => void): void;
  43477. /**
  43478. * Returns a promise that resolves when the scene is ready
  43479. * @returns A promise that resolves when the scene is ready
  43480. */
  43481. whenReadyAsync(): Promise<void>;
  43482. /** @hidden */
  43483. _checkIsReady(): void;
  43484. /**
  43485. * Gets all animatable attached to the scene
  43486. */
  43487. get animatables(): Animatable[];
  43488. /**
  43489. * Resets the last animation time frame.
  43490. * Useful to override when animations start running when loading a scene for the first time.
  43491. */
  43492. resetLastAnimationTimeFrame(): void;
  43493. /**
  43494. * Gets the current view matrix
  43495. * @returns a Matrix
  43496. */
  43497. getViewMatrix(): Matrix;
  43498. /**
  43499. * Gets the current projection matrix
  43500. * @returns a Matrix
  43501. */
  43502. getProjectionMatrix(): Matrix;
  43503. /**
  43504. * Gets the current transform matrix
  43505. * @returns a Matrix made of View * Projection
  43506. */
  43507. getTransformMatrix(): Matrix;
  43508. /**
  43509. * Sets the current transform matrix
  43510. * @param viewL defines the View matrix to use
  43511. * @param projectionL defines the Projection matrix to use
  43512. * @param viewR defines the right View matrix to use (if provided)
  43513. * @param projectionR defines the right Projection matrix to use (if provided)
  43514. */
  43515. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43516. /**
  43517. * Gets the uniform buffer used to store scene data
  43518. * @returns a UniformBuffer
  43519. */
  43520. getSceneUniformBuffer(): UniformBuffer;
  43521. /**
  43522. * Gets an unique (relatively to the current scene) Id
  43523. * @returns an unique number for the scene
  43524. */
  43525. getUniqueId(): number;
  43526. /**
  43527. * Add a mesh to the list of scene's meshes
  43528. * @param newMesh defines the mesh to add
  43529. * @param recursive if all child meshes should also be added to the scene
  43530. */
  43531. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43532. /**
  43533. * Remove a mesh for the list of scene's meshes
  43534. * @param toRemove defines the mesh to remove
  43535. * @param recursive if all child meshes should also be removed from the scene
  43536. * @returns the index where the mesh was in the mesh list
  43537. */
  43538. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43539. /**
  43540. * Add a transform node to the list of scene's transform nodes
  43541. * @param newTransformNode defines the transform node to add
  43542. */
  43543. addTransformNode(newTransformNode: TransformNode): void;
  43544. /**
  43545. * Remove a transform node for the list of scene's transform nodes
  43546. * @param toRemove defines the transform node to remove
  43547. * @returns the index where the transform node was in the transform node list
  43548. */
  43549. removeTransformNode(toRemove: TransformNode): number;
  43550. /**
  43551. * Remove a skeleton for the list of scene's skeletons
  43552. * @param toRemove defines the skeleton to remove
  43553. * @returns the index where the skeleton was in the skeleton list
  43554. */
  43555. removeSkeleton(toRemove: Skeleton): number;
  43556. /**
  43557. * Remove a morph target for the list of scene's morph targets
  43558. * @param toRemove defines the morph target to remove
  43559. * @returns the index where the morph target was in the morph target list
  43560. */
  43561. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43562. /**
  43563. * Remove a light for the list of scene's lights
  43564. * @param toRemove defines the light to remove
  43565. * @returns the index where the light was in the light list
  43566. */
  43567. removeLight(toRemove: Light): number;
  43568. /**
  43569. * Remove a camera for the list of scene's cameras
  43570. * @param toRemove defines the camera to remove
  43571. * @returns the index where the camera was in the camera list
  43572. */
  43573. removeCamera(toRemove: Camera): number;
  43574. /**
  43575. * Remove a particle system for the list of scene's particle systems
  43576. * @param toRemove defines the particle system to remove
  43577. * @returns the index where the particle system was in the particle system list
  43578. */
  43579. removeParticleSystem(toRemove: IParticleSystem): number;
  43580. /**
  43581. * Remove a animation for the list of scene's animations
  43582. * @param toRemove defines the animation to remove
  43583. * @returns the index where the animation was in the animation list
  43584. */
  43585. removeAnimation(toRemove: Animation): number;
  43586. /**
  43587. * Will stop the animation of the given target
  43588. * @param target - the target
  43589. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43590. * @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)
  43591. */
  43592. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43593. /**
  43594. * Removes the given animation group from this scene.
  43595. * @param toRemove The animation group to remove
  43596. * @returns The index of the removed animation group
  43597. */
  43598. removeAnimationGroup(toRemove: AnimationGroup): number;
  43599. /**
  43600. * Removes the given multi-material from this scene.
  43601. * @param toRemove The multi-material to remove
  43602. * @returns The index of the removed multi-material
  43603. */
  43604. removeMultiMaterial(toRemove: MultiMaterial): number;
  43605. /**
  43606. * Removes the given material from this scene.
  43607. * @param toRemove The material to remove
  43608. * @returns The index of the removed material
  43609. */
  43610. removeMaterial(toRemove: Material): number;
  43611. /**
  43612. * Removes the given action manager from this scene.
  43613. * @param toRemove The action manager to remove
  43614. * @returns The index of the removed action manager
  43615. */
  43616. removeActionManager(toRemove: AbstractActionManager): number;
  43617. /**
  43618. * Removes the given texture from this scene.
  43619. * @param toRemove The texture to remove
  43620. * @returns The index of the removed texture
  43621. */
  43622. removeTexture(toRemove: BaseTexture): number;
  43623. /**
  43624. * Adds the given light to this scene
  43625. * @param newLight The light to add
  43626. */
  43627. addLight(newLight: Light): void;
  43628. /**
  43629. * Sorts the list list based on light priorities
  43630. */
  43631. sortLightsByPriority(): void;
  43632. /**
  43633. * Adds the given camera to this scene
  43634. * @param newCamera The camera to add
  43635. */
  43636. addCamera(newCamera: Camera): void;
  43637. /**
  43638. * Adds the given skeleton to this scene
  43639. * @param newSkeleton The skeleton to add
  43640. */
  43641. addSkeleton(newSkeleton: Skeleton): void;
  43642. /**
  43643. * Adds the given particle system to this scene
  43644. * @param newParticleSystem The particle system to add
  43645. */
  43646. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43647. /**
  43648. * Adds the given animation to this scene
  43649. * @param newAnimation The animation to add
  43650. */
  43651. addAnimation(newAnimation: Animation): void;
  43652. /**
  43653. * Adds the given animation group to this scene.
  43654. * @param newAnimationGroup The animation group to add
  43655. */
  43656. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43657. /**
  43658. * Adds the given multi-material to this scene
  43659. * @param newMultiMaterial The multi-material to add
  43660. */
  43661. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43662. /**
  43663. * Adds the given material to this scene
  43664. * @param newMaterial The material to add
  43665. */
  43666. addMaterial(newMaterial: Material): void;
  43667. /**
  43668. * Adds the given morph target to this scene
  43669. * @param newMorphTargetManager The morph target to add
  43670. */
  43671. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43672. /**
  43673. * Adds the given geometry to this scene
  43674. * @param newGeometry The geometry to add
  43675. */
  43676. addGeometry(newGeometry: Geometry): void;
  43677. /**
  43678. * Adds the given action manager to this scene
  43679. * @param newActionManager The action manager to add
  43680. */
  43681. addActionManager(newActionManager: AbstractActionManager): void;
  43682. /**
  43683. * Adds the given texture to this scene.
  43684. * @param newTexture The texture to add
  43685. */
  43686. addTexture(newTexture: BaseTexture): void;
  43687. /**
  43688. * Switch active camera
  43689. * @param newCamera defines the new active camera
  43690. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43691. */
  43692. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43693. /**
  43694. * sets the active camera of the scene using its ID
  43695. * @param id defines the camera's ID
  43696. * @return the new active camera or null if none found.
  43697. */
  43698. setActiveCameraByID(id: string): Nullable<Camera>;
  43699. /**
  43700. * sets the active camera of the scene using its name
  43701. * @param name defines the camera's name
  43702. * @returns the new active camera or null if none found.
  43703. */
  43704. setActiveCameraByName(name: string): Nullable<Camera>;
  43705. /**
  43706. * get an animation group using its name
  43707. * @param name defines the material's name
  43708. * @return the animation group or null if none found.
  43709. */
  43710. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43711. /**
  43712. * Get a material using its unique id
  43713. * @param uniqueId defines the material's unique id
  43714. * @return the material or null if none found.
  43715. */
  43716. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43717. /**
  43718. * get a material using its id
  43719. * @param id defines the material's ID
  43720. * @return the material or null if none found.
  43721. */
  43722. getMaterialByID(id: string): Nullable<Material>;
  43723. /**
  43724. * Gets a the last added material using a given id
  43725. * @param id defines the material's ID
  43726. * @return the last material with the given id or null if none found.
  43727. */
  43728. getLastMaterialByID(id: string): Nullable<Material>;
  43729. /**
  43730. * Gets a material using its name
  43731. * @param name defines the material's name
  43732. * @return the material or null if none found.
  43733. */
  43734. getMaterialByName(name: string): Nullable<Material>;
  43735. /**
  43736. * Get a texture using its unique id
  43737. * @param uniqueId defines the texture's unique id
  43738. * @return the texture or null if none found.
  43739. */
  43740. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43741. /**
  43742. * Gets a camera using its id
  43743. * @param id defines the id to look for
  43744. * @returns the camera or null if not found
  43745. */
  43746. getCameraByID(id: string): Nullable<Camera>;
  43747. /**
  43748. * Gets a camera using its unique id
  43749. * @param uniqueId defines the unique id to look for
  43750. * @returns the camera or null if not found
  43751. */
  43752. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43753. /**
  43754. * Gets a camera using its name
  43755. * @param name defines the camera's name
  43756. * @return the camera or null if none found.
  43757. */
  43758. getCameraByName(name: string): Nullable<Camera>;
  43759. /**
  43760. * Gets a bone using its id
  43761. * @param id defines the bone's id
  43762. * @return the bone or null if not found
  43763. */
  43764. getBoneByID(id: string): Nullable<Bone>;
  43765. /**
  43766. * Gets a bone using its id
  43767. * @param name defines the bone's name
  43768. * @return the bone or null if not found
  43769. */
  43770. getBoneByName(name: string): Nullable<Bone>;
  43771. /**
  43772. * Gets a light node using its name
  43773. * @param name defines the the light's name
  43774. * @return the light or null if none found.
  43775. */
  43776. getLightByName(name: string): Nullable<Light>;
  43777. /**
  43778. * Gets a light node using its id
  43779. * @param id defines the light's id
  43780. * @return the light or null if none found.
  43781. */
  43782. getLightByID(id: string): Nullable<Light>;
  43783. /**
  43784. * Gets a light node using its scene-generated unique ID
  43785. * @param uniqueId defines the light's unique id
  43786. * @return the light or null if none found.
  43787. */
  43788. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  43789. /**
  43790. * Gets a particle system by id
  43791. * @param id defines the particle system id
  43792. * @return the corresponding system or null if none found
  43793. */
  43794. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  43795. /**
  43796. * Gets a geometry using its ID
  43797. * @param id defines the geometry's id
  43798. * @return the geometry or null if none found.
  43799. */
  43800. getGeometryByID(id: string): Nullable<Geometry>;
  43801. private _getGeometryByUniqueID;
  43802. /**
  43803. * Add a new geometry to this scene
  43804. * @param geometry defines the geometry to be added to the scene.
  43805. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  43806. * @return a boolean defining if the geometry was added or not
  43807. */
  43808. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  43809. /**
  43810. * Removes an existing geometry
  43811. * @param geometry defines the geometry to be removed from the scene
  43812. * @return a boolean defining if the geometry was removed or not
  43813. */
  43814. removeGeometry(geometry: Geometry): boolean;
  43815. /**
  43816. * Gets the list of geometries attached to the scene
  43817. * @returns an array of Geometry
  43818. */
  43819. getGeometries(): Geometry[];
  43820. /**
  43821. * Gets the first added mesh found of a given ID
  43822. * @param id defines the id to search for
  43823. * @return the mesh found or null if not found at all
  43824. */
  43825. getMeshByID(id: string): Nullable<AbstractMesh>;
  43826. /**
  43827. * Gets a list of meshes using their id
  43828. * @param id defines the id to search for
  43829. * @returns a list of meshes
  43830. */
  43831. getMeshesByID(id: string): Array<AbstractMesh>;
  43832. /**
  43833. * Gets the first added transform node found of a given ID
  43834. * @param id defines the id to search for
  43835. * @return the found transform node or null if not found at all.
  43836. */
  43837. getTransformNodeByID(id: string): Nullable<TransformNode>;
  43838. /**
  43839. * Gets a transform node with its auto-generated unique id
  43840. * @param uniqueId efines the unique id to search for
  43841. * @return the found transform node or null if not found at all.
  43842. */
  43843. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  43844. /**
  43845. * Gets a list of transform nodes using their id
  43846. * @param id defines the id to search for
  43847. * @returns a list of transform nodes
  43848. */
  43849. getTransformNodesByID(id: string): Array<TransformNode>;
  43850. /**
  43851. * Gets a mesh with its auto-generated unique id
  43852. * @param uniqueId defines the unique id to search for
  43853. * @return the found mesh or null if not found at all.
  43854. */
  43855. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  43856. /**
  43857. * Gets a the last added mesh using a given id
  43858. * @param id defines the id to search for
  43859. * @return the found mesh or null if not found at all.
  43860. */
  43861. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  43862. /**
  43863. * Gets a the last added node (Mesh, Camera, Light) using a given id
  43864. * @param id defines the id to search for
  43865. * @return the found node or null if not found at all
  43866. */
  43867. getLastEntryByID(id: string): Nullable<Node>;
  43868. /**
  43869. * Gets a node (Mesh, Camera, Light) using a given id
  43870. * @param id defines the id to search for
  43871. * @return the found node or null if not found at all
  43872. */
  43873. getNodeByID(id: string): Nullable<Node>;
  43874. /**
  43875. * Gets a node (Mesh, Camera, Light) using a given name
  43876. * @param name defines the name to search for
  43877. * @return the found node or null if not found at all.
  43878. */
  43879. getNodeByName(name: string): Nullable<Node>;
  43880. /**
  43881. * Gets a mesh using a given name
  43882. * @param name defines the name to search for
  43883. * @return the found mesh or null if not found at all.
  43884. */
  43885. getMeshByName(name: string): Nullable<AbstractMesh>;
  43886. /**
  43887. * Gets a transform node using a given name
  43888. * @param name defines the name to search for
  43889. * @return the found transform node or null if not found at all.
  43890. */
  43891. getTransformNodeByName(name: string): Nullable<TransformNode>;
  43892. /**
  43893. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  43894. * @param id defines the id to search for
  43895. * @return the found skeleton or null if not found at all.
  43896. */
  43897. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  43898. /**
  43899. * Gets a skeleton using a given auto generated unique id
  43900. * @param uniqueId defines the unique id to search for
  43901. * @return the found skeleton or null if not found at all.
  43902. */
  43903. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  43904. /**
  43905. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  43906. * @param id defines the id to search for
  43907. * @return the found skeleton or null if not found at all.
  43908. */
  43909. getSkeletonById(id: string): Nullable<Skeleton>;
  43910. /**
  43911. * Gets a skeleton using a given name
  43912. * @param name defines the name to search for
  43913. * @return the found skeleton or null if not found at all.
  43914. */
  43915. getSkeletonByName(name: string): Nullable<Skeleton>;
  43916. /**
  43917. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  43918. * @param id defines the id to search for
  43919. * @return the found morph target manager or null if not found at all.
  43920. */
  43921. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  43922. /**
  43923. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  43924. * @param id defines the id to search for
  43925. * @return the found morph target or null if not found at all.
  43926. */
  43927. getMorphTargetById(id: string): Nullable<MorphTarget>;
  43928. /**
  43929. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  43930. * @param name defines the name to search for
  43931. * @return the found morph target or null if not found at all.
  43932. */
  43933. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  43934. /**
  43935. * Gets a post process using a given name (if many are found, this function will pick the first one)
  43936. * @param name defines the name to search for
  43937. * @return the found post process or null if not found at all.
  43938. */
  43939. getPostProcessByName(name: string): Nullable<PostProcess>;
  43940. /**
  43941. * Gets a boolean indicating if the given mesh is active
  43942. * @param mesh defines the mesh to look for
  43943. * @returns true if the mesh is in the active list
  43944. */
  43945. isActiveMesh(mesh: AbstractMesh): boolean;
  43946. /**
  43947. * Return a unique id as a string which can serve as an identifier for the scene
  43948. */
  43949. get uid(): string;
  43950. /**
  43951. * Add an externaly attached data from its key.
  43952. * This method call will fail and return false, if such key already exists.
  43953. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  43954. * @param key the unique key that identifies the data
  43955. * @param data the data object to associate to the key for this Engine instance
  43956. * @return true if no such key were already present and the data was added successfully, false otherwise
  43957. */
  43958. addExternalData<T>(key: string, data: T): boolean;
  43959. /**
  43960. * Get an externaly attached data from its key
  43961. * @param key the unique key that identifies the data
  43962. * @return the associated data, if present (can be null), or undefined if not present
  43963. */
  43964. getExternalData<T>(key: string): Nullable<T>;
  43965. /**
  43966. * Get an externaly attached data from its key, create it using a factory if it's not already present
  43967. * @param key the unique key that identifies the data
  43968. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  43969. * @return the associated data, can be null if the factory returned null.
  43970. */
  43971. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  43972. /**
  43973. * Remove an externaly attached data from the Engine instance
  43974. * @param key the unique key that identifies the data
  43975. * @return true if the data was successfully removed, false if it doesn't exist
  43976. */
  43977. removeExternalData(key: string): boolean;
  43978. private _evaluateSubMesh;
  43979. /**
  43980. * Clear the processed materials smart array preventing retention point in material dispose.
  43981. */
  43982. freeProcessedMaterials(): void;
  43983. private _preventFreeActiveMeshesAndRenderingGroups;
  43984. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  43985. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  43986. * when disposing several meshes in a row or a hierarchy of meshes.
  43987. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  43988. */
  43989. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  43990. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  43991. /**
  43992. * Clear the active meshes smart array preventing retention point in mesh dispose.
  43993. */
  43994. freeActiveMeshes(): void;
  43995. /**
  43996. * Clear the info related to rendering groups preventing retention points during dispose.
  43997. */
  43998. freeRenderingGroups(): void;
  43999. /** @hidden */
  44000. _isInIntermediateRendering(): boolean;
  44001. /**
  44002. * Lambda returning the list of potentially active meshes.
  44003. */
  44004. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44005. /**
  44006. * Lambda returning the list of potentially active sub meshes.
  44007. */
  44008. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44009. /**
  44010. * Lambda returning the list of potentially intersecting sub meshes.
  44011. */
  44012. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44013. /**
  44014. * Lambda returning the list of potentially colliding sub meshes.
  44015. */
  44016. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44017. private _activeMeshesFrozen;
  44018. private _skipEvaluateActiveMeshesCompletely;
  44019. /**
  44020. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44021. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44022. * @param onSuccess optional success callback
  44023. * @param onError optional error callback
  44024. * @returns the current scene
  44025. */
  44026. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44027. /**
  44028. * Use this function to restart evaluating active meshes on every frame
  44029. * @returns the current scene
  44030. */
  44031. unfreezeActiveMeshes(): Scene;
  44032. private _evaluateActiveMeshes;
  44033. private _activeMesh;
  44034. /**
  44035. * Update the transform matrix to update from the current active camera
  44036. * @param force defines a boolean used to force the update even if cache is up to date
  44037. */
  44038. updateTransformMatrix(force?: boolean): void;
  44039. private _bindFrameBuffer;
  44040. /** @hidden */
  44041. _allowPostProcessClearColor: boolean;
  44042. /** @hidden */
  44043. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44044. private _processSubCameras;
  44045. private _checkIntersections;
  44046. /** @hidden */
  44047. _advancePhysicsEngineStep(step: number): void;
  44048. /**
  44049. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44050. */
  44051. getDeterministicFrameTime: () => number;
  44052. /** @hidden */
  44053. _animate(): void;
  44054. /** Execute all animations (for a frame) */
  44055. animate(): void;
  44056. /**
  44057. * Render the scene
  44058. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44059. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44060. */
  44061. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44062. /**
  44063. * Freeze all materials
  44064. * A frozen material will not be updatable but should be faster to render
  44065. */
  44066. freezeMaterials(): void;
  44067. /**
  44068. * Unfreeze all materials
  44069. * A frozen material will not be updatable but should be faster to render
  44070. */
  44071. unfreezeMaterials(): void;
  44072. /**
  44073. * Releases all held ressources
  44074. */
  44075. dispose(): void;
  44076. /**
  44077. * Gets if the scene is already disposed
  44078. */
  44079. get isDisposed(): boolean;
  44080. /**
  44081. * Call this function to reduce memory footprint of the scene.
  44082. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44083. */
  44084. clearCachedVertexData(): void;
  44085. /**
  44086. * This function will remove the local cached buffer data from texture.
  44087. * It will save memory but will prevent the texture from being rebuilt
  44088. */
  44089. cleanCachedTextureBuffer(): void;
  44090. /**
  44091. * Get the world extend vectors with an optional filter
  44092. *
  44093. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44094. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44095. */
  44096. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44097. min: Vector3;
  44098. max: Vector3;
  44099. };
  44100. /**
  44101. * Creates a ray that can be used to pick in the scene
  44102. * @param x defines the x coordinate of the origin (on-screen)
  44103. * @param y defines the y coordinate of the origin (on-screen)
  44104. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44105. * @param camera defines the camera to use for the picking
  44106. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44107. * @returns a Ray
  44108. */
  44109. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44110. /**
  44111. * Creates a ray that can be used to pick in the scene
  44112. * @param x defines the x coordinate of the origin (on-screen)
  44113. * @param y defines the y coordinate of the origin (on-screen)
  44114. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44115. * @param result defines the ray where to store the picking ray
  44116. * @param camera defines the camera to use for the picking
  44117. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44118. * @returns the current scene
  44119. */
  44120. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44121. /**
  44122. * Creates a ray that can be used to pick in the scene
  44123. * @param x defines the x coordinate of the origin (on-screen)
  44124. * @param y defines the y coordinate of the origin (on-screen)
  44125. * @param camera defines the camera to use for the picking
  44126. * @returns a Ray
  44127. */
  44128. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44129. /**
  44130. * Creates a ray that can be used to pick in the scene
  44131. * @param x defines the x coordinate of the origin (on-screen)
  44132. * @param y defines the y coordinate of the origin (on-screen)
  44133. * @param result defines the ray where to store the picking ray
  44134. * @param camera defines the camera to use for the picking
  44135. * @returns the current scene
  44136. */
  44137. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44138. /** Launch a ray to try to pick a mesh in the scene
  44139. * @param x position on screen
  44140. * @param y position on screen
  44141. * @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
  44142. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44143. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44144. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44145. * @returns a PickingInfo
  44146. */
  44147. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44148. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44149. * @param x position on screen
  44150. * @param y position on screen
  44151. * @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
  44152. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44153. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44154. * @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)
  44155. */
  44156. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44157. /** Use the given ray to pick a mesh in the scene
  44158. * @param ray The ray to use to pick meshes
  44159. * @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
  44160. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44161. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44162. * @returns a PickingInfo
  44163. */
  44164. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44165. /**
  44166. * Launch a ray to try to pick a mesh in the scene
  44167. * @param x X position on screen
  44168. * @param y 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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44172. * @returns an array of PickingInfo
  44173. */
  44174. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44175. /**
  44176. * Launch a ray to try to pick a mesh in the scene
  44177. * @param ray Ray to use
  44178. * @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
  44179. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44180. * @returns an array of PickingInfo
  44181. */
  44182. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44183. /**
  44184. * Force the value of meshUnderPointer
  44185. * @param mesh defines the mesh to use
  44186. * @param pointerId optional pointer id when using more than one pointer
  44187. */
  44188. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44189. /**
  44190. * Gets the mesh under the pointer
  44191. * @returns a Mesh or null if no mesh is under the pointer
  44192. */
  44193. getPointerOverMesh(): Nullable<AbstractMesh>;
  44194. /** @hidden */
  44195. _rebuildGeometries(): void;
  44196. /** @hidden */
  44197. _rebuildTextures(): void;
  44198. private _getByTags;
  44199. /**
  44200. * Get a list of meshes by tags
  44201. * @param tagsQuery defines the tags query to use
  44202. * @param forEach defines a predicate used to filter results
  44203. * @returns an array of Mesh
  44204. */
  44205. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44206. /**
  44207. * Get a list of cameras by tags
  44208. * @param tagsQuery defines the tags query to use
  44209. * @param forEach defines a predicate used to filter results
  44210. * @returns an array of Camera
  44211. */
  44212. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44213. /**
  44214. * Get a list of lights by tags
  44215. * @param tagsQuery defines the tags query to use
  44216. * @param forEach defines a predicate used to filter results
  44217. * @returns an array of Light
  44218. */
  44219. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44220. /**
  44221. * Get a list of materials by tags
  44222. * @param tagsQuery defines the tags query to use
  44223. * @param forEach defines a predicate used to filter results
  44224. * @returns an array of Material
  44225. */
  44226. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44227. /**
  44228. * Get a list of transform nodes 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 TransformNode
  44232. */
  44233. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44234. /**
  44235. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44236. * This allowed control for front to back rendering or reversly depending of the special needs.
  44237. *
  44238. * @param renderingGroupId The rendering group id corresponding to its index
  44239. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44240. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44241. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44242. */
  44243. 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;
  44244. /**
  44245. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44246. *
  44247. * @param renderingGroupId The rendering group id corresponding to its index
  44248. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44249. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44250. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44251. */
  44252. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44253. /**
  44254. * Gets the current auto clear configuration for one rendering group of the rendering
  44255. * manager.
  44256. * @param index the rendering group index to get the information for
  44257. * @returns The auto clear setup for the requested rendering group
  44258. */
  44259. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44260. private _blockMaterialDirtyMechanism;
  44261. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44262. get blockMaterialDirtyMechanism(): boolean;
  44263. set blockMaterialDirtyMechanism(value: boolean);
  44264. /**
  44265. * Will flag all materials as dirty to trigger new shader compilation
  44266. * @param flag defines the flag used to specify which material part must be marked as dirty
  44267. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44268. */
  44269. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44270. /** @hidden */
  44271. _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;
  44272. /** @hidden */
  44273. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44274. /** @hidden */
  44275. _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;
  44276. /** @hidden */
  44277. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44278. /** @hidden */
  44279. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44280. /** @hidden */
  44281. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44282. }
  44283. }
  44284. declare module BABYLON {
  44285. /**
  44286. * Set of assets to keep when moving a scene into an asset container.
  44287. */
  44288. export class KeepAssets extends AbstractScene {
  44289. }
  44290. /**
  44291. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44292. */
  44293. export class InstantiatedEntries {
  44294. /**
  44295. * List of new root nodes (eg. nodes with no parent)
  44296. */
  44297. rootNodes: TransformNode[];
  44298. /**
  44299. * List of new skeletons
  44300. */
  44301. skeletons: Skeleton[];
  44302. /**
  44303. * List of new animation groups
  44304. */
  44305. animationGroups: AnimationGroup[];
  44306. }
  44307. /**
  44308. * Container with a set of assets that can be added or removed from a scene.
  44309. */
  44310. export class AssetContainer extends AbstractScene {
  44311. private _wasAddedToScene;
  44312. /**
  44313. * The scene the AssetContainer belongs to.
  44314. */
  44315. scene: Scene;
  44316. /**
  44317. * Instantiates an AssetContainer.
  44318. * @param scene The scene the AssetContainer belongs to.
  44319. */
  44320. constructor(scene: Scene);
  44321. /**
  44322. * Instantiate or clone all meshes and add the new ones to the scene.
  44323. * Skeletons and animation groups will all be cloned
  44324. * @param nameFunction defines an optional function used to get new names for clones
  44325. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44326. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44327. */
  44328. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44329. /**
  44330. * Adds all the assets from the container to the scene.
  44331. */
  44332. addAllToScene(): void;
  44333. /**
  44334. * Removes all the assets in the container from the scene
  44335. */
  44336. removeAllFromScene(): void;
  44337. /**
  44338. * Disposes all the assets in the container
  44339. */
  44340. dispose(): void;
  44341. private _moveAssets;
  44342. /**
  44343. * Removes all the assets contained in the scene and adds them to the container.
  44344. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44345. */
  44346. moveAllFromScene(keepAssets?: KeepAssets): void;
  44347. /**
  44348. * 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.
  44349. * @returns the root mesh
  44350. */
  44351. createRootMesh(): Mesh;
  44352. /**
  44353. * Merge animations (direct and animation groups) from this asset container into a scene
  44354. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44355. * @param animatables set of animatables to retarget to a node from the scene
  44356. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44357. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44358. */
  44359. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44360. }
  44361. }
  44362. declare module BABYLON {
  44363. /**
  44364. * Defines how the parser contract is defined.
  44365. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44366. */
  44367. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44368. /**
  44369. * Defines how the individual parser contract is defined.
  44370. * These parser can parse an individual asset
  44371. */
  44372. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44373. /**
  44374. * Base class of the scene acting as a container for the different elements composing a scene.
  44375. * This class is dynamically extended by the different components of the scene increasing
  44376. * flexibility and reducing coupling
  44377. */
  44378. export abstract class AbstractScene {
  44379. /**
  44380. * Stores the list of available parsers in the application.
  44381. */
  44382. private static _BabylonFileParsers;
  44383. /**
  44384. * Stores the list of available individual parsers in the application.
  44385. */
  44386. private static _IndividualBabylonFileParsers;
  44387. /**
  44388. * Adds a parser in the list of available ones
  44389. * @param name Defines the name of the parser
  44390. * @param parser Defines the parser to add
  44391. */
  44392. static AddParser(name: string, parser: BabylonFileParser): void;
  44393. /**
  44394. * Gets a general parser from the list of avaialble ones
  44395. * @param name Defines the name of the parser
  44396. * @returns the requested parser or null
  44397. */
  44398. static GetParser(name: string): Nullable<BabylonFileParser>;
  44399. /**
  44400. * Adds n individual parser in the list of available ones
  44401. * @param name Defines the name of the parser
  44402. * @param parser Defines the parser to add
  44403. */
  44404. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44405. /**
  44406. * Gets an individual parser from the list of avaialble ones
  44407. * @param name Defines the name of the parser
  44408. * @returns the requested parser or null
  44409. */
  44410. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44411. /**
  44412. * Parser json data and populate both a scene and its associated container object
  44413. * @param jsonData Defines the data to parse
  44414. * @param scene Defines the scene to parse the data for
  44415. * @param container Defines the container attached to the parsing sequence
  44416. * @param rootUrl Defines the root url of the data
  44417. */
  44418. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44419. /**
  44420. * Gets the list of root nodes (ie. nodes with no parent)
  44421. */
  44422. rootNodes: Node[];
  44423. /** All of the cameras added to this scene
  44424. * @see https://doc.babylonjs.com/babylon101/cameras
  44425. */
  44426. cameras: Camera[];
  44427. /**
  44428. * All of the lights added to this scene
  44429. * @see https://doc.babylonjs.com/babylon101/lights
  44430. */
  44431. lights: Light[];
  44432. /**
  44433. * All of the (abstract) meshes added to this scene
  44434. */
  44435. meshes: AbstractMesh[];
  44436. /**
  44437. * The list of skeletons added to the scene
  44438. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44439. */
  44440. skeletons: Skeleton[];
  44441. /**
  44442. * All of the particle systems added to this scene
  44443. * @see https://doc.babylonjs.com/babylon101/particles
  44444. */
  44445. particleSystems: IParticleSystem[];
  44446. /**
  44447. * Gets a list of Animations associated with the scene
  44448. */
  44449. animations: Animation[];
  44450. /**
  44451. * All of the animation groups added to this scene
  44452. * @see https://doc.babylonjs.com/how_to/group
  44453. */
  44454. animationGroups: AnimationGroup[];
  44455. /**
  44456. * All of the multi-materials added to this scene
  44457. * @see https://doc.babylonjs.com/how_to/multi_materials
  44458. */
  44459. multiMaterials: MultiMaterial[];
  44460. /**
  44461. * All of the materials added to this scene
  44462. * In the context of a Scene, it is not supposed to be modified manually.
  44463. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44464. * Note also that the order of the Material within the array is not significant and might change.
  44465. * @see https://doc.babylonjs.com/babylon101/materials
  44466. */
  44467. materials: Material[];
  44468. /**
  44469. * The list of morph target managers added to the scene
  44470. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44471. */
  44472. morphTargetManagers: MorphTargetManager[];
  44473. /**
  44474. * The list of geometries used in the scene.
  44475. */
  44476. geometries: Geometry[];
  44477. /**
  44478. * All of the tranform nodes added to this scene
  44479. * In the context of a Scene, it is not supposed to be modified manually.
  44480. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44481. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44482. * @see https://doc.babylonjs.com/how_to/transformnode
  44483. */
  44484. transformNodes: TransformNode[];
  44485. /**
  44486. * ActionManagers available on the scene.
  44487. */
  44488. actionManagers: AbstractActionManager[];
  44489. /**
  44490. * Textures to keep.
  44491. */
  44492. textures: BaseTexture[];
  44493. /** @hidden */
  44494. protected _environmentTexture: Nullable<BaseTexture>;
  44495. /**
  44496. * Texture used in all pbr material as the reflection texture.
  44497. * As in the majority of the scene they are the same (exception for multi room and so on),
  44498. * this is easier to reference from here than from all the materials.
  44499. */
  44500. get environmentTexture(): Nullable<BaseTexture>;
  44501. set environmentTexture(value: Nullable<BaseTexture>);
  44502. /**
  44503. * The list of postprocesses added to the scene
  44504. */
  44505. postProcesses: PostProcess[];
  44506. /**
  44507. * @returns all meshes, lights, cameras, transformNodes and bones
  44508. */
  44509. getNodes(): Array<Node>;
  44510. }
  44511. }
  44512. declare module BABYLON {
  44513. /**
  44514. * Interface used to define options for Sound class
  44515. */
  44516. export interface ISoundOptions {
  44517. /**
  44518. * Does the sound autoplay once loaded.
  44519. */
  44520. autoplay?: boolean;
  44521. /**
  44522. * Does the sound loop after it finishes playing once.
  44523. */
  44524. loop?: boolean;
  44525. /**
  44526. * Sound's volume
  44527. */
  44528. volume?: number;
  44529. /**
  44530. * Is it a spatial sound?
  44531. */
  44532. spatialSound?: boolean;
  44533. /**
  44534. * Maximum distance to hear that sound
  44535. */
  44536. maxDistance?: number;
  44537. /**
  44538. * Uses user defined attenuation function
  44539. */
  44540. useCustomAttenuation?: boolean;
  44541. /**
  44542. * Define the roll off factor of spatial sounds.
  44543. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44544. */
  44545. rolloffFactor?: number;
  44546. /**
  44547. * Define the reference distance the sound should be heard perfectly.
  44548. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44549. */
  44550. refDistance?: number;
  44551. /**
  44552. * Define the distance attenuation model the sound will follow.
  44553. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44554. */
  44555. distanceModel?: string;
  44556. /**
  44557. * Defines the playback speed (1 by default)
  44558. */
  44559. playbackRate?: number;
  44560. /**
  44561. * Defines if the sound is from a streaming source
  44562. */
  44563. streaming?: boolean;
  44564. /**
  44565. * Defines an optional length (in seconds) inside the sound file
  44566. */
  44567. length?: number;
  44568. /**
  44569. * Defines an optional offset (in seconds) inside the sound file
  44570. */
  44571. offset?: number;
  44572. /**
  44573. * If true, URLs will not be required to state the audio file codec to use.
  44574. */
  44575. skipCodecCheck?: boolean;
  44576. }
  44577. /**
  44578. * Defines a sound that can be played in the application.
  44579. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44580. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44581. */
  44582. export class Sound {
  44583. /**
  44584. * The name of the sound in the scene.
  44585. */
  44586. name: string;
  44587. /**
  44588. * Does the sound autoplay once loaded.
  44589. */
  44590. autoplay: boolean;
  44591. /**
  44592. * Does the sound loop after it finishes playing once.
  44593. */
  44594. loop: boolean;
  44595. /**
  44596. * Does the sound use a custom attenuation curve to simulate the falloff
  44597. * happening when the source gets further away from the camera.
  44598. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44599. */
  44600. useCustomAttenuation: boolean;
  44601. /**
  44602. * The sound track id this sound belongs to.
  44603. */
  44604. soundTrackId: number;
  44605. /**
  44606. * Is this sound currently played.
  44607. */
  44608. isPlaying: boolean;
  44609. /**
  44610. * Is this sound currently paused.
  44611. */
  44612. isPaused: boolean;
  44613. /**
  44614. * Does this sound enables spatial sound.
  44615. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44616. */
  44617. spatialSound: boolean;
  44618. /**
  44619. * Define the reference distance the sound should be heard perfectly.
  44620. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44621. */
  44622. refDistance: number;
  44623. /**
  44624. * Define the roll off factor of spatial sounds.
  44625. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44626. */
  44627. rolloffFactor: number;
  44628. /**
  44629. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44630. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44631. */
  44632. maxDistance: number;
  44633. /**
  44634. * Define the distance attenuation model the sound will follow.
  44635. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44636. */
  44637. distanceModel: string;
  44638. /**
  44639. * @hidden
  44640. * Back Compat
  44641. **/
  44642. onended: () => any;
  44643. /**
  44644. * Gets or sets an object used to store user defined information for the sound.
  44645. */
  44646. metadata: any;
  44647. /**
  44648. * Observable event when the current playing sound finishes.
  44649. */
  44650. onEndedObservable: Observable<Sound>;
  44651. private _panningModel;
  44652. private _playbackRate;
  44653. private _streaming;
  44654. private _startTime;
  44655. private _startOffset;
  44656. private _position;
  44657. /** @hidden */
  44658. _positionInEmitterSpace: boolean;
  44659. private _localDirection;
  44660. private _volume;
  44661. private _isReadyToPlay;
  44662. private _isDirectional;
  44663. private _readyToPlayCallback;
  44664. private _audioBuffer;
  44665. private _soundSource;
  44666. private _streamingSource;
  44667. private _soundPanner;
  44668. private _soundGain;
  44669. private _inputAudioNode;
  44670. private _outputAudioNode;
  44671. private _coneInnerAngle;
  44672. private _coneOuterAngle;
  44673. private _coneOuterGain;
  44674. private _scene;
  44675. private _connectedTransformNode;
  44676. private _customAttenuationFunction;
  44677. private _registerFunc;
  44678. private _isOutputConnected;
  44679. private _htmlAudioElement;
  44680. private _urlType;
  44681. private _length?;
  44682. private _offset?;
  44683. /** @hidden */
  44684. static _SceneComponentInitialization: (scene: Scene) => void;
  44685. /**
  44686. * Create a sound and attach it to a scene
  44687. * @param name Name of your sound
  44688. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44689. * @param scene defines the scene the sound belongs to
  44690. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44691. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44692. */
  44693. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44694. /**
  44695. * Release the sound and its associated resources
  44696. */
  44697. dispose(): void;
  44698. /**
  44699. * Gets if the sounds is ready to be played or not.
  44700. * @returns true if ready, otherwise false
  44701. */
  44702. isReady(): boolean;
  44703. private _soundLoaded;
  44704. /**
  44705. * Sets the data of the sound from an audiobuffer
  44706. * @param audioBuffer The audioBuffer containing the data
  44707. */
  44708. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44709. /**
  44710. * Updates the current sounds options such as maxdistance, loop...
  44711. * @param options A JSON object containing values named as the object properties
  44712. */
  44713. updateOptions(options: ISoundOptions): void;
  44714. private _createSpatialParameters;
  44715. private _updateSpatialParameters;
  44716. /**
  44717. * Switch the panning model to HRTF:
  44718. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44719. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44720. */
  44721. switchPanningModelToHRTF(): void;
  44722. /**
  44723. * Switch the panning model to Equal Power:
  44724. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44725. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44726. */
  44727. switchPanningModelToEqualPower(): void;
  44728. private _switchPanningModel;
  44729. /**
  44730. * Connect this sound to a sound track audio node like gain...
  44731. * @param soundTrackAudioNode the sound track audio node to connect to
  44732. */
  44733. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44734. /**
  44735. * Transform this sound into a directional source
  44736. * @param coneInnerAngle Size of the inner cone in degree
  44737. * @param coneOuterAngle Size of the outer cone in degree
  44738. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44739. */
  44740. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44741. /**
  44742. * Gets or sets the inner angle for the directional cone.
  44743. */
  44744. get directionalConeInnerAngle(): number;
  44745. /**
  44746. * Gets or sets the inner angle for the directional cone.
  44747. */
  44748. set directionalConeInnerAngle(value: number);
  44749. /**
  44750. * Gets or sets the outer angle for the directional cone.
  44751. */
  44752. get directionalConeOuterAngle(): number;
  44753. /**
  44754. * Gets or sets the outer angle for the directional cone.
  44755. */
  44756. set directionalConeOuterAngle(value: number);
  44757. /**
  44758. * Sets the position of the emitter if spatial sound is enabled
  44759. * @param newPosition Defines the new posisiton
  44760. */
  44761. setPosition(newPosition: Vector3): void;
  44762. /**
  44763. * Sets the local direction of the emitter if spatial sound is enabled
  44764. * @param newLocalDirection Defines the new local direction
  44765. */
  44766. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44767. private _updateDirection;
  44768. /** @hidden */
  44769. updateDistanceFromListener(): void;
  44770. /**
  44771. * Sets a new custom attenuation function for the sound.
  44772. * @param callback Defines the function used for the attenuation
  44773. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44774. */
  44775. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44776. /**
  44777. * Play the sound
  44778. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  44779. * @param offset (optional) Start the sound at a specific time in seconds
  44780. * @param length (optional) Sound duration (in seconds)
  44781. */
  44782. play(time?: number, offset?: number, length?: number): void;
  44783. private _onended;
  44784. /**
  44785. * Stop the sound
  44786. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  44787. */
  44788. stop(time?: number): void;
  44789. /**
  44790. * Put the sound in pause
  44791. */
  44792. pause(): void;
  44793. /**
  44794. * Sets a dedicated volume for this sounds
  44795. * @param newVolume Define the new volume of the sound
  44796. * @param time Define time for gradual change to new volume
  44797. */
  44798. setVolume(newVolume: number, time?: number): void;
  44799. /**
  44800. * Set the sound play back rate
  44801. * @param newPlaybackRate Define the playback rate the sound should be played at
  44802. */
  44803. setPlaybackRate(newPlaybackRate: number): void;
  44804. /**
  44805. * Gets the volume of the sound.
  44806. * @returns the volume of the sound
  44807. */
  44808. getVolume(): number;
  44809. /**
  44810. * Attach the sound to a dedicated mesh
  44811. * @param transformNode The transform node to connect the sound with
  44812. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44813. */
  44814. attachToMesh(transformNode: TransformNode): void;
  44815. /**
  44816. * Detach the sound from the previously attached mesh
  44817. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44818. */
  44819. detachFromMesh(): void;
  44820. private _onRegisterAfterWorldMatrixUpdate;
  44821. /**
  44822. * Clone the current sound in the scene.
  44823. * @returns the new sound clone
  44824. */
  44825. clone(): Nullable<Sound>;
  44826. /**
  44827. * Gets the current underlying audio buffer containing the data
  44828. * @returns the audio buffer
  44829. */
  44830. getAudioBuffer(): Nullable<AudioBuffer>;
  44831. /**
  44832. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  44833. * @returns the source node
  44834. */
  44835. getSoundSource(): Nullable<AudioBufferSourceNode>;
  44836. /**
  44837. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  44838. * @returns the gain node
  44839. */
  44840. getSoundGain(): Nullable<GainNode>;
  44841. /**
  44842. * Serializes the Sound in a JSON representation
  44843. * @returns the JSON representation of the sound
  44844. */
  44845. serialize(): any;
  44846. /**
  44847. * Parse a JSON representation of a sound to innstantiate in a given scene
  44848. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  44849. * @param scene Define the scene the new parsed sound should be created in
  44850. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  44851. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  44852. * @returns the newly parsed sound
  44853. */
  44854. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  44855. }
  44856. }
  44857. declare module BABYLON {
  44858. /**
  44859. * This defines an action helpful to play a defined sound on a triggered action.
  44860. */
  44861. export class PlaySoundAction extends Action {
  44862. private _sound;
  44863. /**
  44864. * Instantiate the action
  44865. * @param triggerOptions defines the trigger options
  44866. * @param sound defines the sound to play
  44867. * @param condition defines the trigger related conditions
  44868. */
  44869. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44870. /** @hidden */
  44871. _prepare(): void;
  44872. /**
  44873. * Execute the action and play the sound.
  44874. */
  44875. execute(): void;
  44876. /**
  44877. * Serializes the actions and its related information.
  44878. * @param parent defines the object to serialize in
  44879. * @returns the serialized object
  44880. */
  44881. serialize(parent: any): any;
  44882. }
  44883. /**
  44884. * This defines an action helpful to stop a defined sound on a triggered action.
  44885. */
  44886. export class StopSoundAction extends Action {
  44887. private _sound;
  44888. /**
  44889. * Instantiate the action
  44890. * @param triggerOptions defines the trigger options
  44891. * @param sound defines the sound to stop
  44892. * @param condition defines the trigger related conditions
  44893. */
  44894. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44895. /** @hidden */
  44896. _prepare(): void;
  44897. /**
  44898. * Execute the action and stop the sound.
  44899. */
  44900. execute(): void;
  44901. /**
  44902. * Serializes the actions and its related information.
  44903. * @param parent defines the object to serialize in
  44904. * @returns the serialized object
  44905. */
  44906. serialize(parent: any): any;
  44907. }
  44908. }
  44909. declare module BABYLON {
  44910. /**
  44911. * This defines an action responsible to change the value of a property
  44912. * by interpolating between its current value and the newly set one once triggered.
  44913. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44914. */
  44915. export class InterpolateValueAction extends Action {
  44916. /**
  44917. * Defines the path of the property where the value should be interpolated
  44918. */
  44919. propertyPath: string;
  44920. /**
  44921. * Defines the target value at the end of the interpolation.
  44922. */
  44923. value: any;
  44924. /**
  44925. * Defines the time it will take for the property to interpolate to the value.
  44926. */
  44927. duration: number;
  44928. /**
  44929. * Defines if the other scene animations should be stopped when the action has been triggered
  44930. */
  44931. stopOtherAnimations?: boolean;
  44932. /**
  44933. * Defines a callback raised once the interpolation animation has been done.
  44934. */
  44935. onInterpolationDone?: () => void;
  44936. /**
  44937. * Observable triggered once the interpolation animation has been done.
  44938. */
  44939. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  44940. private _target;
  44941. private _effectiveTarget;
  44942. private _property;
  44943. /**
  44944. * Instantiate the action
  44945. * @param triggerOptions defines the trigger options
  44946. * @param target defines the object containing the value to interpolate
  44947. * @param propertyPath defines the path to the property in the target object
  44948. * @param value defines the target value at the end of the interpolation
  44949. * @param duration deines the time it will take for the property to interpolate to the value.
  44950. * @param condition defines the trigger related conditions
  44951. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  44952. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  44953. */
  44954. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  44955. /** @hidden */
  44956. _prepare(): void;
  44957. /**
  44958. * Execute the action starts the value interpolation.
  44959. */
  44960. execute(): void;
  44961. /**
  44962. * Serializes the actions and its related information.
  44963. * @param parent defines the object to serialize in
  44964. * @returns the serialized object
  44965. */
  44966. serialize(parent: any): any;
  44967. }
  44968. }
  44969. declare module BABYLON {
  44970. /**
  44971. * Options allowed during the creation of a sound track.
  44972. */
  44973. export interface ISoundTrackOptions {
  44974. /**
  44975. * The volume the sound track should take during creation
  44976. */
  44977. volume?: number;
  44978. /**
  44979. * Define if the sound track is the main sound track of the scene
  44980. */
  44981. mainTrack?: boolean;
  44982. }
  44983. /**
  44984. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  44985. * It will be also used in a future release to apply effects on a specific track.
  44986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44987. */
  44988. export class SoundTrack {
  44989. /**
  44990. * The unique identifier of the sound track in the scene.
  44991. */
  44992. id: number;
  44993. /**
  44994. * The list of sounds included in the sound track.
  44995. */
  44996. soundCollection: Array<Sound>;
  44997. private _outputAudioNode;
  44998. private _scene;
  44999. private _connectedAnalyser;
  45000. private _options;
  45001. private _isInitialized;
  45002. /**
  45003. * Creates a new sound track.
  45004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45005. * @param scene Define the scene the sound track belongs to
  45006. * @param options
  45007. */
  45008. constructor(scene: Scene, options?: ISoundTrackOptions);
  45009. private _initializeSoundTrackAudioGraph;
  45010. /**
  45011. * Release the sound track and its associated resources
  45012. */
  45013. dispose(): void;
  45014. /**
  45015. * Adds a sound to this sound track
  45016. * @param sound define the cound to add
  45017. * @ignoreNaming
  45018. */
  45019. AddSound(sound: Sound): void;
  45020. /**
  45021. * Removes a sound to this sound track
  45022. * @param sound define the cound to remove
  45023. * @ignoreNaming
  45024. */
  45025. RemoveSound(sound: Sound): void;
  45026. /**
  45027. * Set a global volume for the full sound track.
  45028. * @param newVolume Define the new volume of the sound track
  45029. */
  45030. setVolume(newVolume: number): void;
  45031. /**
  45032. * Switch the panning model to HRTF:
  45033. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45034. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45035. */
  45036. switchPanningModelToHRTF(): void;
  45037. /**
  45038. * Switch the panning model to Equal Power:
  45039. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45040. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45041. */
  45042. switchPanningModelToEqualPower(): void;
  45043. /**
  45044. * Connect the sound track to an audio analyser allowing some amazing
  45045. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45046. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45047. * @param analyser The analyser to connect to the engine
  45048. */
  45049. connectToAnalyser(analyser: Analyser): void;
  45050. }
  45051. }
  45052. declare module BABYLON {
  45053. interface AbstractScene {
  45054. /**
  45055. * The list of sounds used in the scene.
  45056. */
  45057. sounds: Nullable<Array<Sound>>;
  45058. }
  45059. interface Scene {
  45060. /**
  45061. * @hidden
  45062. * Backing field
  45063. */
  45064. _mainSoundTrack: SoundTrack;
  45065. /**
  45066. * The main sound track played by the scene.
  45067. * It cotains your primary collection of sounds.
  45068. */
  45069. mainSoundTrack: SoundTrack;
  45070. /**
  45071. * The list of sound tracks added to the scene
  45072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45073. */
  45074. soundTracks: Nullable<Array<SoundTrack>>;
  45075. /**
  45076. * Gets a sound using a given name
  45077. * @param name defines the name to search for
  45078. * @return the found sound or null if not found at all.
  45079. */
  45080. getSoundByName(name: string): Nullable<Sound>;
  45081. /**
  45082. * Gets or sets if audio support is enabled
  45083. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45084. */
  45085. audioEnabled: boolean;
  45086. /**
  45087. * Gets or sets if audio will be output to headphones
  45088. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45089. */
  45090. headphone: boolean;
  45091. /**
  45092. * Gets or sets custom audio listener position provider
  45093. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45094. */
  45095. audioListenerPositionProvider: Nullable<() => Vector3>;
  45096. /**
  45097. * Gets or sets a refresh rate when using 3D audio positioning
  45098. */
  45099. audioPositioningRefreshRate: number;
  45100. }
  45101. /**
  45102. * Defines the sound scene component responsible to manage any sounds
  45103. * in a given scene.
  45104. */
  45105. export class AudioSceneComponent implements ISceneSerializableComponent {
  45106. private static _CameraDirectionLH;
  45107. private static _CameraDirectionRH;
  45108. /**
  45109. * The component name helpfull to identify the component in the list of scene components.
  45110. */
  45111. readonly name: string;
  45112. /**
  45113. * The scene the component belongs to.
  45114. */
  45115. scene: Scene;
  45116. private _audioEnabled;
  45117. /**
  45118. * Gets whether audio is enabled or not.
  45119. * Please use related enable/disable method to switch state.
  45120. */
  45121. get audioEnabled(): boolean;
  45122. private _headphone;
  45123. /**
  45124. * Gets whether audio is outputing to headphone or not.
  45125. * Please use the according Switch methods to change output.
  45126. */
  45127. get headphone(): boolean;
  45128. /**
  45129. * Gets or sets a refresh rate when using 3D audio positioning
  45130. */
  45131. audioPositioningRefreshRate: number;
  45132. private _audioListenerPositionProvider;
  45133. /**
  45134. * Gets the current audio listener position provider
  45135. */
  45136. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45137. /**
  45138. * Sets a custom listener position for all sounds in the scene
  45139. * By default, this is the position of the first active camera
  45140. */
  45141. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45142. /**
  45143. * Creates a new instance of the component for the given scene
  45144. * @param scene Defines the scene to register the component in
  45145. */
  45146. constructor(scene: Scene);
  45147. /**
  45148. * Registers the component in a given scene
  45149. */
  45150. register(): void;
  45151. /**
  45152. * Rebuilds the elements related to this component in case of
  45153. * context lost for instance.
  45154. */
  45155. rebuild(): void;
  45156. /**
  45157. * Serializes the component data to the specified json object
  45158. * @param serializationObject The object to serialize to
  45159. */
  45160. serialize(serializationObject: any): void;
  45161. /**
  45162. * Adds all the elements from the container to the scene
  45163. * @param container the container holding the elements
  45164. */
  45165. addFromContainer(container: AbstractScene): void;
  45166. /**
  45167. * Removes all the elements in the container from the scene
  45168. * @param container contains the elements to remove
  45169. * @param dispose if the removed element should be disposed (default: false)
  45170. */
  45171. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45172. /**
  45173. * Disposes the component and the associated ressources.
  45174. */
  45175. dispose(): void;
  45176. /**
  45177. * Disables audio in the associated scene.
  45178. */
  45179. disableAudio(): void;
  45180. /**
  45181. * Enables audio in the associated scene.
  45182. */
  45183. enableAudio(): void;
  45184. /**
  45185. * Switch audio to headphone output.
  45186. */
  45187. switchAudioModeForHeadphones(): void;
  45188. /**
  45189. * Switch audio to normal speakers.
  45190. */
  45191. switchAudioModeForNormalSpeakers(): void;
  45192. private _cachedCameraDirection;
  45193. private _cachedCameraPosition;
  45194. private _lastCheck;
  45195. private _afterRender;
  45196. }
  45197. }
  45198. declare module BABYLON {
  45199. /**
  45200. * Wraps one or more Sound objects and selects one with random weight for playback.
  45201. */
  45202. export class WeightedSound {
  45203. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45204. loop: boolean;
  45205. private _coneInnerAngle;
  45206. private _coneOuterAngle;
  45207. private _volume;
  45208. /** A Sound is currently playing. */
  45209. isPlaying: boolean;
  45210. /** A Sound is currently paused. */
  45211. isPaused: boolean;
  45212. private _sounds;
  45213. private _weights;
  45214. private _currentIndex?;
  45215. /**
  45216. * Creates a new WeightedSound from the list of sounds given.
  45217. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45218. * @param sounds Array of Sounds that will be selected from.
  45219. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45220. */
  45221. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45222. /**
  45223. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45224. */
  45225. get directionalConeInnerAngle(): number;
  45226. /**
  45227. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45228. */
  45229. set directionalConeInnerAngle(value: number);
  45230. /**
  45231. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45232. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45233. */
  45234. get directionalConeOuterAngle(): number;
  45235. /**
  45236. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45237. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45238. */
  45239. set directionalConeOuterAngle(value: number);
  45240. /**
  45241. * Playback volume.
  45242. */
  45243. get volume(): number;
  45244. /**
  45245. * Playback volume.
  45246. */
  45247. set volume(value: number);
  45248. private _onended;
  45249. /**
  45250. * Suspend playback
  45251. */
  45252. pause(): void;
  45253. /**
  45254. * Stop playback
  45255. */
  45256. stop(): void;
  45257. /**
  45258. * Start playback.
  45259. * @param startOffset Position the clip head at a specific time in seconds.
  45260. */
  45261. play(startOffset?: number): void;
  45262. }
  45263. }
  45264. declare module BABYLON {
  45265. /**
  45266. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45267. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45268. */
  45269. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45270. /**
  45271. * Gets the name of the behavior.
  45272. */
  45273. get name(): string;
  45274. /**
  45275. * The easing function used by animations
  45276. */
  45277. static EasingFunction: BackEase;
  45278. /**
  45279. * The easing mode used by animations
  45280. */
  45281. static EasingMode: number;
  45282. /**
  45283. * The duration of the animation, in milliseconds
  45284. */
  45285. transitionDuration: number;
  45286. /**
  45287. * Length of the distance animated by the transition when lower radius is reached
  45288. */
  45289. lowerRadiusTransitionRange: number;
  45290. /**
  45291. * Length of the distance animated by the transition when upper radius is reached
  45292. */
  45293. upperRadiusTransitionRange: number;
  45294. private _autoTransitionRange;
  45295. /**
  45296. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45297. */
  45298. get autoTransitionRange(): boolean;
  45299. /**
  45300. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45301. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45302. */
  45303. set autoTransitionRange(value: boolean);
  45304. private _attachedCamera;
  45305. private _onAfterCheckInputsObserver;
  45306. private _onMeshTargetChangedObserver;
  45307. /**
  45308. * Initializes the behavior.
  45309. */
  45310. init(): void;
  45311. /**
  45312. * Attaches the behavior to its arc rotate camera.
  45313. * @param camera Defines the camera to attach the behavior to
  45314. */
  45315. attach(camera: ArcRotateCamera): void;
  45316. /**
  45317. * Detaches the behavior from its current arc rotate camera.
  45318. */
  45319. detach(): void;
  45320. private _radiusIsAnimating;
  45321. private _radiusBounceTransition;
  45322. private _animatables;
  45323. private _cachedWheelPrecision;
  45324. /**
  45325. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45326. * @param radiusLimit The limit to check against.
  45327. * @return Bool to indicate if at limit.
  45328. */
  45329. private _isRadiusAtLimit;
  45330. /**
  45331. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45332. * @param radiusDelta The delta by which to animate to. Can be negative.
  45333. */
  45334. private _applyBoundRadiusAnimation;
  45335. /**
  45336. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45337. */
  45338. protected _clearAnimationLocks(): void;
  45339. /**
  45340. * Stops and removes all animations that have been applied to the camera
  45341. */
  45342. stopAllAnimations(): void;
  45343. }
  45344. }
  45345. declare module BABYLON {
  45346. /**
  45347. * 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.
  45348. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45349. */
  45350. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45351. /**
  45352. * Gets the name of the behavior.
  45353. */
  45354. get name(): string;
  45355. private _mode;
  45356. private _radiusScale;
  45357. private _positionScale;
  45358. private _defaultElevation;
  45359. private _elevationReturnTime;
  45360. private _elevationReturnWaitTime;
  45361. private _zoomStopsAnimation;
  45362. private _framingTime;
  45363. /**
  45364. * The easing function used by animations
  45365. */
  45366. static EasingFunction: ExponentialEase;
  45367. /**
  45368. * The easing mode used by animations
  45369. */
  45370. static EasingMode: number;
  45371. /**
  45372. * Sets the current mode used by the behavior
  45373. */
  45374. set mode(mode: number);
  45375. /**
  45376. * Gets current mode used by the behavior.
  45377. */
  45378. get mode(): number;
  45379. /**
  45380. * Sets the scale applied to the radius (1 by default)
  45381. */
  45382. set radiusScale(radius: number);
  45383. /**
  45384. * Gets the scale applied to the radius
  45385. */
  45386. get radiusScale(): number;
  45387. /**
  45388. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45389. */
  45390. set positionScale(scale: number);
  45391. /**
  45392. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45393. */
  45394. get positionScale(): number;
  45395. /**
  45396. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45397. * behaviour is triggered, in radians.
  45398. */
  45399. set defaultElevation(elevation: number);
  45400. /**
  45401. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45402. * behaviour is triggered, in radians.
  45403. */
  45404. get defaultElevation(): number;
  45405. /**
  45406. * Sets the time (in milliseconds) taken to return to the default beta position.
  45407. * Negative value indicates camera should not return to default.
  45408. */
  45409. set elevationReturnTime(speed: number);
  45410. /**
  45411. * Gets the time (in milliseconds) taken to return to the default beta position.
  45412. * Negative value indicates camera should not return to default.
  45413. */
  45414. get elevationReturnTime(): number;
  45415. /**
  45416. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45417. */
  45418. set elevationReturnWaitTime(time: number);
  45419. /**
  45420. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45421. */
  45422. get elevationReturnWaitTime(): number;
  45423. /**
  45424. * Sets the flag that indicates if user zooming should stop animation.
  45425. */
  45426. set zoomStopsAnimation(flag: boolean);
  45427. /**
  45428. * Gets the flag that indicates if user zooming should stop animation.
  45429. */
  45430. get zoomStopsAnimation(): boolean;
  45431. /**
  45432. * Sets the transition time when framing the mesh, in milliseconds
  45433. */
  45434. set framingTime(time: number);
  45435. /**
  45436. * Gets the transition time when framing the mesh, in milliseconds
  45437. */
  45438. get framingTime(): number;
  45439. /**
  45440. * Define if the behavior should automatically change the configured
  45441. * camera limits and sensibilities.
  45442. */
  45443. autoCorrectCameraLimitsAndSensibility: boolean;
  45444. private _onPrePointerObservableObserver;
  45445. private _onAfterCheckInputsObserver;
  45446. private _onMeshTargetChangedObserver;
  45447. private _attachedCamera;
  45448. private _isPointerDown;
  45449. private _lastInteractionTime;
  45450. /**
  45451. * Initializes the behavior.
  45452. */
  45453. init(): void;
  45454. /**
  45455. * Attaches the behavior to its arc rotate camera.
  45456. * @param camera Defines the camera to attach the behavior to
  45457. */
  45458. attach(camera: ArcRotateCamera): void;
  45459. /**
  45460. * Detaches the behavior from its current arc rotate camera.
  45461. */
  45462. detach(): void;
  45463. private _animatables;
  45464. private _betaIsAnimating;
  45465. private _betaTransition;
  45466. private _radiusTransition;
  45467. private _vectorTransition;
  45468. /**
  45469. * Targets the given mesh and updates zoom level accordingly.
  45470. * @param mesh The mesh to target.
  45471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45473. */
  45474. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45475. /**
  45476. * Targets the given mesh with its children and updates zoom level accordingly.
  45477. * @param mesh The mesh to target.
  45478. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45479. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45480. */
  45481. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45482. /**
  45483. * Targets the given meshes with their children and updates zoom level accordingly.
  45484. * @param meshes The mesh to target.
  45485. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45486. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45487. */
  45488. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45489. /**
  45490. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45491. * @param minimumWorld Determines the smaller position of the bounding box extend
  45492. * @param maximumWorld Determines the bigger position of the bounding box extend
  45493. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45494. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45495. */
  45496. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45497. /**
  45498. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45499. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45500. * frustum width.
  45501. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45502. * to fully enclose the mesh in the viewing frustum.
  45503. */
  45504. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45505. /**
  45506. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45507. * is automatically returned to its default position (expected to be above ground plane).
  45508. */
  45509. private _maintainCameraAboveGround;
  45510. /**
  45511. * Returns the frustum slope based on the canvas ratio and camera FOV
  45512. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45513. */
  45514. private _getFrustumSlope;
  45515. /**
  45516. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45517. */
  45518. private _clearAnimationLocks;
  45519. /**
  45520. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45521. */
  45522. private _applyUserInteraction;
  45523. /**
  45524. * Stops and removes all animations that have been applied to the camera
  45525. */
  45526. stopAllAnimations(): void;
  45527. /**
  45528. * Gets a value indicating if the user is moving the camera
  45529. */
  45530. get isUserIsMoving(): boolean;
  45531. /**
  45532. * The camera can move all the way towards the mesh.
  45533. */
  45534. static IgnoreBoundsSizeMode: number;
  45535. /**
  45536. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45537. */
  45538. static FitFrustumSidesMode: number;
  45539. }
  45540. }
  45541. declare module BABYLON {
  45542. /**
  45543. * Base class for Camera Pointer Inputs.
  45544. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45545. * for example usage.
  45546. */
  45547. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45548. /**
  45549. * Defines the camera the input is attached to.
  45550. */
  45551. abstract camera: Camera;
  45552. /**
  45553. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45554. */
  45555. protected _altKey: boolean;
  45556. protected _ctrlKey: boolean;
  45557. protected _metaKey: boolean;
  45558. protected _shiftKey: boolean;
  45559. /**
  45560. * Which mouse buttons were pressed at time of last mouse event.
  45561. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45562. */
  45563. protected _buttonsPressed: number;
  45564. /**
  45565. * Defines the buttons associated with the input to handle camera move.
  45566. */
  45567. buttons: number[];
  45568. /**
  45569. * Attach the input controls to a specific dom element to get the input from.
  45570. * @param element Defines the element the controls should be listened from
  45571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45572. */
  45573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45574. /**
  45575. * Detach the current controls from the specified dom element.
  45576. * @param element Defines the element to stop listening the inputs from
  45577. */
  45578. detachControl(element: Nullable<HTMLElement>): void;
  45579. /**
  45580. * Gets the class name of the current input.
  45581. * @returns the class name
  45582. */
  45583. getClassName(): string;
  45584. /**
  45585. * Get the friendly name associated with the input class.
  45586. * @returns the input friendly name
  45587. */
  45588. getSimpleName(): string;
  45589. /**
  45590. * Called on pointer POINTERDOUBLETAP event.
  45591. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45592. */
  45593. protected onDoubleTap(type: string): void;
  45594. /**
  45595. * Called on pointer POINTERMOVE event if only a single touch is active.
  45596. * Override this method to provide functionality.
  45597. */
  45598. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45599. /**
  45600. * Called on pointer POINTERMOVE event if multiple touches are active.
  45601. * Override this method to provide functionality.
  45602. */
  45603. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45604. /**
  45605. * Called on JS contextmenu event.
  45606. * Override this method to provide functionality.
  45607. */
  45608. protected onContextMenu(evt: PointerEvent): void;
  45609. /**
  45610. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45611. * press.
  45612. * Override this method to provide functionality.
  45613. */
  45614. protected onButtonDown(evt: PointerEvent): void;
  45615. /**
  45616. * Called each time a new POINTERUP event occurs. Ie, for each button
  45617. * release.
  45618. * Override this method to provide functionality.
  45619. */
  45620. protected onButtonUp(evt: PointerEvent): void;
  45621. /**
  45622. * Called when window becomes inactive.
  45623. * Override this method to provide functionality.
  45624. */
  45625. protected onLostFocus(): void;
  45626. private _pointerInput;
  45627. private _observer;
  45628. private _onLostFocus;
  45629. private pointA;
  45630. private pointB;
  45631. }
  45632. }
  45633. declare module BABYLON {
  45634. /**
  45635. * Manage the pointers inputs to control an arc rotate camera.
  45636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45637. */
  45638. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45639. /**
  45640. * Defines the camera the input is attached to.
  45641. */
  45642. camera: ArcRotateCamera;
  45643. /**
  45644. * Gets the class name of the current input.
  45645. * @returns the class name
  45646. */
  45647. getClassName(): string;
  45648. /**
  45649. * Defines the buttons associated with the input to handle camera move.
  45650. */
  45651. buttons: number[];
  45652. /**
  45653. * Defines the pointer angular sensibility along the X axis or how fast is
  45654. * the camera rotating.
  45655. */
  45656. angularSensibilityX: number;
  45657. /**
  45658. * Defines the pointer angular sensibility along the Y axis or how fast is
  45659. * the camera rotating.
  45660. */
  45661. angularSensibilityY: number;
  45662. /**
  45663. * Defines the pointer pinch precision or how fast is the camera zooming.
  45664. */
  45665. pinchPrecision: number;
  45666. /**
  45667. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45668. * from 0.
  45669. * It defines the percentage of current camera.radius to use as delta when
  45670. * pinch zoom is used.
  45671. */
  45672. pinchDeltaPercentage: number;
  45673. /**
  45674. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45675. * that any object in the plane at the camera's target point will scale
  45676. * perfectly with finger motion.
  45677. * Overrides pinchDeltaPercentage and pinchPrecision.
  45678. */
  45679. useNaturalPinchZoom: boolean;
  45680. /**
  45681. * Defines the pointer panning sensibility or how fast is the camera moving.
  45682. */
  45683. panningSensibility: number;
  45684. /**
  45685. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45686. */
  45687. multiTouchPanning: boolean;
  45688. /**
  45689. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45690. * zoom (pinch) through multitouch.
  45691. */
  45692. multiTouchPanAndZoom: boolean;
  45693. /**
  45694. * Revers pinch action direction.
  45695. */
  45696. pinchInwards: boolean;
  45697. private _isPanClick;
  45698. private _twoFingerActivityCount;
  45699. private _isPinching;
  45700. /**
  45701. * Called on pointer POINTERMOVE event if only a single touch is active.
  45702. */
  45703. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45704. /**
  45705. * Called on pointer POINTERDOUBLETAP event.
  45706. */
  45707. protected onDoubleTap(type: string): void;
  45708. /**
  45709. * Called on pointer POINTERMOVE event if multiple touches are active.
  45710. */
  45711. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45712. /**
  45713. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45714. * press.
  45715. */
  45716. protected onButtonDown(evt: PointerEvent): void;
  45717. /**
  45718. * Called each time a new POINTERUP event occurs. Ie, for each button
  45719. * release.
  45720. */
  45721. protected onButtonUp(evt: PointerEvent): void;
  45722. /**
  45723. * Called when window becomes inactive.
  45724. */
  45725. protected onLostFocus(): void;
  45726. }
  45727. }
  45728. declare module BABYLON {
  45729. /**
  45730. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  45731. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45732. */
  45733. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  45734. /**
  45735. * Defines the camera the input is attached to.
  45736. */
  45737. camera: ArcRotateCamera;
  45738. /**
  45739. * Defines the list of key codes associated with the up action (increase alpha)
  45740. */
  45741. keysUp: number[];
  45742. /**
  45743. * Defines the list of key codes associated with the down action (decrease alpha)
  45744. */
  45745. keysDown: number[];
  45746. /**
  45747. * Defines the list of key codes associated with the left action (increase beta)
  45748. */
  45749. keysLeft: number[];
  45750. /**
  45751. * Defines the list of key codes associated with the right action (decrease beta)
  45752. */
  45753. keysRight: number[];
  45754. /**
  45755. * Defines the list of key codes associated with the reset action.
  45756. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  45757. */
  45758. keysReset: number[];
  45759. /**
  45760. * Defines the panning sensibility of the inputs.
  45761. * (How fast is the camera panning)
  45762. */
  45763. panningSensibility: number;
  45764. /**
  45765. * Defines the zooming sensibility of the inputs.
  45766. * (How fast is the camera zooming)
  45767. */
  45768. zoomingSensibility: number;
  45769. /**
  45770. * Defines whether maintaining the alt key down switch the movement mode from
  45771. * orientation to zoom.
  45772. */
  45773. useAltToZoom: boolean;
  45774. /**
  45775. * Rotation speed of the camera
  45776. */
  45777. angularSpeed: number;
  45778. private _keys;
  45779. private _ctrlPressed;
  45780. private _altPressed;
  45781. private _onCanvasBlurObserver;
  45782. private _onKeyboardObserver;
  45783. private _engine;
  45784. private _scene;
  45785. /**
  45786. * Attach the input controls to a specific dom element to get the input from.
  45787. * @param element Defines the element the controls should be listened from
  45788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45789. */
  45790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45791. /**
  45792. * Detach the current controls from the specified dom element.
  45793. * @param element Defines the element to stop listening the inputs from
  45794. */
  45795. detachControl(element: Nullable<HTMLElement>): void;
  45796. /**
  45797. * Update the current camera state depending on the inputs that have been used this frame.
  45798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45799. */
  45800. checkInputs(): void;
  45801. /**
  45802. * Gets the class name of the current intput.
  45803. * @returns the class name
  45804. */
  45805. getClassName(): string;
  45806. /**
  45807. * Get the friendly name associated with the input class.
  45808. * @returns the input friendly name
  45809. */
  45810. getSimpleName(): string;
  45811. }
  45812. }
  45813. declare module BABYLON {
  45814. /**
  45815. * Manage the mouse wheel inputs to control an arc rotate camera.
  45816. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45817. */
  45818. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  45819. /**
  45820. * Defines the camera the input is attached to.
  45821. */
  45822. camera: ArcRotateCamera;
  45823. /**
  45824. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45825. */
  45826. wheelPrecision: number;
  45827. /**
  45828. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45829. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45830. */
  45831. wheelDeltaPercentage: number;
  45832. private _wheel;
  45833. private _observer;
  45834. private computeDeltaFromMouseWheelLegacyEvent;
  45835. /**
  45836. * Attach the input controls to a specific dom element to get the input from.
  45837. * @param element Defines the element the controls should be listened from
  45838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45839. */
  45840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45841. /**
  45842. * Detach the current controls from the specified dom element.
  45843. * @param element Defines the element to stop listening the inputs from
  45844. */
  45845. detachControl(element: Nullable<HTMLElement>): void;
  45846. /**
  45847. * Gets the class name of the current intput.
  45848. * @returns the class name
  45849. */
  45850. getClassName(): string;
  45851. /**
  45852. * Get the friendly name associated with the input class.
  45853. * @returns the input friendly name
  45854. */
  45855. getSimpleName(): string;
  45856. }
  45857. }
  45858. declare module BABYLON {
  45859. /**
  45860. * Default Inputs manager for the ArcRotateCamera.
  45861. * It groups all the default supported inputs for ease of use.
  45862. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45863. */
  45864. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  45865. /**
  45866. * Instantiates a new ArcRotateCameraInputsManager.
  45867. * @param camera Defines the camera the inputs belong to
  45868. */
  45869. constructor(camera: ArcRotateCamera);
  45870. /**
  45871. * Add mouse wheel input support to the input manager.
  45872. * @returns the current input manager
  45873. */
  45874. addMouseWheel(): ArcRotateCameraInputsManager;
  45875. /**
  45876. * Add pointers input support to the input manager.
  45877. * @returns the current input manager
  45878. */
  45879. addPointers(): ArcRotateCameraInputsManager;
  45880. /**
  45881. * Add keyboard input support to the input manager.
  45882. * @returns the current input manager
  45883. */
  45884. addKeyboard(): ArcRotateCameraInputsManager;
  45885. }
  45886. }
  45887. declare module BABYLON {
  45888. /**
  45889. * This represents an orbital type of camera.
  45890. *
  45891. * 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.
  45892. * 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.
  45893. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  45894. */
  45895. export class ArcRotateCamera extends TargetCamera {
  45896. /**
  45897. * Defines the rotation angle of the camera along the longitudinal axis.
  45898. */
  45899. alpha: number;
  45900. /**
  45901. * Defines the rotation angle of the camera along the latitudinal axis.
  45902. */
  45903. beta: number;
  45904. /**
  45905. * Defines the radius of the camera from it s target point.
  45906. */
  45907. radius: number;
  45908. protected _target: Vector3;
  45909. protected _targetHost: Nullable<AbstractMesh>;
  45910. /**
  45911. * Defines the target point of the camera.
  45912. * The camera looks towards it form the radius distance.
  45913. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  45914. */
  45915. get target(): Vector3;
  45916. set target(value: Vector3);
  45917. /**
  45918. * Define the current local position of the camera in the scene
  45919. */
  45920. get position(): Vector3;
  45921. set position(newPosition: Vector3);
  45922. protected _upToYMatrix: Matrix;
  45923. protected _YToUpMatrix: Matrix;
  45924. /**
  45925. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  45926. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  45927. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  45928. */
  45929. set upVector(vec: Vector3);
  45930. get upVector(): Vector3;
  45931. /**
  45932. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  45933. */
  45934. setMatUp(): void;
  45935. /**
  45936. * Current inertia value on the longitudinal axis.
  45937. * The bigger this number the longer it will take for the camera to stop.
  45938. */
  45939. inertialAlphaOffset: number;
  45940. /**
  45941. * Current inertia value on the latitudinal axis.
  45942. * The bigger this number the longer it will take for the camera to stop.
  45943. */
  45944. inertialBetaOffset: number;
  45945. /**
  45946. * Current inertia value on the radius axis.
  45947. * The bigger this number the longer it will take for the camera to stop.
  45948. */
  45949. inertialRadiusOffset: number;
  45950. /**
  45951. * Minimum allowed angle on the longitudinal axis.
  45952. * This can help limiting how the Camera is able to move in the scene.
  45953. */
  45954. lowerAlphaLimit: Nullable<number>;
  45955. /**
  45956. * Maximum allowed angle on the longitudinal axis.
  45957. * This can help limiting how the Camera is able to move in the scene.
  45958. */
  45959. upperAlphaLimit: Nullable<number>;
  45960. /**
  45961. * Minimum allowed angle on the latitudinal axis.
  45962. * This can help limiting how the Camera is able to move in the scene.
  45963. */
  45964. lowerBetaLimit: number;
  45965. /**
  45966. * Maximum allowed angle on the latitudinal axis.
  45967. * This can help limiting how the Camera is able to move in the scene.
  45968. */
  45969. upperBetaLimit: number;
  45970. /**
  45971. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  45972. * This can help limiting how the Camera is able to move in the scene.
  45973. */
  45974. lowerRadiusLimit: Nullable<number>;
  45975. /**
  45976. * Maximum allowed distance of the camera to the target (The camera can not get further).
  45977. * This can help limiting how the Camera is able to move in the scene.
  45978. */
  45979. upperRadiusLimit: Nullable<number>;
  45980. /**
  45981. * Defines the current inertia value used during panning of the camera along the X axis.
  45982. */
  45983. inertialPanningX: number;
  45984. /**
  45985. * Defines the current inertia value used during panning of the camera along the Y axis.
  45986. */
  45987. inertialPanningY: number;
  45988. /**
  45989. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  45990. * Basically if your fingers moves away from more than this distance you will be considered
  45991. * in pinch mode.
  45992. */
  45993. pinchToPanMaxDistance: number;
  45994. /**
  45995. * Defines the maximum distance the camera can pan.
  45996. * This could help keeping the cammera always in your scene.
  45997. */
  45998. panningDistanceLimit: Nullable<number>;
  45999. /**
  46000. * Defines the target of the camera before paning.
  46001. */
  46002. panningOriginTarget: Vector3;
  46003. /**
  46004. * Defines the value of the inertia used during panning.
  46005. * 0 would mean stop inertia and one would mean no decelleration at all.
  46006. */
  46007. panningInertia: number;
  46008. /**
  46009. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46010. */
  46011. get angularSensibilityX(): number;
  46012. set angularSensibilityX(value: number);
  46013. /**
  46014. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46015. */
  46016. get angularSensibilityY(): number;
  46017. set angularSensibilityY(value: number);
  46018. /**
  46019. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46020. */
  46021. get pinchPrecision(): number;
  46022. set pinchPrecision(value: number);
  46023. /**
  46024. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46025. * It will be used instead of pinchDeltaPrecision if different from 0.
  46026. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46027. */
  46028. get pinchDeltaPercentage(): number;
  46029. set pinchDeltaPercentage(value: number);
  46030. /**
  46031. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46032. * and pinch delta percentage.
  46033. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46034. * that any object in the plane at the camera's target point will scale
  46035. * perfectly with finger motion.
  46036. */
  46037. get useNaturalPinchZoom(): boolean;
  46038. set useNaturalPinchZoom(value: boolean);
  46039. /**
  46040. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46041. */
  46042. get panningSensibility(): number;
  46043. set panningSensibility(value: number);
  46044. /**
  46045. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46046. */
  46047. get keysUp(): number[];
  46048. set keysUp(value: number[]);
  46049. /**
  46050. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46051. */
  46052. get keysDown(): number[];
  46053. set keysDown(value: number[]);
  46054. /**
  46055. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46056. */
  46057. get keysLeft(): number[];
  46058. set keysLeft(value: number[]);
  46059. /**
  46060. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46061. */
  46062. get keysRight(): number[];
  46063. set keysRight(value: number[]);
  46064. /**
  46065. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46066. */
  46067. get wheelPrecision(): number;
  46068. set wheelPrecision(value: number);
  46069. /**
  46070. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46071. * It will be used instead of pinchDeltaPrecision if different from 0.
  46072. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46073. */
  46074. get wheelDeltaPercentage(): number;
  46075. set wheelDeltaPercentage(value: number);
  46076. /**
  46077. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46078. */
  46079. zoomOnFactor: number;
  46080. /**
  46081. * Defines a screen offset for the camera position.
  46082. */
  46083. targetScreenOffset: Vector2;
  46084. /**
  46085. * Allows the camera to be completely reversed.
  46086. * If false the camera can not arrive upside down.
  46087. */
  46088. allowUpsideDown: boolean;
  46089. /**
  46090. * Define if double tap/click is used to restore the previously saved state of the camera.
  46091. */
  46092. useInputToRestoreState: boolean;
  46093. /** @hidden */
  46094. _viewMatrix: Matrix;
  46095. /** @hidden */
  46096. _useCtrlForPanning: boolean;
  46097. /** @hidden */
  46098. _panningMouseButton: number;
  46099. /**
  46100. * Defines the input associated to the camera.
  46101. */
  46102. inputs: ArcRotateCameraInputsManager;
  46103. /** @hidden */
  46104. _reset: () => void;
  46105. /**
  46106. * Defines the allowed panning axis.
  46107. */
  46108. panningAxis: Vector3;
  46109. protected _localDirection: Vector3;
  46110. protected _transformedDirection: Vector3;
  46111. private _bouncingBehavior;
  46112. /**
  46113. * Gets the bouncing behavior of the camera if it has been enabled.
  46114. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46115. */
  46116. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46117. /**
  46118. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46119. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46120. */
  46121. get useBouncingBehavior(): boolean;
  46122. set useBouncingBehavior(value: boolean);
  46123. private _framingBehavior;
  46124. /**
  46125. * Gets the framing behavior of the camera if it has been enabled.
  46126. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46127. */
  46128. get framingBehavior(): Nullable<FramingBehavior>;
  46129. /**
  46130. * Defines if the framing behavior of the camera is enabled on the camera.
  46131. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46132. */
  46133. get useFramingBehavior(): boolean;
  46134. set useFramingBehavior(value: boolean);
  46135. private _autoRotationBehavior;
  46136. /**
  46137. * Gets the auto rotation behavior of the camera if it has been enabled.
  46138. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46139. */
  46140. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46141. /**
  46142. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46143. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46144. */
  46145. get useAutoRotationBehavior(): boolean;
  46146. set useAutoRotationBehavior(value: boolean);
  46147. /**
  46148. * Observable triggered when the mesh target has been changed on the camera.
  46149. */
  46150. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46151. /**
  46152. * Event raised when the camera is colliding with a mesh.
  46153. */
  46154. onCollide: (collidedMesh: AbstractMesh) => void;
  46155. /**
  46156. * Defines whether the camera should check collision with the objects oh the scene.
  46157. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46158. */
  46159. checkCollisions: boolean;
  46160. /**
  46161. * Defines the collision radius of the camera.
  46162. * This simulates a sphere around the camera.
  46163. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46164. */
  46165. collisionRadius: Vector3;
  46166. protected _collider: Collider;
  46167. protected _previousPosition: Vector3;
  46168. protected _collisionVelocity: Vector3;
  46169. protected _newPosition: Vector3;
  46170. protected _previousAlpha: number;
  46171. protected _previousBeta: number;
  46172. protected _previousRadius: number;
  46173. protected _collisionTriggered: boolean;
  46174. protected _targetBoundingCenter: Nullable<Vector3>;
  46175. private _computationVector;
  46176. /**
  46177. * Instantiates a new ArcRotateCamera in a given scene
  46178. * @param name Defines the name of the camera
  46179. * @param alpha Defines the camera rotation along the logitudinal axis
  46180. * @param beta Defines the camera rotation along the latitudinal axis
  46181. * @param radius Defines the camera distance from its target
  46182. * @param target Defines the camera target
  46183. * @param scene Defines the scene the camera belongs to
  46184. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46185. */
  46186. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46187. /** @hidden */
  46188. _initCache(): void;
  46189. /** @hidden */
  46190. _updateCache(ignoreParentClass?: boolean): void;
  46191. protected _getTargetPosition(): Vector3;
  46192. private _storedAlpha;
  46193. private _storedBeta;
  46194. private _storedRadius;
  46195. private _storedTarget;
  46196. private _storedTargetScreenOffset;
  46197. /**
  46198. * Stores the current state of the camera (alpha, beta, radius and target)
  46199. * @returns the camera itself
  46200. */
  46201. storeState(): Camera;
  46202. /**
  46203. * @hidden
  46204. * Restored camera state. You must call storeState() first
  46205. */
  46206. _restoreStateValues(): boolean;
  46207. /** @hidden */
  46208. _isSynchronizedViewMatrix(): boolean;
  46209. /**
  46210. * Attached controls to the current camera.
  46211. * @param element Defines the element the controls should be listened from
  46212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46213. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46214. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46215. */
  46216. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46217. /**
  46218. * Detach the current controls from the camera.
  46219. * The camera will stop reacting to inputs.
  46220. * @param element Defines the element to stop listening the inputs from
  46221. */
  46222. detachControl(element: HTMLElement): void;
  46223. /** @hidden */
  46224. _checkInputs(): void;
  46225. protected _checkLimits(): void;
  46226. /**
  46227. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46228. */
  46229. rebuildAnglesAndRadius(): void;
  46230. /**
  46231. * Use a position to define the current camera related information like alpha, beta and radius
  46232. * @param position Defines the position to set the camera at
  46233. */
  46234. setPosition(position: Vector3): void;
  46235. /**
  46236. * Defines the target the camera should look at.
  46237. * This will automatically adapt alpha beta and radius to fit within the new target.
  46238. * @param target Defines the new target as a Vector or a mesh
  46239. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46240. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46241. */
  46242. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46243. /** @hidden */
  46244. _getViewMatrix(): Matrix;
  46245. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46246. /**
  46247. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46248. * @param meshes Defines the mesh to zoom on
  46249. * @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)
  46250. */
  46251. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46252. /**
  46253. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46254. * The target will be changed but the radius
  46255. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46256. * @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)
  46257. */
  46258. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46259. min: Vector3;
  46260. max: Vector3;
  46261. distance: number;
  46262. }, doNotUpdateMaxZ?: boolean): void;
  46263. /**
  46264. * @override
  46265. * Override Camera.createRigCamera
  46266. */
  46267. createRigCamera(name: string, cameraIndex: number): Camera;
  46268. /**
  46269. * @hidden
  46270. * @override
  46271. * Override Camera._updateRigCameras
  46272. */
  46273. _updateRigCameras(): void;
  46274. /**
  46275. * Destroy the camera and release the current resources hold by it.
  46276. */
  46277. dispose(): void;
  46278. /**
  46279. * Gets the current object class name.
  46280. * @return the class name
  46281. */
  46282. getClassName(): string;
  46283. }
  46284. }
  46285. declare module BABYLON {
  46286. /**
  46287. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46288. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46289. */
  46290. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46291. /**
  46292. * Gets the name of the behavior.
  46293. */
  46294. get name(): string;
  46295. private _zoomStopsAnimation;
  46296. private _idleRotationSpeed;
  46297. private _idleRotationWaitTime;
  46298. private _idleRotationSpinupTime;
  46299. /**
  46300. * Sets the flag that indicates if user zooming should stop animation.
  46301. */
  46302. set zoomStopsAnimation(flag: boolean);
  46303. /**
  46304. * Gets the flag that indicates if user zooming should stop animation.
  46305. */
  46306. get zoomStopsAnimation(): boolean;
  46307. /**
  46308. * Sets the default speed at which the camera rotates around the model.
  46309. */
  46310. set idleRotationSpeed(speed: number);
  46311. /**
  46312. * Gets the default speed at which the camera rotates around the model.
  46313. */
  46314. get idleRotationSpeed(): number;
  46315. /**
  46316. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46317. */
  46318. set idleRotationWaitTime(time: number);
  46319. /**
  46320. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46321. */
  46322. get idleRotationWaitTime(): number;
  46323. /**
  46324. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46325. */
  46326. set idleRotationSpinupTime(time: number);
  46327. /**
  46328. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46329. */
  46330. get idleRotationSpinupTime(): number;
  46331. /**
  46332. * Gets a value indicating if the camera is currently rotating because of this behavior
  46333. */
  46334. get rotationInProgress(): boolean;
  46335. private _onPrePointerObservableObserver;
  46336. private _onAfterCheckInputsObserver;
  46337. private _attachedCamera;
  46338. private _isPointerDown;
  46339. private _lastFrameTime;
  46340. private _lastInteractionTime;
  46341. private _cameraRotationSpeed;
  46342. /**
  46343. * Initializes the behavior.
  46344. */
  46345. init(): void;
  46346. /**
  46347. * Attaches the behavior to its arc rotate camera.
  46348. * @param camera Defines the camera to attach the behavior to
  46349. */
  46350. attach(camera: ArcRotateCamera): void;
  46351. /**
  46352. * Detaches the behavior from its current arc rotate camera.
  46353. */
  46354. detach(): void;
  46355. /**
  46356. * Returns true if user is scrolling.
  46357. * @return true if user is scrolling.
  46358. */
  46359. private _userIsZooming;
  46360. private _lastFrameRadius;
  46361. private _shouldAnimationStopForInteraction;
  46362. /**
  46363. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46364. */
  46365. private _applyUserInteraction;
  46366. private _userIsMoving;
  46367. }
  46368. }
  46369. declare module BABYLON {
  46370. /**
  46371. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46372. */
  46373. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46374. private ui;
  46375. /**
  46376. * The name of the behavior
  46377. */
  46378. name: string;
  46379. /**
  46380. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46381. */
  46382. distanceAwayFromFace: number;
  46383. /**
  46384. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46385. */
  46386. distanceAwayFromBottomOfFace: number;
  46387. private _faceVectors;
  46388. private _target;
  46389. private _scene;
  46390. private _onRenderObserver;
  46391. private _tmpMatrix;
  46392. private _tmpVector;
  46393. /**
  46394. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46395. * @param ui The transform node that should be attched to the mesh
  46396. */
  46397. constructor(ui: TransformNode);
  46398. /**
  46399. * Initializes the behavior
  46400. */
  46401. init(): void;
  46402. private _closestFace;
  46403. private _zeroVector;
  46404. private _lookAtTmpMatrix;
  46405. private _lookAtToRef;
  46406. /**
  46407. * Attaches the AttachToBoxBehavior to the passed in mesh
  46408. * @param target The mesh that the specified node will be attached to
  46409. */
  46410. attach(target: Mesh): void;
  46411. /**
  46412. * Detaches the behavior from the mesh
  46413. */
  46414. detach(): void;
  46415. }
  46416. }
  46417. declare module BABYLON {
  46418. /**
  46419. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46420. */
  46421. export class FadeInOutBehavior implements Behavior<Mesh> {
  46422. /**
  46423. * Time in milliseconds to delay before fading in (Default: 0)
  46424. */
  46425. delay: number;
  46426. /**
  46427. * Time in milliseconds for the mesh to fade in (Default: 300)
  46428. */
  46429. fadeInTime: number;
  46430. private _millisecondsPerFrame;
  46431. private _hovered;
  46432. private _hoverValue;
  46433. private _ownerNode;
  46434. /**
  46435. * Instatiates the FadeInOutBehavior
  46436. */
  46437. constructor();
  46438. /**
  46439. * The name of the behavior
  46440. */
  46441. get name(): string;
  46442. /**
  46443. * Initializes the behavior
  46444. */
  46445. init(): void;
  46446. /**
  46447. * Attaches the fade behavior on the passed in mesh
  46448. * @param ownerNode The mesh that will be faded in/out once attached
  46449. */
  46450. attach(ownerNode: Mesh): void;
  46451. /**
  46452. * Detaches the behavior from the mesh
  46453. */
  46454. detach(): void;
  46455. /**
  46456. * Triggers the mesh to begin fading in or out
  46457. * @param value if the object should fade in or out (true to fade in)
  46458. */
  46459. fadeIn(value: boolean): void;
  46460. private _update;
  46461. private _setAllVisibility;
  46462. }
  46463. }
  46464. declare module BABYLON {
  46465. /**
  46466. * Class containing a set of static utilities functions for managing Pivots
  46467. * @hidden
  46468. */
  46469. export class PivotTools {
  46470. private static _PivotCached;
  46471. private static _OldPivotPoint;
  46472. private static _PivotTranslation;
  46473. private static _PivotTmpVector;
  46474. private static _PivotPostMultiplyPivotMatrix;
  46475. /** @hidden */
  46476. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46477. /** @hidden */
  46478. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46479. }
  46480. }
  46481. declare module BABYLON {
  46482. /**
  46483. * Class containing static functions to help procedurally build meshes
  46484. */
  46485. export class PlaneBuilder {
  46486. /**
  46487. * Creates a plane mesh
  46488. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46489. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46490. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46492. * * 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
  46493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46494. * @param name defines the name of the mesh
  46495. * @param options defines the options used to create the mesh
  46496. * @param scene defines the hosting scene
  46497. * @returns the plane mesh
  46498. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46499. */
  46500. static CreatePlane(name: string, options: {
  46501. size?: number;
  46502. width?: number;
  46503. height?: number;
  46504. sideOrientation?: number;
  46505. frontUVs?: Vector4;
  46506. backUVs?: Vector4;
  46507. updatable?: boolean;
  46508. sourcePlane?: Plane;
  46509. }, scene?: Nullable<Scene>): Mesh;
  46510. }
  46511. }
  46512. declare module BABYLON {
  46513. /**
  46514. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46515. */
  46516. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46517. private static _AnyMouseID;
  46518. /**
  46519. * Abstract mesh the behavior is set on
  46520. */
  46521. attachedNode: AbstractMesh;
  46522. private _dragPlane;
  46523. private _scene;
  46524. private _pointerObserver;
  46525. private _beforeRenderObserver;
  46526. private static _planeScene;
  46527. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46528. /**
  46529. * 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)
  46530. */
  46531. maxDragAngle: number;
  46532. /**
  46533. * @hidden
  46534. */
  46535. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46536. /**
  46537. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46538. */
  46539. currentDraggingPointerID: number;
  46540. /**
  46541. * The last position where the pointer hit the drag plane in world space
  46542. */
  46543. lastDragPosition: Vector3;
  46544. /**
  46545. * If the behavior is currently in a dragging state
  46546. */
  46547. dragging: boolean;
  46548. /**
  46549. * 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)
  46550. */
  46551. dragDeltaRatio: number;
  46552. /**
  46553. * If the drag plane orientation should be updated during the dragging (Default: true)
  46554. */
  46555. updateDragPlane: boolean;
  46556. private _debugMode;
  46557. private _moving;
  46558. /**
  46559. * Fires each time the attached mesh is dragged with the pointer
  46560. * * delta between last drag position and current drag position in world space
  46561. * * dragDistance along the drag axis
  46562. * * dragPlaneNormal normal of the current drag plane used during the drag
  46563. * * dragPlanePoint in world space where the drag intersects the drag plane
  46564. */
  46565. onDragObservable: Observable<{
  46566. delta: Vector3;
  46567. dragPlanePoint: Vector3;
  46568. dragPlaneNormal: Vector3;
  46569. dragDistance: number;
  46570. pointerId: number;
  46571. }>;
  46572. /**
  46573. * Fires each time a drag begins (eg. mouse down on mesh)
  46574. */
  46575. onDragStartObservable: Observable<{
  46576. dragPlanePoint: Vector3;
  46577. pointerId: number;
  46578. }>;
  46579. /**
  46580. * Fires each time a drag ends (eg. mouse release after drag)
  46581. */
  46582. onDragEndObservable: Observable<{
  46583. dragPlanePoint: Vector3;
  46584. pointerId: number;
  46585. }>;
  46586. /**
  46587. * If the attached mesh should be moved when dragged
  46588. */
  46589. moveAttached: boolean;
  46590. /**
  46591. * If the drag behavior will react to drag events (Default: true)
  46592. */
  46593. enabled: boolean;
  46594. /**
  46595. * If pointer events should start and release the drag (Default: true)
  46596. */
  46597. startAndReleaseDragOnPointerEvents: boolean;
  46598. /**
  46599. * If camera controls should be detached during the drag
  46600. */
  46601. detachCameraControls: boolean;
  46602. /**
  46603. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46604. */
  46605. useObjectOrientationForDragging: boolean;
  46606. private _options;
  46607. /**
  46608. * Gets the options used by the behavior
  46609. */
  46610. get options(): {
  46611. dragAxis?: Vector3;
  46612. dragPlaneNormal?: Vector3;
  46613. };
  46614. /**
  46615. * Sets the options used by the behavior
  46616. */
  46617. set options(options: {
  46618. dragAxis?: Vector3;
  46619. dragPlaneNormal?: Vector3;
  46620. });
  46621. /**
  46622. * Creates a pointer drag behavior that can be attached to a mesh
  46623. * @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)
  46624. */
  46625. constructor(options?: {
  46626. dragAxis?: Vector3;
  46627. dragPlaneNormal?: Vector3;
  46628. });
  46629. /**
  46630. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46631. */
  46632. validateDrag: (targetPosition: Vector3) => boolean;
  46633. /**
  46634. * The name of the behavior
  46635. */
  46636. get name(): string;
  46637. /**
  46638. * Initializes the behavior
  46639. */
  46640. init(): void;
  46641. private _tmpVector;
  46642. private _alternatePickedPoint;
  46643. private _worldDragAxis;
  46644. private _targetPosition;
  46645. private _attachedElement;
  46646. /**
  46647. * Attaches the drag behavior the passed in mesh
  46648. * @param ownerNode The mesh that will be dragged around once attached
  46649. * @param predicate Predicate to use for pick filtering
  46650. */
  46651. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46652. /**
  46653. * Force relase the drag action by code.
  46654. */
  46655. releaseDrag(): void;
  46656. private _startDragRay;
  46657. private _lastPointerRay;
  46658. /**
  46659. * Simulates the start of a pointer drag event on the behavior
  46660. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46661. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46662. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46663. */
  46664. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46665. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46666. private _dragDelta;
  46667. protected _moveDrag(ray: Ray): void;
  46668. private _pickWithRayOnDragPlane;
  46669. private _pointA;
  46670. private _pointC;
  46671. private _localAxis;
  46672. private _lookAt;
  46673. private _updateDragPlanePosition;
  46674. /**
  46675. * Detaches the behavior from the mesh
  46676. */
  46677. detach(): void;
  46678. }
  46679. }
  46680. declare module BABYLON {
  46681. /**
  46682. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46683. */
  46684. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46685. private _dragBehaviorA;
  46686. private _dragBehaviorB;
  46687. private _startDistance;
  46688. private _initialScale;
  46689. private _targetScale;
  46690. private _ownerNode;
  46691. private _sceneRenderObserver;
  46692. /**
  46693. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46694. */
  46695. constructor();
  46696. /**
  46697. * The name of the behavior
  46698. */
  46699. get name(): string;
  46700. /**
  46701. * Initializes the behavior
  46702. */
  46703. init(): void;
  46704. private _getCurrentDistance;
  46705. /**
  46706. * Attaches the scale behavior the passed in mesh
  46707. * @param ownerNode The mesh that will be scaled around once attached
  46708. */
  46709. attach(ownerNode: Mesh): void;
  46710. /**
  46711. * Detaches the behavior from the mesh
  46712. */
  46713. detach(): void;
  46714. }
  46715. }
  46716. declare module BABYLON {
  46717. /**
  46718. * 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
  46719. */
  46720. export class SixDofDragBehavior implements Behavior<Mesh> {
  46721. private static _virtualScene;
  46722. private _ownerNode;
  46723. private _sceneRenderObserver;
  46724. private _scene;
  46725. private _targetPosition;
  46726. private _virtualOriginMesh;
  46727. private _virtualDragMesh;
  46728. private _pointerObserver;
  46729. private _moving;
  46730. private _startingOrientation;
  46731. private _attachedElement;
  46732. /**
  46733. * 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)
  46734. */
  46735. private zDragFactor;
  46736. /**
  46737. * If the object should rotate to face the drag origin
  46738. */
  46739. rotateDraggedObject: boolean;
  46740. /**
  46741. * If the behavior is currently in a dragging state
  46742. */
  46743. dragging: boolean;
  46744. /**
  46745. * 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)
  46746. */
  46747. dragDeltaRatio: number;
  46748. /**
  46749. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46750. */
  46751. currentDraggingPointerID: number;
  46752. /**
  46753. * If camera controls should be detached during the drag
  46754. */
  46755. detachCameraControls: boolean;
  46756. /**
  46757. * Fires each time a drag starts
  46758. */
  46759. onDragStartObservable: Observable<{}>;
  46760. /**
  46761. * Fires each time a drag ends (eg. mouse release after drag)
  46762. */
  46763. onDragEndObservable: Observable<{}>;
  46764. /**
  46765. * 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
  46766. */
  46767. constructor();
  46768. /**
  46769. * The name of the behavior
  46770. */
  46771. get name(): string;
  46772. /**
  46773. * Initializes the behavior
  46774. */
  46775. init(): void;
  46776. /**
  46777. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  46778. */
  46779. private get _pointerCamera();
  46780. /**
  46781. * Attaches the scale behavior the passed in mesh
  46782. * @param ownerNode The mesh that will be scaled around once attached
  46783. */
  46784. attach(ownerNode: Mesh): void;
  46785. /**
  46786. * Detaches the behavior from the mesh
  46787. */
  46788. detach(): void;
  46789. }
  46790. }
  46791. declare module BABYLON {
  46792. /**
  46793. * Class used to apply inverse kinematics to bones
  46794. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  46795. */
  46796. export class BoneIKController {
  46797. private static _tmpVecs;
  46798. private static _tmpQuat;
  46799. private static _tmpMats;
  46800. /**
  46801. * Gets or sets the target mesh
  46802. */
  46803. targetMesh: AbstractMesh;
  46804. /** Gets or sets the mesh used as pole */
  46805. poleTargetMesh: AbstractMesh;
  46806. /**
  46807. * Gets or sets the bone used as pole
  46808. */
  46809. poleTargetBone: Nullable<Bone>;
  46810. /**
  46811. * Gets or sets the target position
  46812. */
  46813. targetPosition: Vector3;
  46814. /**
  46815. * Gets or sets the pole target position
  46816. */
  46817. poleTargetPosition: Vector3;
  46818. /**
  46819. * Gets or sets the pole target local offset
  46820. */
  46821. poleTargetLocalOffset: Vector3;
  46822. /**
  46823. * Gets or sets the pole angle
  46824. */
  46825. poleAngle: number;
  46826. /**
  46827. * Gets or sets the mesh associated with the controller
  46828. */
  46829. mesh: AbstractMesh;
  46830. /**
  46831. * 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)
  46832. */
  46833. slerpAmount: number;
  46834. private _bone1Quat;
  46835. private _bone1Mat;
  46836. private _bone2Ang;
  46837. private _bone1;
  46838. private _bone2;
  46839. private _bone1Length;
  46840. private _bone2Length;
  46841. private _maxAngle;
  46842. private _maxReach;
  46843. private _rightHandedSystem;
  46844. private _bendAxis;
  46845. private _slerping;
  46846. private _adjustRoll;
  46847. /**
  46848. * Gets or sets maximum allowed angle
  46849. */
  46850. get maxAngle(): number;
  46851. set maxAngle(value: number);
  46852. /**
  46853. * Creates a new BoneIKController
  46854. * @param mesh defines the mesh to control
  46855. * @param bone defines the bone to control
  46856. * @param options defines options to set up the controller
  46857. */
  46858. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  46859. targetMesh?: AbstractMesh;
  46860. poleTargetMesh?: AbstractMesh;
  46861. poleTargetBone?: Bone;
  46862. poleTargetLocalOffset?: Vector3;
  46863. poleAngle?: number;
  46864. bendAxis?: Vector3;
  46865. maxAngle?: number;
  46866. slerpAmount?: number;
  46867. });
  46868. private _setMaxAngle;
  46869. /**
  46870. * Force the controller to update the bones
  46871. */
  46872. update(): void;
  46873. }
  46874. }
  46875. declare module BABYLON {
  46876. /**
  46877. * Class used to make a bone look toward a point in space
  46878. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  46879. */
  46880. export class BoneLookController {
  46881. private static _tmpVecs;
  46882. private static _tmpQuat;
  46883. private static _tmpMats;
  46884. /**
  46885. * The target Vector3 that the bone will look at
  46886. */
  46887. target: Vector3;
  46888. /**
  46889. * The mesh that the bone is attached to
  46890. */
  46891. mesh: AbstractMesh;
  46892. /**
  46893. * The bone that will be looking to the target
  46894. */
  46895. bone: Bone;
  46896. /**
  46897. * The up axis of the coordinate system that is used when the bone is rotated
  46898. */
  46899. upAxis: Vector3;
  46900. /**
  46901. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  46902. */
  46903. upAxisSpace: Space;
  46904. /**
  46905. * Used to make an adjustment to the yaw of the bone
  46906. */
  46907. adjustYaw: number;
  46908. /**
  46909. * Used to make an adjustment to the pitch of the bone
  46910. */
  46911. adjustPitch: number;
  46912. /**
  46913. * Used to make an adjustment to the roll of the bone
  46914. */
  46915. adjustRoll: number;
  46916. /**
  46917. * 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)
  46918. */
  46919. slerpAmount: number;
  46920. private _minYaw;
  46921. private _maxYaw;
  46922. private _minPitch;
  46923. private _maxPitch;
  46924. private _minYawSin;
  46925. private _minYawCos;
  46926. private _maxYawSin;
  46927. private _maxYawCos;
  46928. private _midYawConstraint;
  46929. private _minPitchTan;
  46930. private _maxPitchTan;
  46931. private _boneQuat;
  46932. private _slerping;
  46933. private _transformYawPitch;
  46934. private _transformYawPitchInv;
  46935. private _firstFrameSkipped;
  46936. private _yawRange;
  46937. private _fowardAxis;
  46938. /**
  46939. * Gets or sets the minimum yaw angle that the bone can look to
  46940. */
  46941. get minYaw(): number;
  46942. set minYaw(value: number);
  46943. /**
  46944. * Gets or sets the maximum yaw angle that the bone can look to
  46945. */
  46946. get maxYaw(): number;
  46947. set maxYaw(value: number);
  46948. /**
  46949. * Gets or sets the minimum pitch angle that the bone can look to
  46950. */
  46951. get minPitch(): number;
  46952. set minPitch(value: number);
  46953. /**
  46954. * Gets or sets the maximum pitch angle that the bone can look to
  46955. */
  46956. get maxPitch(): number;
  46957. set maxPitch(value: number);
  46958. /**
  46959. * Create a BoneLookController
  46960. * @param mesh the mesh that the bone belongs to
  46961. * @param bone the bone that will be looking to the target
  46962. * @param target the target Vector3 to look at
  46963. * @param options optional settings:
  46964. * * maxYaw: the maximum angle the bone will yaw to
  46965. * * minYaw: the minimum angle the bone will yaw to
  46966. * * maxPitch: the maximum angle the bone will pitch to
  46967. * * minPitch: the minimum angle the bone will yaw to
  46968. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  46969. * * upAxis: the up axis of the coordinate system
  46970. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  46971. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  46972. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  46973. * * adjustYaw: used to make an adjustment to the yaw of the bone
  46974. * * adjustPitch: used to make an adjustment to the pitch of the bone
  46975. * * adjustRoll: used to make an adjustment to the roll of the bone
  46976. **/
  46977. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  46978. maxYaw?: number;
  46979. minYaw?: number;
  46980. maxPitch?: number;
  46981. minPitch?: number;
  46982. slerpAmount?: number;
  46983. upAxis?: Vector3;
  46984. upAxisSpace?: Space;
  46985. yawAxis?: Vector3;
  46986. pitchAxis?: Vector3;
  46987. adjustYaw?: number;
  46988. adjustPitch?: number;
  46989. adjustRoll?: number;
  46990. });
  46991. /**
  46992. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  46993. */
  46994. update(): void;
  46995. private _getAngleDiff;
  46996. private _getAngleBetween;
  46997. private _isAngleBetween;
  46998. }
  46999. }
  47000. declare module BABYLON {
  47001. /**
  47002. * Manage the gamepad inputs to control an arc rotate camera.
  47003. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47004. */
  47005. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47006. /**
  47007. * Defines the camera the input is attached to.
  47008. */
  47009. camera: ArcRotateCamera;
  47010. /**
  47011. * Defines the gamepad the input is gathering event from.
  47012. */
  47013. gamepad: Nullable<Gamepad>;
  47014. /**
  47015. * Defines the gamepad rotation sensiblity.
  47016. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47017. */
  47018. gamepadRotationSensibility: number;
  47019. /**
  47020. * Defines the gamepad move sensiblity.
  47021. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47022. */
  47023. gamepadMoveSensibility: number;
  47024. private _yAxisScale;
  47025. /**
  47026. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47027. */
  47028. get invertYAxis(): boolean;
  47029. set invertYAxis(value: boolean);
  47030. private _onGamepadConnectedObserver;
  47031. private _onGamepadDisconnectedObserver;
  47032. /**
  47033. * Attach the input controls to a specific dom element to get the input from.
  47034. * @param element Defines the element the controls should be listened from
  47035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47036. */
  47037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47038. /**
  47039. * Detach the current controls from the specified dom element.
  47040. * @param element Defines the element to stop listening the inputs from
  47041. */
  47042. detachControl(element: Nullable<HTMLElement>): void;
  47043. /**
  47044. * Update the current camera state depending on the inputs that have been used this frame.
  47045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47046. */
  47047. checkInputs(): void;
  47048. /**
  47049. * Gets the class name of the current intput.
  47050. * @returns the class name
  47051. */
  47052. getClassName(): string;
  47053. /**
  47054. * Get the friendly name associated with the input class.
  47055. * @returns the input friendly name
  47056. */
  47057. getSimpleName(): string;
  47058. }
  47059. }
  47060. declare module BABYLON {
  47061. interface ArcRotateCameraInputsManager {
  47062. /**
  47063. * Add orientation input support to the input manager.
  47064. * @returns the current input manager
  47065. */
  47066. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47067. }
  47068. /**
  47069. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47070. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47071. */
  47072. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47073. /**
  47074. * Defines the camera the input is attached to.
  47075. */
  47076. camera: ArcRotateCamera;
  47077. /**
  47078. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47079. */
  47080. alphaCorrection: number;
  47081. /**
  47082. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47083. */
  47084. gammaCorrection: number;
  47085. private _alpha;
  47086. private _gamma;
  47087. private _dirty;
  47088. private _deviceOrientationHandler;
  47089. /**
  47090. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47091. */
  47092. constructor();
  47093. /**
  47094. * Attach the input controls to a specific dom element to get the input from.
  47095. * @param element Defines the element the controls should be listened from
  47096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47097. */
  47098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47099. /** @hidden */
  47100. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47101. /**
  47102. * Update the current camera state depending on the inputs that have been used this frame.
  47103. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47104. */
  47105. checkInputs(): void;
  47106. /**
  47107. * Detach the current controls from the specified dom element.
  47108. * @param element Defines the element to stop listening the inputs from
  47109. */
  47110. detachControl(element: Nullable<HTMLElement>): void;
  47111. /**
  47112. * Gets the class name of the current intput.
  47113. * @returns the class name
  47114. */
  47115. getClassName(): string;
  47116. /**
  47117. * Get the friendly name associated with the input class.
  47118. * @returns the input friendly name
  47119. */
  47120. getSimpleName(): string;
  47121. }
  47122. }
  47123. declare module BABYLON {
  47124. /**
  47125. * Listen to mouse events to control the camera.
  47126. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47127. */
  47128. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47129. /**
  47130. * Defines the camera the input is attached to.
  47131. */
  47132. camera: FlyCamera;
  47133. /**
  47134. * Defines if touch is enabled. (Default is true.)
  47135. */
  47136. touchEnabled: boolean;
  47137. /**
  47138. * Defines the buttons associated with the input to handle camera rotation.
  47139. */
  47140. buttons: number[];
  47141. /**
  47142. * Assign buttons for Yaw control.
  47143. */
  47144. buttonsYaw: number[];
  47145. /**
  47146. * Assign buttons for Pitch control.
  47147. */
  47148. buttonsPitch: number[];
  47149. /**
  47150. * Assign buttons for Roll control.
  47151. */
  47152. buttonsRoll: number[];
  47153. /**
  47154. * Detect if any button is being pressed while mouse is moved.
  47155. * -1 = Mouse locked.
  47156. * 0 = Left button.
  47157. * 1 = Middle Button.
  47158. * 2 = Right Button.
  47159. */
  47160. activeButton: number;
  47161. /**
  47162. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47163. * Higher values reduce its sensitivity.
  47164. */
  47165. angularSensibility: number;
  47166. private _observer;
  47167. private _rollObserver;
  47168. private previousPosition;
  47169. private noPreventDefault;
  47170. private element;
  47171. /**
  47172. * Listen to mouse events to control the camera.
  47173. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47175. */
  47176. constructor(touchEnabled?: boolean);
  47177. /**
  47178. * Attach the mouse control to the HTML DOM element.
  47179. * @param element Defines the element that listens to the input events.
  47180. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47181. */
  47182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47183. /**
  47184. * Detach the current controls from the specified dom element.
  47185. * @param element Defines the element to stop listening the inputs from
  47186. */
  47187. detachControl(element: Nullable<HTMLElement>): void;
  47188. /**
  47189. * Gets the class name of the current input.
  47190. * @returns the class name.
  47191. */
  47192. getClassName(): string;
  47193. /**
  47194. * Get the friendly name associated with the input class.
  47195. * @returns the input's friendly name.
  47196. */
  47197. getSimpleName(): string;
  47198. private _pointerInput;
  47199. private _onMouseMove;
  47200. /**
  47201. * Rotate camera by mouse offset.
  47202. */
  47203. private rotateCamera;
  47204. }
  47205. }
  47206. declare module BABYLON {
  47207. /**
  47208. * Default Inputs manager for the FlyCamera.
  47209. * It groups all the default supported inputs for ease of use.
  47210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47211. */
  47212. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47213. /**
  47214. * Instantiates a new FlyCameraInputsManager.
  47215. * @param camera Defines the camera the inputs belong to.
  47216. */
  47217. constructor(camera: FlyCamera);
  47218. /**
  47219. * Add keyboard input support to the input manager.
  47220. * @returns the new FlyCameraKeyboardMoveInput().
  47221. */
  47222. addKeyboard(): FlyCameraInputsManager;
  47223. /**
  47224. * Add mouse input support to the input manager.
  47225. * @param touchEnabled Enable touch screen support.
  47226. * @returns the new FlyCameraMouseInput().
  47227. */
  47228. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47229. }
  47230. }
  47231. declare module BABYLON {
  47232. /**
  47233. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47234. * such as in a 3D Space Shooter or a Flight Simulator.
  47235. */
  47236. export class FlyCamera extends TargetCamera {
  47237. /**
  47238. * Define the collision ellipsoid of the camera.
  47239. * This is helpful for simulating a camera body, like a player's body.
  47240. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47241. */
  47242. ellipsoid: Vector3;
  47243. /**
  47244. * Define an offset for the position of the ellipsoid around the camera.
  47245. * This can be helpful if the camera is attached away from the player's body center,
  47246. * such as at its head.
  47247. */
  47248. ellipsoidOffset: Vector3;
  47249. /**
  47250. * Enable or disable collisions of the camera with the rest of the scene objects.
  47251. */
  47252. checkCollisions: boolean;
  47253. /**
  47254. * Enable or disable gravity on the camera.
  47255. */
  47256. applyGravity: boolean;
  47257. /**
  47258. * Define the current direction the camera is moving to.
  47259. */
  47260. cameraDirection: Vector3;
  47261. /**
  47262. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47263. * This overrides and empties cameraRotation.
  47264. */
  47265. rotationQuaternion: Quaternion;
  47266. /**
  47267. * Track Roll to maintain the wanted Rolling when looking around.
  47268. */
  47269. _trackRoll: number;
  47270. /**
  47271. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47272. */
  47273. rollCorrect: number;
  47274. /**
  47275. * Mimic a banked turn, Rolling the camera when Yawing.
  47276. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47277. */
  47278. bankedTurn: boolean;
  47279. /**
  47280. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47281. */
  47282. bankedTurnLimit: number;
  47283. /**
  47284. * Value of 0 disables the banked Roll.
  47285. * Value of 1 is equal to the Yaw angle in radians.
  47286. */
  47287. bankedTurnMultiplier: number;
  47288. /**
  47289. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47290. */
  47291. inputs: FlyCameraInputsManager;
  47292. /**
  47293. * Gets the input sensibility for mouse input.
  47294. * Higher values reduce sensitivity.
  47295. */
  47296. get angularSensibility(): number;
  47297. /**
  47298. * Sets the input sensibility for a mouse input.
  47299. * Higher values reduce sensitivity.
  47300. */
  47301. set angularSensibility(value: number);
  47302. /**
  47303. * Get the keys for camera movement forward.
  47304. */
  47305. get keysForward(): number[];
  47306. /**
  47307. * Set the keys for camera movement forward.
  47308. */
  47309. set keysForward(value: number[]);
  47310. /**
  47311. * Get the keys for camera movement backward.
  47312. */
  47313. get keysBackward(): number[];
  47314. set keysBackward(value: number[]);
  47315. /**
  47316. * Get the keys for camera movement up.
  47317. */
  47318. get keysUp(): number[];
  47319. /**
  47320. * Set the keys for camera movement up.
  47321. */
  47322. set keysUp(value: number[]);
  47323. /**
  47324. * Get the keys for camera movement down.
  47325. */
  47326. get keysDown(): number[];
  47327. /**
  47328. * Set the keys for camera movement down.
  47329. */
  47330. set keysDown(value: number[]);
  47331. /**
  47332. * Get the keys for camera movement left.
  47333. */
  47334. get keysLeft(): number[];
  47335. /**
  47336. * Set the keys for camera movement left.
  47337. */
  47338. set keysLeft(value: number[]);
  47339. /**
  47340. * Set the keys for camera movement right.
  47341. */
  47342. get keysRight(): number[];
  47343. /**
  47344. * Set the keys for camera movement right.
  47345. */
  47346. set keysRight(value: number[]);
  47347. /**
  47348. * Event raised when the camera collides with a mesh in the scene.
  47349. */
  47350. onCollide: (collidedMesh: AbstractMesh) => void;
  47351. private _collider;
  47352. private _needMoveForGravity;
  47353. private _oldPosition;
  47354. private _diffPosition;
  47355. private _newPosition;
  47356. /** @hidden */
  47357. _localDirection: Vector3;
  47358. /** @hidden */
  47359. _transformedDirection: Vector3;
  47360. /**
  47361. * Instantiates a FlyCamera.
  47362. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47363. * such as in a 3D Space Shooter or a Flight Simulator.
  47364. * @param name Define the name of the camera in the scene.
  47365. * @param position Define the starting position of the camera in the scene.
  47366. * @param scene Define the scene the camera belongs to.
  47367. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47368. */
  47369. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47370. /**
  47371. * Attach a control to the HTML DOM element.
  47372. * @param element Defines the element that listens to the input events.
  47373. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47374. */
  47375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47376. /**
  47377. * Detach a control from the HTML DOM element.
  47378. * The camera will stop reacting to that input.
  47379. * @param element Defines the element that listens to the input events.
  47380. */
  47381. detachControl(element: HTMLElement): void;
  47382. private _collisionMask;
  47383. /**
  47384. * Get the mask that the camera ignores in collision events.
  47385. */
  47386. get collisionMask(): number;
  47387. /**
  47388. * Set the mask that the camera ignores in collision events.
  47389. */
  47390. set collisionMask(mask: number);
  47391. /** @hidden */
  47392. _collideWithWorld(displacement: Vector3): void;
  47393. /** @hidden */
  47394. private _onCollisionPositionChange;
  47395. /** @hidden */
  47396. _checkInputs(): void;
  47397. /** @hidden */
  47398. _decideIfNeedsToMove(): boolean;
  47399. /** @hidden */
  47400. _updatePosition(): void;
  47401. /**
  47402. * Restore the Roll to its target value at the rate specified.
  47403. * @param rate - Higher means slower restoring.
  47404. * @hidden
  47405. */
  47406. restoreRoll(rate: number): void;
  47407. /**
  47408. * Destroy the camera and release the current resources held by it.
  47409. */
  47410. dispose(): void;
  47411. /**
  47412. * Get the current object class name.
  47413. * @returns the class name.
  47414. */
  47415. getClassName(): string;
  47416. }
  47417. }
  47418. declare module BABYLON {
  47419. /**
  47420. * Listen to keyboard events to control the camera.
  47421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47422. */
  47423. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47424. /**
  47425. * Defines the camera the input is attached to.
  47426. */
  47427. camera: FlyCamera;
  47428. /**
  47429. * The list of keyboard keys used to control the forward move of the camera.
  47430. */
  47431. keysForward: number[];
  47432. /**
  47433. * The list of keyboard keys used to control the backward move of the camera.
  47434. */
  47435. keysBackward: number[];
  47436. /**
  47437. * The list of keyboard keys used to control the forward move of the camera.
  47438. */
  47439. keysUp: number[];
  47440. /**
  47441. * The list of keyboard keys used to control the backward move of the camera.
  47442. */
  47443. keysDown: number[];
  47444. /**
  47445. * The list of keyboard keys used to control the right strafe move of the camera.
  47446. */
  47447. keysRight: number[];
  47448. /**
  47449. * The list of keyboard keys used to control the left strafe move of the camera.
  47450. */
  47451. keysLeft: number[];
  47452. private _keys;
  47453. private _onCanvasBlurObserver;
  47454. private _onKeyboardObserver;
  47455. private _engine;
  47456. private _scene;
  47457. /**
  47458. * Attach the input controls to a specific dom element to get the input from.
  47459. * @param element Defines the element the controls should be listened from
  47460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47461. */
  47462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47463. /**
  47464. * Detach the current controls from the specified dom element.
  47465. * @param element Defines the element to stop listening the inputs from
  47466. */
  47467. detachControl(element: Nullable<HTMLElement>): void;
  47468. /**
  47469. * Gets the class name of the current intput.
  47470. * @returns the class name
  47471. */
  47472. getClassName(): string;
  47473. /** @hidden */
  47474. _onLostFocus(e: FocusEvent): void;
  47475. /**
  47476. * Get the friendly name associated with the input class.
  47477. * @returns the input friendly name
  47478. */
  47479. getSimpleName(): string;
  47480. /**
  47481. * Update the current camera state depending on the inputs that have been used this frame.
  47482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47483. */
  47484. checkInputs(): void;
  47485. }
  47486. }
  47487. declare module BABYLON {
  47488. /**
  47489. * Manage the mouse wheel inputs to control a follow camera.
  47490. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47491. */
  47492. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47493. /**
  47494. * Defines the camera the input is attached to.
  47495. */
  47496. camera: FollowCamera;
  47497. /**
  47498. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47499. */
  47500. axisControlRadius: boolean;
  47501. /**
  47502. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47503. */
  47504. axisControlHeight: boolean;
  47505. /**
  47506. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47507. */
  47508. axisControlRotation: boolean;
  47509. /**
  47510. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47511. * relation to mouseWheel events.
  47512. */
  47513. wheelPrecision: number;
  47514. /**
  47515. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47516. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47517. */
  47518. wheelDeltaPercentage: number;
  47519. private _wheel;
  47520. private _observer;
  47521. /**
  47522. * Attach the input controls to a specific dom element to get the input from.
  47523. * @param element Defines the element the controls should be listened from
  47524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47525. */
  47526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47527. /**
  47528. * Detach the current controls from the specified dom element.
  47529. * @param element Defines the element to stop listening the inputs from
  47530. */
  47531. detachControl(element: Nullable<HTMLElement>): void;
  47532. /**
  47533. * Gets the class name of the current intput.
  47534. * @returns the class name
  47535. */
  47536. getClassName(): string;
  47537. /**
  47538. * Get the friendly name associated with the input class.
  47539. * @returns the input friendly name
  47540. */
  47541. getSimpleName(): string;
  47542. }
  47543. }
  47544. declare module BABYLON {
  47545. /**
  47546. * Manage the pointers inputs to control an follow camera.
  47547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47548. */
  47549. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47550. /**
  47551. * Defines the camera the input is attached to.
  47552. */
  47553. camera: FollowCamera;
  47554. /**
  47555. * Gets the class name of the current input.
  47556. * @returns the class name
  47557. */
  47558. getClassName(): string;
  47559. /**
  47560. * Defines the pointer angular sensibility along the X axis or how fast is
  47561. * the camera rotating.
  47562. * A negative number will reverse the axis direction.
  47563. */
  47564. angularSensibilityX: number;
  47565. /**
  47566. * Defines the pointer angular sensibility along the Y axis or how fast is
  47567. * the camera rotating.
  47568. * A negative number will reverse the axis direction.
  47569. */
  47570. angularSensibilityY: number;
  47571. /**
  47572. * Defines the pointer pinch precision or how fast is the camera zooming.
  47573. * A negative number will reverse the axis direction.
  47574. */
  47575. pinchPrecision: number;
  47576. /**
  47577. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47578. * from 0.
  47579. * It defines the percentage of current camera.radius to use as delta when
  47580. * pinch zoom is used.
  47581. */
  47582. pinchDeltaPercentage: number;
  47583. /**
  47584. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47585. */
  47586. axisXControlRadius: boolean;
  47587. /**
  47588. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47589. */
  47590. axisXControlHeight: boolean;
  47591. /**
  47592. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47593. */
  47594. axisXControlRotation: boolean;
  47595. /**
  47596. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47597. */
  47598. axisYControlRadius: boolean;
  47599. /**
  47600. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47601. */
  47602. axisYControlHeight: boolean;
  47603. /**
  47604. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47605. */
  47606. axisYControlRotation: boolean;
  47607. /**
  47608. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47609. */
  47610. axisPinchControlRadius: boolean;
  47611. /**
  47612. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47613. */
  47614. axisPinchControlHeight: boolean;
  47615. /**
  47616. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47617. */
  47618. axisPinchControlRotation: boolean;
  47619. /**
  47620. * Log error messages if basic misconfiguration has occurred.
  47621. */
  47622. warningEnable: boolean;
  47623. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47624. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47625. private _warningCounter;
  47626. private _warning;
  47627. }
  47628. }
  47629. declare module BABYLON {
  47630. /**
  47631. * Default Inputs manager for the FollowCamera.
  47632. * It groups all the default supported inputs for ease of use.
  47633. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47634. */
  47635. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47636. /**
  47637. * Instantiates a new FollowCameraInputsManager.
  47638. * @param camera Defines the camera the inputs belong to
  47639. */
  47640. constructor(camera: FollowCamera);
  47641. /**
  47642. * Add keyboard input support to the input manager.
  47643. * @returns the current input manager
  47644. */
  47645. addKeyboard(): FollowCameraInputsManager;
  47646. /**
  47647. * Add mouse wheel input support to the input manager.
  47648. * @returns the current input manager
  47649. */
  47650. addMouseWheel(): FollowCameraInputsManager;
  47651. /**
  47652. * Add pointers input support to the input manager.
  47653. * @returns the current input manager
  47654. */
  47655. addPointers(): FollowCameraInputsManager;
  47656. /**
  47657. * Add orientation input support to the input manager.
  47658. * @returns the current input manager
  47659. */
  47660. addVRDeviceOrientation(): FollowCameraInputsManager;
  47661. }
  47662. }
  47663. declare module BABYLON {
  47664. /**
  47665. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47666. * an arc rotate version arcFollowCamera are available.
  47667. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47668. */
  47669. export class FollowCamera extends TargetCamera {
  47670. /**
  47671. * Distance the follow camera should follow an object at
  47672. */
  47673. radius: number;
  47674. /**
  47675. * Minimum allowed distance of the camera to the axis of rotation
  47676. * (The camera can not get closer).
  47677. * This can help limiting how the Camera is able to move in the scene.
  47678. */
  47679. lowerRadiusLimit: Nullable<number>;
  47680. /**
  47681. * Maximum allowed distance of the camera to the axis of rotation
  47682. * (The camera can not get further).
  47683. * This can help limiting how the Camera is able to move in the scene.
  47684. */
  47685. upperRadiusLimit: Nullable<number>;
  47686. /**
  47687. * Define a rotation offset between the camera and the object it follows
  47688. */
  47689. rotationOffset: number;
  47690. /**
  47691. * Minimum allowed angle to camera position relative to target object.
  47692. * This can help limiting how the Camera is able to move in the scene.
  47693. */
  47694. lowerRotationOffsetLimit: Nullable<number>;
  47695. /**
  47696. * Maximum allowed angle to camera position relative to target object.
  47697. * This can help limiting how the Camera is able to move in the scene.
  47698. */
  47699. upperRotationOffsetLimit: Nullable<number>;
  47700. /**
  47701. * Define a height offset between the camera and the object it follows.
  47702. * It can help following an object from the top (like a car chaing a plane)
  47703. */
  47704. heightOffset: number;
  47705. /**
  47706. * Minimum allowed height of camera position relative to target object.
  47707. * This can help limiting how the Camera is able to move in the scene.
  47708. */
  47709. lowerHeightOffsetLimit: Nullable<number>;
  47710. /**
  47711. * Maximum allowed height of camera position relative to target object.
  47712. * This can help limiting how the Camera is able to move in the scene.
  47713. */
  47714. upperHeightOffsetLimit: Nullable<number>;
  47715. /**
  47716. * Define how fast the camera can accelerate to follow it s target.
  47717. */
  47718. cameraAcceleration: number;
  47719. /**
  47720. * Define the speed limit of the camera following an object.
  47721. */
  47722. maxCameraSpeed: number;
  47723. /**
  47724. * Define the target of the camera.
  47725. */
  47726. lockedTarget: Nullable<AbstractMesh>;
  47727. /**
  47728. * Defines the input associated with the camera.
  47729. */
  47730. inputs: FollowCameraInputsManager;
  47731. /**
  47732. * Instantiates the follow camera.
  47733. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47734. * @param name Define the name of the camera in the scene
  47735. * @param position Define the position of the camera
  47736. * @param scene Define the scene the camera belong to
  47737. * @param lockedTarget Define the target of the camera
  47738. */
  47739. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  47740. private _follow;
  47741. /**
  47742. * Attached controls to the current camera.
  47743. * @param element Defines the element the controls should be listened from
  47744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47745. */
  47746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47747. /**
  47748. * Detach the current controls from the camera.
  47749. * The camera will stop reacting to inputs.
  47750. * @param element Defines the element to stop listening the inputs from
  47751. */
  47752. detachControl(element: HTMLElement): void;
  47753. /** @hidden */
  47754. _checkInputs(): void;
  47755. private _checkLimits;
  47756. /**
  47757. * Gets the camera class name.
  47758. * @returns the class name
  47759. */
  47760. getClassName(): string;
  47761. }
  47762. /**
  47763. * Arc Rotate version of the follow camera.
  47764. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  47765. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47766. */
  47767. export class ArcFollowCamera extends TargetCamera {
  47768. /** The longitudinal angle of the camera */
  47769. alpha: number;
  47770. /** The latitudinal angle of the camera */
  47771. beta: number;
  47772. /** The radius of the camera from its target */
  47773. radius: number;
  47774. private _cartesianCoordinates;
  47775. /** Define the camera target (the mesh it should follow) */
  47776. private _meshTarget;
  47777. /**
  47778. * Instantiates a new ArcFollowCamera
  47779. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47780. * @param name Define the name of the camera
  47781. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  47782. * @param beta Define the rotation angle of the camera around the elevation axis
  47783. * @param radius Define the radius of the camera from its target point
  47784. * @param target Define the target of the camera
  47785. * @param scene Define the scene the camera belongs to
  47786. */
  47787. constructor(name: string,
  47788. /** The longitudinal angle of the camera */
  47789. alpha: number,
  47790. /** The latitudinal angle of the camera */
  47791. beta: number,
  47792. /** The radius of the camera from its target */
  47793. radius: number,
  47794. /** Define the camera target (the mesh it should follow) */
  47795. target: Nullable<AbstractMesh>, scene: Scene);
  47796. private _follow;
  47797. /** @hidden */
  47798. _checkInputs(): void;
  47799. /**
  47800. * Returns the class name of the object.
  47801. * It is mostly used internally for serialization purposes.
  47802. */
  47803. getClassName(): string;
  47804. }
  47805. }
  47806. declare module BABYLON {
  47807. /**
  47808. * Manage the keyboard inputs to control the movement of a follow camera.
  47809. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47810. */
  47811. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  47812. /**
  47813. * Defines the camera the input is attached to.
  47814. */
  47815. camera: FollowCamera;
  47816. /**
  47817. * Defines the list of key codes associated with the up action (increase heightOffset)
  47818. */
  47819. keysHeightOffsetIncr: number[];
  47820. /**
  47821. * Defines the list of key codes associated with the down action (decrease heightOffset)
  47822. */
  47823. keysHeightOffsetDecr: number[];
  47824. /**
  47825. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  47826. */
  47827. keysHeightOffsetModifierAlt: boolean;
  47828. /**
  47829. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  47830. */
  47831. keysHeightOffsetModifierCtrl: boolean;
  47832. /**
  47833. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  47834. */
  47835. keysHeightOffsetModifierShift: boolean;
  47836. /**
  47837. * Defines the list of key codes associated with the left action (increase rotationOffset)
  47838. */
  47839. keysRotationOffsetIncr: number[];
  47840. /**
  47841. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  47842. */
  47843. keysRotationOffsetDecr: number[];
  47844. /**
  47845. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  47846. */
  47847. keysRotationOffsetModifierAlt: boolean;
  47848. /**
  47849. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  47850. */
  47851. keysRotationOffsetModifierCtrl: boolean;
  47852. /**
  47853. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  47854. */
  47855. keysRotationOffsetModifierShift: boolean;
  47856. /**
  47857. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  47858. */
  47859. keysRadiusIncr: number[];
  47860. /**
  47861. * Defines the list of key codes associated with the zoom-out action (increase radius)
  47862. */
  47863. keysRadiusDecr: number[];
  47864. /**
  47865. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  47866. */
  47867. keysRadiusModifierAlt: boolean;
  47868. /**
  47869. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  47870. */
  47871. keysRadiusModifierCtrl: boolean;
  47872. /**
  47873. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  47874. */
  47875. keysRadiusModifierShift: boolean;
  47876. /**
  47877. * Defines the rate of change of heightOffset.
  47878. */
  47879. heightSensibility: number;
  47880. /**
  47881. * Defines the rate of change of rotationOffset.
  47882. */
  47883. rotationSensibility: number;
  47884. /**
  47885. * Defines the rate of change of radius.
  47886. */
  47887. radiusSensibility: number;
  47888. private _keys;
  47889. private _ctrlPressed;
  47890. private _altPressed;
  47891. private _shiftPressed;
  47892. private _onCanvasBlurObserver;
  47893. private _onKeyboardObserver;
  47894. private _engine;
  47895. private _scene;
  47896. /**
  47897. * Attach the input controls to a specific dom element to get the input from.
  47898. * @param element Defines the element the controls should be listened from
  47899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47900. */
  47901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47902. /**
  47903. * Detach the current controls from the specified dom element.
  47904. * @param element Defines the element to stop listening the inputs from
  47905. */
  47906. detachControl(element: Nullable<HTMLElement>): void;
  47907. /**
  47908. * Update the current camera state depending on the inputs that have been used this frame.
  47909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47910. */
  47911. checkInputs(): void;
  47912. /**
  47913. * Gets the class name of the current input.
  47914. * @returns the class name
  47915. */
  47916. getClassName(): string;
  47917. /**
  47918. * Get the friendly name associated with the input class.
  47919. * @returns the input friendly name
  47920. */
  47921. getSimpleName(): string;
  47922. /**
  47923. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47924. * allow modification of the heightOffset value.
  47925. */
  47926. private _modifierHeightOffset;
  47927. /**
  47928. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47929. * allow modification of the rotationOffset value.
  47930. */
  47931. private _modifierRotationOffset;
  47932. /**
  47933. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47934. * allow modification of the radius value.
  47935. */
  47936. private _modifierRadius;
  47937. }
  47938. }
  47939. declare module BABYLON {
  47940. interface FreeCameraInputsManager {
  47941. /**
  47942. * @hidden
  47943. */
  47944. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  47945. /**
  47946. * Add orientation input support to the input manager.
  47947. * @returns the current input manager
  47948. */
  47949. addDeviceOrientation(): FreeCameraInputsManager;
  47950. }
  47951. /**
  47952. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  47953. * Screen rotation is taken into account.
  47954. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47955. */
  47956. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  47957. private _camera;
  47958. private _screenOrientationAngle;
  47959. private _constantTranform;
  47960. private _screenQuaternion;
  47961. private _alpha;
  47962. private _beta;
  47963. private _gamma;
  47964. /**
  47965. * Can be used to detect if a device orientation sensor is available on a device
  47966. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  47967. * @returns a promise that will resolve on orientation change
  47968. */
  47969. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  47970. /**
  47971. * @hidden
  47972. */
  47973. _onDeviceOrientationChangedObservable: Observable<void>;
  47974. /**
  47975. * Instantiates a new input
  47976. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47977. */
  47978. constructor();
  47979. /**
  47980. * Define the camera controlled by the input.
  47981. */
  47982. get camera(): FreeCamera;
  47983. set camera(camera: FreeCamera);
  47984. /**
  47985. * Attach the input controls to a specific dom element to get the input from.
  47986. * @param element Defines the element the controls should be listened from
  47987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47988. */
  47989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47990. private _orientationChanged;
  47991. private _deviceOrientation;
  47992. /**
  47993. * Detach the current controls from the specified dom element.
  47994. * @param element Defines the element to stop listening the inputs from
  47995. */
  47996. detachControl(element: Nullable<HTMLElement>): void;
  47997. /**
  47998. * Update the current camera state depending on the inputs that have been used this frame.
  47999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48000. */
  48001. checkInputs(): void;
  48002. /**
  48003. * Gets the class name of the current intput.
  48004. * @returns the class name
  48005. */
  48006. getClassName(): string;
  48007. /**
  48008. * Get the friendly name associated with the input class.
  48009. * @returns the input friendly name
  48010. */
  48011. getSimpleName(): string;
  48012. }
  48013. }
  48014. declare module BABYLON {
  48015. /**
  48016. * Manage the gamepad inputs to control a free camera.
  48017. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48018. */
  48019. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48020. /**
  48021. * Define the camera the input is attached to.
  48022. */
  48023. camera: FreeCamera;
  48024. /**
  48025. * Define the Gamepad controlling the input
  48026. */
  48027. gamepad: Nullable<Gamepad>;
  48028. /**
  48029. * Defines the gamepad rotation sensiblity.
  48030. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48031. */
  48032. gamepadAngularSensibility: number;
  48033. /**
  48034. * Defines the gamepad move sensiblity.
  48035. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48036. */
  48037. gamepadMoveSensibility: number;
  48038. private _yAxisScale;
  48039. /**
  48040. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48041. */
  48042. get invertYAxis(): boolean;
  48043. set invertYAxis(value: boolean);
  48044. private _onGamepadConnectedObserver;
  48045. private _onGamepadDisconnectedObserver;
  48046. private _cameraTransform;
  48047. private _deltaTransform;
  48048. private _vector3;
  48049. private _vector2;
  48050. /**
  48051. * Attach the input controls to a specific dom element to get the input from.
  48052. * @param element Defines the element the controls should be listened from
  48053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48054. */
  48055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48056. /**
  48057. * Detach the current controls from the specified dom element.
  48058. * @param element Defines the element to stop listening the inputs from
  48059. */
  48060. detachControl(element: Nullable<HTMLElement>): void;
  48061. /**
  48062. * Update the current camera state depending on the inputs that have been used this frame.
  48063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48064. */
  48065. checkInputs(): void;
  48066. /**
  48067. * Gets the class name of the current intput.
  48068. * @returns the class name
  48069. */
  48070. getClassName(): string;
  48071. /**
  48072. * Get the friendly name associated with the input class.
  48073. * @returns the input friendly name
  48074. */
  48075. getSimpleName(): string;
  48076. }
  48077. }
  48078. declare module BABYLON {
  48079. /**
  48080. * Defines the potential axis of a Joystick
  48081. */
  48082. export enum JoystickAxis {
  48083. /** X axis */
  48084. X = 0,
  48085. /** Y axis */
  48086. Y = 1,
  48087. /** Z axis */
  48088. Z = 2
  48089. }
  48090. /**
  48091. * Represents the different customization options available
  48092. * for VirtualJoystick
  48093. */
  48094. interface VirtualJoystickCustomizations {
  48095. /**
  48096. * Size of the joystick's puck
  48097. */
  48098. puckSize: number;
  48099. /**
  48100. * Size of the joystick's container
  48101. */
  48102. containerSize: number;
  48103. /**
  48104. * Color of the joystick && puck
  48105. */
  48106. color: string;
  48107. /**
  48108. * Image URL for the joystick's puck
  48109. */
  48110. puckImage?: string;
  48111. /**
  48112. * Image URL for the joystick's container
  48113. */
  48114. containerImage?: string;
  48115. /**
  48116. * Defines the unmoving position of the joystick container
  48117. */
  48118. position?: {
  48119. x: number;
  48120. y: number;
  48121. };
  48122. /**
  48123. * Defines whether or not the joystick container is always visible
  48124. */
  48125. alwaysVisible: boolean;
  48126. /**
  48127. * Defines whether or not to limit the movement of the puck to the joystick's container
  48128. */
  48129. limitToContainer: boolean;
  48130. }
  48131. /**
  48132. * Class used to define virtual joystick (used in touch mode)
  48133. */
  48134. export class VirtualJoystick {
  48135. /**
  48136. * Gets or sets a boolean indicating that left and right values must be inverted
  48137. */
  48138. reverseLeftRight: boolean;
  48139. /**
  48140. * Gets or sets a boolean indicating that up and down values must be inverted
  48141. */
  48142. reverseUpDown: boolean;
  48143. /**
  48144. * Gets the offset value for the position (ie. the change of the position value)
  48145. */
  48146. deltaPosition: Vector3;
  48147. /**
  48148. * Gets a boolean indicating if the virtual joystick was pressed
  48149. */
  48150. pressed: boolean;
  48151. /**
  48152. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48153. */
  48154. static Canvas: Nullable<HTMLCanvasElement>;
  48155. /**
  48156. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48157. */
  48158. limitToContainer: boolean;
  48159. private static _globalJoystickIndex;
  48160. private static _alwaysVisibleSticks;
  48161. private static vjCanvasContext;
  48162. private static vjCanvasWidth;
  48163. private static vjCanvasHeight;
  48164. private static halfWidth;
  48165. private static _GetDefaultOptions;
  48166. private _action;
  48167. private _axisTargetedByLeftAndRight;
  48168. private _axisTargetedByUpAndDown;
  48169. private _joystickSensibility;
  48170. private _inversedSensibility;
  48171. private _joystickPointerID;
  48172. private _joystickColor;
  48173. private _joystickPointerPos;
  48174. private _joystickPreviousPointerPos;
  48175. private _joystickPointerStartPos;
  48176. private _deltaJoystickVector;
  48177. private _leftJoystick;
  48178. private _touches;
  48179. private _joystickPosition;
  48180. private _alwaysVisible;
  48181. private _puckImage;
  48182. private _containerImage;
  48183. private _joystickPuckSize;
  48184. private _joystickContainerSize;
  48185. private _clearPuckSize;
  48186. private _clearContainerSize;
  48187. private _clearPuckSizeOffset;
  48188. private _clearContainerSizeOffset;
  48189. private _onPointerDownHandlerRef;
  48190. private _onPointerMoveHandlerRef;
  48191. private _onPointerUpHandlerRef;
  48192. private _onResize;
  48193. /**
  48194. * Creates a new virtual joystick
  48195. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48196. * @param customizations Defines the options we want to customize the VirtualJoystick
  48197. */
  48198. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48199. /**
  48200. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48201. * @param newJoystickSensibility defines the new sensibility
  48202. */
  48203. setJoystickSensibility(newJoystickSensibility: number): void;
  48204. private _onPointerDown;
  48205. private _onPointerMove;
  48206. private _onPointerUp;
  48207. /**
  48208. * Change the color of the virtual joystick
  48209. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48210. */
  48211. setJoystickColor(newColor: string): void;
  48212. /**
  48213. * Size of the joystick's container
  48214. */
  48215. set containerSize(newSize: number);
  48216. get containerSize(): number;
  48217. /**
  48218. * Size of the joystick's puck
  48219. */
  48220. set puckSize(newSize: number);
  48221. get puckSize(): number;
  48222. /**
  48223. * Clears the set position of the joystick
  48224. */
  48225. clearPosition(): void;
  48226. /**
  48227. * Defines whether or not the joystick container is always visible
  48228. */
  48229. set alwaysVisible(value: boolean);
  48230. get alwaysVisible(): boolean;
  48231. /**
  48232. * Sets the constant position of the Joystick container
  48233. * @param x X axis coordinate
  48234. * @param y Y axis coordinate
  48235. */
  48236. setPosition(x: number, y: number): void;
  48237. /**
  48238. * Defines a callback to call when the joystick is touched
  48239. * @param action defines the callback
  48240. */
  48241. setActionOnTouch(action: () => any): void;
  48242. /**
  48243. * Defines which axis you'd like to control for left & right
  48244. * @param axis defines the axis to use
  48245. */
  48246. setAxisForLeftRight(axis: JoystickAxis): void;
  48247. /**
  48248. * Defines which axis you'd like to control for up & down
  48249. * @param axis defines the axis to use
  48250. */
  48251. setAxisForUpDown(axis: JoystickAxis): void;
  48252. /**
  48253. * Clears the canvas from the previous puck / container draw
  48254. */
  48255. private _clearPreviousDraw;
  48256. /**
  48257. * Loads `urlPath` to be used for the container's image
  48258. * @param urlPath defines the urlPath of an image to use
  48259. */
  48260. setContainerImage(urlPath: string): void;
  48261. /**
  48262. * Loads `urlPath` to be used for the puck's image
  48263. * @param urlPath defines the urlPath of an image to use
  48264. */
  48265. setPuckImage(urlPath: string): void;
  48266. /**
  48267. * Draws the Virtual Joystick's container
  48268. */
  48269. private _drawContainer;
  48270. /**
  48271. * Draws the Virtual Joystick's puck
  48272. */
  48273. private _drawPuck;
  48274. private _drawVirtualJoystick;
  48275. /**
  48276. * Release internal HTML canvas
  48277. */
  48278. releaseCanvas(): void;
  48279. }
  48280. }
  48281. declare module BABYLON {
  48282. interface FreeCameraInputsManager {
  48283. /**
  48284. * Add virtual joystick input support to the input manager.
  48285. * @returns the current input manager
  48286. */
  48287. addVirtualJoystick(): FreeCameraInputsManager;
  48288. }
  48289. /**
  48290. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48291. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48292. */
  48293. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48294. /**
  48295. * Defines the camera the input is attached to.
  48296. */
  48297. camera: FreeCamera;
  48298. private _leftjoystick;
  48299. private _rightjoystick;
  48300. /**
  48301. * Gets the left stick of the virtual joystick.
  48302. * @returns The virtual Joystick
  48303. */
  48304. getLeftJoystick(): VirtualJoystick;
  48305. /**
  48306. * Gets the right stick of the virtual joystick.
  48307. * @returns The virtual Joystick
  48308. */
  48309. getRightJoystick(): VirtualJoystick;
  48310. /**
  48311. * Update the current camera state depending on the inputs that have been used this frame.
  48312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48313. */
  48314. checkInputs(): void;
  48315. /**
  48316. * Attach the input controls to a specific dom element to get the input from.
  48317. * @param element Defines the element the controls should be listened from
  48318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48319. */
  48320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48321. /**
  48322. * Detach the current controls from the specified dom element.
  48323. * @param element Defines the element to stop listening the inputs from
  48324. */
  48325. detachControl(element: Nullable<HTMLElement>): void;
  48326. /**
  48327. * Gets the class name of the current intput.
  48328. * @returns the class name
  48329. */
  48330. getClassName(): string;
  48331. /**
  48332. * Get the friendly name associated with the input class.
  48333. * @returns the input friendly name
  48334. */
  48335. getSimpleName(): string;
  48336. }
  48337. }
  48338. declare module BABYLON {
  48339. /**
  48340. * This represents a FPS type of camera controlled by touch.
  48341. * This is like a universal camera minus the Gamepad controls.
  48342. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48343. */
  48344. export class TouchCamera extends FreeCamera {
  48345. /**
  48346. * Defines the touch sensibility for rotation.
  48347. * The higher the faster.
  48348. */
  48349. get touchAngularSensibility(): number;
  48350. set touchAngularSensibility(value: number);
  48351. /**
  48352. * Defines the touch sensibility for move.
  48353. * The higher the faster.
  48354. */
  48355. get touchMoveSensibility(): number;
  48356. set touchMoveSensibility(value: number);
  48357. /**
  48358. * Instantiates a new touch camera.
  48359. * This represents a FPS type of camera controlled by touch.
  48360. * This is like a universal camera minus the Gamepad controls.
  48361. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48362. * @param name Define the name of the camera in the scene
  48363. * @param position Define the start position of the camera in the scene
  48364. * @param scene Define the scene the camera belongs to
  48365. */
  48366. constructor(name: string, position: Vector3, scene: Scene);
  48367. /**
  48368. * Gets the current object class name.
  48369. * @return the class name
  48370. */
  48371. getClassName(): string;
  48372. /** @hidden */
  48373. _setupInputs(): void;
  48374. }
  48375. }
  48376. declare module BABYLON {
  48377. /**
  48378. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48379. * being tilted forward or back and left or right.
  48380. */
  48381. export class DeviceOrientationCamera extends FreeCamera {
  48382. private _initialQuaternion;
  48383. private _quaternionCache;
  48384. private _tmpDragQuaternion;
  48385. private _disablePointerInputWhenUsingDeviceOrientation;
  48386. /**
  48387. * Creates a new device orientation camera
  48388. * @param name The name of the camera
  48389. * @param position The start position camera
  48390. * @param scene The scene the camera belongs to
  48391. */
  48392. constructor(name: string, position: Vector3, scene: Scene);
  48393. /**
  48394. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48395. */
  48396. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48397. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48398. private _dragFactor;
  48399. /**
  48400. * Enabled turning on the y axis when the orientation sensor is active
  48401. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48402. */
  48403. enableHorizontalDragging(dragFactor?: number): void;
  48404. /**
  48405. * Gets the current instance class name ("DeviceOrientationCamera").
  48406. * This helps avoiding instanceof at run time.
  48407. * @returns the class name
  48408. */
  48409. getClassName(): string;
  48410. /**
  48411. * @hidden
  48412. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48413. */
  48414. _checkInputs(): void;
  48415. /**
  48416. * Reset the camera to its default orientation on the specified axis only.
  48417. * @param axis The axis to reset
  48418. */
  48419. resetToCurrentRotation(axis?: Axis): void;
  48420. }
  48421. }
  48422. declare module BABYLON {
  48423. /**
  48424. * Defines supported buttons for XBox360 compatible gamepads
  48425. */
  48426. export enum Xbox360Button {
  48427. /** A */
  48428. A = 0,
  48429. /** B */
  48430. B = 1,
  48431. /** X */
  48432. X = 2,
  48433. /** Y */
  48434. Y = 3,
  48435. /** Left button */
  48436. LB = 4,
  48437. /** Right button */
  48438. RB = 5,
  48439. /** Back */
  48440. Back = 8,
  48441. /** Start */
  48442. Start = 9,
  48443. /** Left stick */
  48444. LeftStick = 10,
  48445. /** Right stick */
  48446. RightStick = 11
  48447. }
  48448. /** Defines values for XBox360 DPad */
  48449. export enum Xbox360Dpad {
  48450. /** Up */
  48451. Up = 12,
  48452. /** Down */
  48453. Down = 13,
  48454. /** Left */
  48455. Left = 14,
  48456. /** Right */
  48457. Right = 15
  48458. }
  48459. /**
  48460. * Defines a XBox360 gamepad
  48461. */
  48462. export class Xbox360Pad extends Gamepad {
  48463. private _leftTrigger;
  48464. private _rightTrigger;
  48465. private _onlefttriggerchanged;
  48466. private _onrighttriggerchanged;
  48467. private _onbuttondown;
  48468. private _onbuttonup;
  48469. private _ondpaddown;
  48470. private _ondpadup;
  48471. /** Observable raised when a button is pressed */
  48472. onButtonDownObservable: Observable<Xbox360Button>;
  48473. /** Observable raised when a button is released */
  48474. onButtonUpObservable: Observable<Xbox360Button>;
  48475. /** Observable raised when a pad is pressed */
  48476. onPadDownObservable: Observable<Xbox360Dpad>;
  48477. /** Observable raised when a pad is released */
  48478. onPadUpObservable: Observable<Xbox360Dpad>;
  48479. private _buttonA;
  48480. private _buttonB;
  48481. private _buttonX;
  48482. private _buttonY;
  48483. private _buttonBack;
  48484. private _buttonStart;
  48485. private _buttonLB;
  48486. private _buttonRB;
  48487. private _buttonLeftStick;
  48488. private _buttonRightStick;
  48489. private _dPadUp;
  48490. private _dPadDown;
  48491. private _dPadLeft;
  48492. private _dPadRight;
  48493. private _isXboxOnePad;
  48494. /**
  48495. * Creates a new XBox360 gamepad object
  48496. * @param id defines the id of this gamepad
  48497. * @param index defines its index
  48498. * @param gamepad defines the internal HTML gamepad object
  48499. * @param xboxOne defines if it is a XBox One gamepad
  48500. */
  48501. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48502. /**
  48503. * Defines the callback to call when left trigger is pressed
  48504. * @param callback defines the callback to use
  48505. */
  48506. onlefttriggerchanged(callback: (value: number) => void): void;
  48507. /**
  48508. * Defines the callback to call when right trigger is pressed
  48509. * @param callback defines the callback to use
  48510. */
  48511. onrighttriggerchanged(callback: (value: number) => void): void;
  48512. /**
  48513. * Gets the left trigger value
  48514. */
  48515. get leftTrigger(): number;
  48516. /**
  48517. * Sets the left trigger value
  48518. */
  48519. set leftTrigger(newValue: number);
  48520. /**
  48521. * Gets the right trigger value
  48522. */
  48523. get rightTrigger(): number;
  48524. /**
  48525. * Sets the right trigger value
  48526. */
  48527. set rightTrigger(newValue: number);
  48528. /**
  48529. * Defines the callback to call when a button is pressed
  48530. * @param callback defines the callback to use
  48531. */
  48532. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48533. /**
  48534. * Defines the callback to call when a button is released
  48535. * @param callback defines the callback to use
  48536. */
  48537. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48538. /**
  48539. * Defines the callback to call when a pad is pressed
  48540. * @param callback defines the callback to use
  48541. */
  48542. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48543. /**
  48544. * Defines the callback to call when a pad is released
  48545. * @param callback defines the callback to use
  48546. */
  48547. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48548. private _setButtonValue;
  48549. private _setDPadValue;
  48550. /**
  48551. * Gets the value of the `A` button
  48552. */
  48553. get buttonA(): number;
  48554. /**
  48555. * Sets the value of the `A` button
  48556. */
  48557. set buttonA(value: number);
  48558. /**
  48559. * Gets the value of the `B` button
  48560. */
  48561. get buttonB(): number;
  48562. /**
  48563. * Sets the value of the `B` button
  48564. */
  48565. set buttonB(value: number);
  48566. /**
  48567. * Gets the value of the `X` button
  48568. */
  48569. get buttonX(): number;
  48570. /**
  48571. * Sets the value of the `X` button
  48572. */
  48573. set buttonX(value: number);
  48574. /**
  48575. * Gets the value of the `Y` button
  48576. */
  48577. get buttonY(): number;
  48578. /**
  48579. * Sets the value of the `Y` button
  48580. */
  48581. set buttonY(value: number);
  48582. /**
  48583. * Gets the value of the `Start` button
  48584. */
  48585. get buttonStart(): number;
  48586. /**
  48587. * Sets the value of the `Start` button
  48588. */
  48589. set buttonStart(value: number);
  48590. /**
  48591. * Gets the value of the `Back` button
  48592. */
  48593. get buttonBack(): number;
  48594. /**
  48595. * Sets the value of the `Back` button
  48596. */
  48597. set buttonBack(value: number);
  48598. /**
  48599. * Gets the value of the `Left` button
  48600. */
  48601. get buttonLB(): number;
  48602. /**
  48603. * Sets the value of the `Left` button
  48604. */
  48605. set buttonLB(value: number);
  48606. /**
  48607. * Gets the value of the `Right` button
  48608. */
  48609. get buttonRB(): number;
  48610. /**
  48611. * Sets the value of the `Right` button
  48612. */
  48613. set buttonRB(value: number);
  48614. /**
  48615. * Gets the value of the Left joystick
  48616. */
  48617. get buttonLeftStick(): number;
  48618. /**
  48619. * Sets the value of the Left joystick
  48620. */
  48621. set buttonLeftStick(value: number);
  48622. /**
  48623. * Gets the value of the Right joystick
  48624. */
  48625. get buttonRightStick(): number;
  48626. /**
  48627. * Sets the value of the Right joystick
  48628. */
  48629. set buttonRightStick(value: number);
  48630. /**
  48631. * Gets the value of D-pad up
  48632. */
  48633. get dPadUp(): number;
  48634. /**
  48635. * Sets the value of D-pad up
  48636. */
  48637. set dPadUp(value: number);
  48638. /**
  48639. * Gets the value of D-pad down
  48640. */
  48641. get dPadDown(): number;
  48642. /**
  48643. * Sets the value of D-pad down
  48644. */
  48645. set dPadDown(value: number);
  48646. /**
  48647. * Gets the value of D-pad left
  48648. */
  48649. get dPadLeft(): number;
  48650. /**
  48651. * Sets the value of D-pad left
  48652. */
  48653. set dPadLeft(value: number);
  48654. /**
  48655. * Gets the value of D-pad right
  48656. */
  48657. get dPadRight(): number;
  48658. /**
  48659. * Sets the value of D-pad right
  48660. */
  48661. set dPadRight(value: number);
  48662. /**
  48663. * Force the gamepad to synchronize with device values
  48664. */
  48665. update(): void;
  48666. /**
  48667. * Disposes the gamepad
  48668. */
  48669. dispose(): void;
  48670. }
  48671. }
  48672. declare module BABYLON {
  48673. /**
  48674. * Defines supported buttons for DualShock compatible gamepads
  48675. */
  48676. export enum DualShockButton {
  48677. /** Cross */
  48678. Cross = 0,
  48679. /** Circle */
  48680. Circle = 1,
  48681. /** Square */
  48682. Square = 2,
  48683. /** Triangle */
  48684. Triangle = 3,
  48685. /** L1 */
  48686. L1 = 4,
  48687. /** R1 */
  48688. R1 = 5,
  48689. /** Share */
  48690. Share = 8,
  48691. /** Options */
  48692. Options = 9,
  48693. /** Left stick */
  48694. LeftStick = 10,
  48695. /** Right stick */
  48696. RightStick = 11
  48697. }
  48698. /** Defines values for DualShock DPad */
  48699. export enum DualShockDpad {
  48700. /** Up */
  48701. Up = 12,
  48702. /** Down */
  48703. Down = 13,
  48704. /** Left */
  48705. Left = 14,
  48706. /** Right */
  48707. Right = 15
  48708. }
  48709. /**
  48710. * Defines a DualShock gamepad
  48711. */
  48712. export class DualShockPad extends Gamepad {
  48713. private _leftTrigger;
  48714. private _rightTrigger;
  48715. private _onlefttriggerchanged;
  48716. private _onrighttriggerchanged;
  48717. private _onbuttondown;
  48718. private _onbuttonup;
  48719. private _ondpaddown;
  48720. private _ondpadup;
  48721. /** Observable raised when a button is pressed */
  48722. onButtonDownObservable: Observable<DualShockButton>;
  48723. /** Observable raised when a button is released */
  48724. onButtonUpObservable: Observable<DualShockButton>;
  48725. /** Observable raised when a pad is pressed */
  48726. onPadDownObservable: Observable<DualShockDpad>;
  48727. /** Observable raised when a pad is released */
  48728. onPadUpObservable: Observable<DualShockDpad>;
  48729. private _buttonCross;
  48730. private _buttonCircle;
  48731. private _buttonSquare;
  48732. private _buttonTriangle;
  48733. private _buttonShare;
  48734. private _buttonOptions;
  48735. private _buttonL1;
  48736. private _buttonR1;
  48737. private _buttonLeftStick;
  48738. private _buttonRightStick;
  48739. private _dPadUp;
  48740. private _dPadDown;
  48741. private _dPadLeft;
  48742. private _dPadRight;
  48743. /**
  48744. * Creates a new DualShock gamepad object
  48745. * @param id defines the id of this gamepad
  48746. * @param index defines its index
  48747. * @param gamepad defines the internal HTML gamepad object
  48748. */
  48749. constructor(id: string, index: number, gamepad: any);
  48750. /**
  48751. * Defines the callback to call when left trigger is pressed
  48752. * @param callback defines the callback to use
  48753. */
  48754. onlefttriggerchanged(callback: (value: number) => void): void;
  48755. /**
  48756. * Defines the callback to call when right trigger is pressed
  48757. * @param callback defines the callback to use
  48758. */
  48759. onrighttriggerchanged(callback: (value: number) => void): void;
  48760. /**
  48761. * Gets the left trigger value
  48762. */
  48763. get leftTrigger(): number;
  48764. /**
  48765. * Sets the left trigger value
  48766. */
  48767. set leftTrigger(newValue: number);
  48768. /**
  48769. * Gets the right trigger value
  48770. */
  48771. get rightTrigger(): number;
  48772. /**
  48773. * Sets the right trigger value
  48774. */
  48775. set rightTrigger(newValue: number);
  48776. /**
  48777. * Defines the callback to call when a button is pressed
  48778. * @param callback defines the callback to use
  48779. */
  48780. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  48781. /**
  48782. * Defines the callback to call when a button is released
  48783. * @param callback defines the callback to use
  48784. */
  48785. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  48786. /**
  48787. * Defines the callback to call when a pad is pressed
  48788. * @param callback defines the callback to use
  48789. */
  48790. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  48791. /**
  48792. * Defines the callback to call when a pad is released
  48793. * @param callback defines the callback to use
  48794. */
  48795. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  48796. private _setButtonValue;
  48797. private _setDPadValue;
  48798. /**
  48799. * Gets the value of the `Cross` button
  48800. */
  48801. get buttonCross(): number;
  48802. /**
  48803. * Sets the value of the `Cross` button
  48804. */
  48805. set buttonCross(value: number);
  48806. /**
  48807. * Gets the value of the `Circle` button
  48808. */
  48809. get buttonCircle(): number;
  48810. /**
  48811. * Sets the value of the `Circle` button
  48812. */
  48813. set buttonCircle(value: number);
  48814. /**
  48815. * Gets the value of the `Square` button
  48816. */
  48817. get buttonSquare(): number;
  48818. /**
  48819. * Sets the value of the `Square` button
  48820. */
  48821. set buttonSquare(value: number);
  48822. /**
  48823. * Gets the value of the `Triangle` button
  48824. */
  48825. get buttonTriangle(): number;
  48826. /**
  48827. * Sets the value of the `Triangle` button
  48828. */
  48829. set buttonTriangle(value: number);
  48830. /**
  48831. * Gets the value of the `Options` button
  48832. */
  48833. get buttonOptions(): number;
  48834. /**
  48835. * Sets the value of the `Options` button
  48836. */
  48837. set buttonOptions(value: number);
  48838. /**
  48839. * Gets the value of the `Share` button
  48840. */
  48841. get buttonShare(): number;
  48842. /**
  48843. * Sets the value of the `Share` button
  48844. */
  48845. set buttonShare(value: number);
  48846. /**
  48847. * Gets the value of the `L1` button
  48848. */
  48849. get buttonL1(): number;
  48850. /**
  48851. * Sets the value of the `L1` button
  48852. */
  48853. set buttonL1(value: number);
  48854. /**
  48855. * Gets the value of the `R1` button
  48856. */
  48857. get buttonR1(): number;
  48858. /**
  48859. * Sets the value of the `R1` button
  48860. */
  48861. set buttonR1(value: number);
  48862. /**
  48863. * Gets the value of the Left joystick
  48864. */
  48865. get buttonLeftStick(): number;
  48866. /**
  48867. * Sets the value of the Left joystick
  48868. */
  48869. set buttonLeftStick(value: number);
  48870. /**
  48871. * Gets the value of the Right joystick
  48872. */
  48873. get buttonRightStick(): number;
  48874. /**
  48875. * Sets the value of the Right joystick
  48876. */
  48877. set buttonRightStick(value: number);
  48878. /**
  48879. * Gets the value of D-pad up
  48880. */
  48881. get dPadUp(): number;
  48882. /**
  48883. * Sets the value of D-pad up
  48884. */
  48885. set dPadUp(value: number);
  48886. /**
  48887. * Gets the value of D-pad down
  48888. */
  48889. get dPadDown(): number;
  48890. /**
  48891. * Sets the value of D-pad down
  48892. */
  48893. set dPadDown(value: number);
  48894. /**
  48895. * Gets the value of D-pad left
  48896. */
  48897. get dPadLeft(): number;
  48898. /**
  48899. * Sets the value of D-pad left
  48900. */
  48901. set dPadLeft(value: number);
  48902. /**
  48903. * Gets the value of D-pad right
  48904. */
  48905. get dPadRight(): number;
  48906. /**
  48907. * Sets the value of D-pad right
  48908. */
  48909. set dPadRight(value: number);
  48910. /**
  48911. * Force the gamepad to synchronize with device values
  48912. */
  48913. update(): void;
  48914. /**
  48915. * Disposes the gamepad
  48916. */
  48917. dispose(): void;
  48918. }
  48919. }
  48920. declare module BABYLON {
  48921. /**
  48922. * Manager for handling gamepads
  48923. */
  48924. export class GamepadManager {
  48925. private _scene?;
  48926. private _babylonGamepads;
  48927. private _oneGamepadConnected;
  48928. /** @hidden */
  48929. _isMonitoring: boolean;
  48930. private _gamepadEventSupported;
  48931. private _gamepadSupport?;
  48932. /**
  48933. * observable to be triggered when the gamepad controller has been connected
  48934. */
  48935. onGamepadConnectedObservable: Observable<Gamepad>;
  48936. /**
  48937. * observable to be triggered when the gamepad controller has been disconnected
  48938. */
  48939. onGamepadDisconnectedObservable: Observable<Gamepad>;
  48940. private _onGamepadConnectedEvent;
  48941. private _onGamepadDisconnectedEvent;
  48942. /**
  48943. * Initializes the gamepad manager
  48944. * @param _scene BabylonJS scene
  48945. */
  48946. constructor(_scene?: Scene | undefined);
  48947. /**
  48948. * The gamepads in the game pad manager
  48949. */
  48950. get gamepads(): Gamepad[];
  48951. /**
  48952. * Get the gamepad controllers based on type
  48953. * @param type The type of gamepad controller
  48954. * @returns Nullable gamepad
  48955. */
  48956. getGamepadByType(type?: number): Nullable<Gamepad>;
  48957. /**
  48958. * Disposes the gamepad manager
  48959. */
  48960. dispose(): void;
  48961. private _addNewGamepad;
  48962. private _startMonitoringGamepads;
  48963. private _stopMonitoringGamepads;
  48964. /** @hidden */
  48965. _checkGamepadsStatus(): void;
  48966. private _updateGamepadObjects;
  48967. }
  48968. }
  48969. declare module BABYLON {
  48970. interface Scene {
  48971. /** @hidden */
  48972. _gamepadManager: Nullable<GamepadManager>;
  48973. /**
  48974. * Gets the gamepad manager associated with the scene
  48975. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  48976. */
  48977. gamepadManager: GamepadManager;
  48978. }
  48979. /**
  48980. * Interface representing a free camera inputs manager
  48981. */
  48982. interface FreeCameraInputsManager {
  48983. /**
  48984. * Adds gamepad input support to the FreeCameraInputsManager.
  48985. * @returns the FreeCameraInputsManager
  48986. */
  48987. addGamepad(): FreeCameraInputsManager;
  48988. }
  48989. /**
  48990. * Interface representing an arc rotate camera inputs manager
  48991. */
  48992. interface ArcRotateCameraInputsManager {
  48993. /**
  48994. * Adds gamepad input support to the ArcRotateCamera InputManager.
  48995. * @returns the camera inputs manager
  48996. */
  48997. addGamepad(): ArcRotateCameraInputsManager;
  48998. }
  48999. /**
  49000. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49001. */
  49002. export class GamepadSystemSceneComponent implements ISceneComponent {
  49003. /**
  49004. * The component name helpfull to identify the component in the list of scene components.
  49005. */
  49006. readonly name: string;
  49007. /**
  49008. * The scene the component belongs to.
  49009. */
  49010. scene: Scene;
  49011. /**
  49012. * Creates a new instance of the component for the given scene
  49013. * @param scene Defines the scene to register the component in
  49014. */
  49015. constructor(scene: Scene);
  49016. /**
  49017. * Registers the component in a given scene
  49018. */
  49019. register(): void;
  49020. /**
  49021. * Rebuilds the elements related to this component in case of
  49022. * context lost for instance.
  49023. */
  49024. rebuild(): void;
  49025. /**
  49026. * Disposes the component and the associated ressources
  49027. */
  49028. dispose(): void;
  49029. private _beforeCameraUpdate;
  49030. }
  49031. }
  49032. declare module BABYLON {
  49033. /**
  49034. * 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,
  49035. * which still works and will still be found in many Playgrounds.
  49036. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49037. */
  49038. export class UniversalCamera extends TouchCamera {
  49039. /**
  49040. * Defines the gamepad rotation sensiblity.
  49041. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49042. */
  49043. get gamepadAngularSensibility(): number;
  49044. set gamepadAngularSensibility(value: number);
  49045. /**
  49046. * Defines the gamepad move sensiblity.
  49047. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49048. */
  49049. get gamepadMoveSensibility(): number;
  49050. set gamepadMoveSensibility(value: number);
  49051. /**
  49052. * 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,
  49053. * which still works and will still be found in many Playgrounds.
  49054. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49055. * @param name Define the name of the camera in the scene
  49056. * @param position Define the start position of the camera in the scene
  49057. * @param scene Define the scene the camera belongs to
  49058. */
  49059. constructor(name: string, position: Vector3, scene: Scene);
  49060. /**
  49061. * Gets the current object class name.
  49062. * @return the class name
  49063. */
  49064. getClassName(): string;
  49065. }
  49066. }
  49067. declare module BABYLON {
  49068. /**
  49069. * This represents a FPS type of camera. This is only here for back compat purpose.
  49070. * Please use the UniversalCamera instead as both are identical.
  49071. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49072. */
  49073. export class GamepadCamera extends UniversalCamera {
  49074. /**
  49075. * Instantiates a new Gamepad Camera
  49076. * This represents a FPS type of camera. This is only here for back compat purpose.
  49077. * Please use the UniversalCamera instead as both are identical.
  49078. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49079. * @param name Define the name of the camera in the scene
  49080. * @param position Define the start position of the camera in the scene
  49081. * @param scene Define the scene the camera belongs to
  49082. */
  49083. constructor(name: string, position: Vector3, scene: Scene);
  49084. /**
  49085. * Gets the current object class name.
  49086. * @return the class name
  49087. */
  49088. getClassName(): string;
  49089. }
  49090. }
  49091. declare module BABYLON {
  49092. /** @hidden */
  49093. export var passPixelShader: {
  49094. name: string;
  49095. shader: string;
  49096. };
  49097. }
  49098. declare module BABYLON {
  49099. /** @hidden */
  49100. export var passCubePixelShader: {
  49101. name: string;
  49102. shader: string;
  49103. };
  49104. }
  49105. declare module BABYLON {
  49106. /**
  49107. * PassPostProcess which produces an output the same as it's input
  49108. */
  49109. export class PassPostProcess extends PostProcess {
  49110. /**
  49111. * Gets a string identifying the name of the class
  49112. * @returns "PassPostProcess" string
  49113. */
  49114. getClassName(): string;
  49115. /**
  49116. * Creates the PassPostProcess
  49117. * @param name The name of the effect.
  49118. * @param options The required width/height ratio to downsize to before computing the render pass.
  49119. * @param camera The camera to apply the render pass to.
  49120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49121. * @param engine The engine which the post process will be applied. (default: current engine)
  49122. * @param reusable If the post process can be reused on the same frame. (default: false)
  49123. * @param textureType The type of texture to be used when performing the post processing.
  49124. * @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)
  49125. */
  49126. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49127. /** @hidden */
  49128. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49129. }
  49130. /**
  49131. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49132. */
  49133. export class PassCubePostProcess extends PostProcess {
  49134. private _face;
  49135. /**
  49136. * Gets or sets the cube face to display.
  49137. * * 0 is +X
  49138. * * 1 is -X
  49139. * * 2 is +Y
  49140. * * 3 is -Y
  49141. * * 4 is +Z
  49142. * * 5 is -Z
  49143. */
  49144. get face(): number;
  49145. set face(value: number);
  49146. /**
  49147. * Gets a string identifying the name of the class
  49148. * @returns "PassCubePostProcess" string
  49149. */
  49150. getClassName(): string;
  49151. /**
  49152. * Creates the PassCubePostProcess
  49153. * @param name The name of the effect.
  49154. * @param options The required width/height ratio to downsize to before computing the render pass.
  49155. * @param camera The camera to apply the render pass to.
  49156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49157. * @param engine The engine which the post process will be applied. (default: current engine)
  49158. * @param reusable If the post process can be reused on the same frame. (default: false)
  49159. * @param textureType The type of texture to be used when performing the post processing.
  49160. * @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)
  49161. */
  49162. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49163. /** @hidden */
  49164. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49165. }
  49166. }
  49167. declare module BABYLON {
  49168. /** @hidden */
  49169. export var anaglyphPixelShader: {
  49170. name: string;
  49171. shader: string;
  49172. };
  49173. }
  49174. declare module BABYLON {
  49175. /**
  49176. * Postprocess used to generate anaglyphic rendering
  49177. */
  49178. export class AnaglyphPostProcess extends PostProcess {
  49179. private _passedProcess;
  49180. /**
  49181. * Gets a string identifying the name of the class
  49182. * @returns "AnaglyphPostProcess" string
  49183. */
  49184. getClassName(): string;
  49185. /**
  49186. * Creates a new AnaglyphPostProcess
  49187. * @param name defines postprocess name
  49188. * @param options defines creation options or target ratio scale
  49189. * @param rigCameras defines cameras using this postprocess
  49190. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49191. * @param engine defines hosting engine
  49192. * @param reusable defines if the postprocess will be reused multiple times per frame
  49193. */
  49194. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49195. }
  49196. }
  49197. declare module BABYLON {
  49198. /**
  49199. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49200. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49201. */
  49202. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49203. /**
  49204. * Creates a new AnaglyphArcRotateCamera
  49205. * @param name defines camera name
  49206. * @param alpha defines alpha angle (in radians)
  49207. * @param beta defines beta angle (in radians)
  49208. * @param radius defines radius
  49209. * @param target defines camera target
  49210. * @param interaxialDistance defines distance between each color axis
  49211. * @param scene defines the hosting scene
  49212. */
  49213. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49214. /**
  49215. * Gets camera class name
  49216. * @returns AnaglyphArcRotateCamera
  49217. */
  49218. getClassName(): string;
  49219. }
  49220. }
  49221. declare module BABYLON {
  49222. /**
  49223. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49224. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49225. */
  49226. export class AnaglyphFreeCamera extends FreeCamera {
  49227. /**
  49228. * Creates a new AnaglyphFreeCamera
  49229. * @param name defines camera name
  49230. * @param position defines initial position
  49231. * @param interaxialDistance defines distance between each color axis
  49232. * @param scene defines the hosting scene
  49233. */
  49234. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49235. /**
  49236. * Gets camera class name
  49237. * @returns AnaglyphFreeCamera
  49238. */
  49239. getClassName(): string;
  49240. }
  49241. }
  49242. declare module BABYLON {
  49243. /**
  49244. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49245. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49246. */
  49247. export class AnaglyphGamepadCamera extends GamepadCamera {
  49248. /**
  49249. * Creates a new AnaglyphGamepadCamera
  49250. * @param name defines camera name
  49251. * @param position defines initial position
  49252. * @param interaxialDistance defines distance between each color axis
  49253. * @param scene defines the hosting scene
  49254. */
  49255. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49256. /**
  49257. * Gets camera class name
  49258. * @returns AnaglyphGamepadCamera
  49259. */
  49260. getClassName(): string;
  49261. }
  49262. }
  49263. declare module BABYLON {
  49264. /**
  49265. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49266. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49267. */
  49268. export class AnaglyphUniversalCamera extends UniversalCamera {
  49269. /**
  49270. * Creates a new AnaglyphUniversalCamera
  49271. * @param name defines camera name
  49272. * @param position defines initial position
  49273. * @param interaxialDistance defines distance between each color axis
  49274. * @param scene defines the hosting scene
  49275. */
  49276. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49277. /**
  49278. * Gets camera class name
  49279. * @returns AnaglyphUniversalCamera
  49280. */
  49281. getClassName(): string;
  49282. }
  49283. }
  49284. declare module BABYLON {
  49285. /**
  49286. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49287. * @see https://doc.babylonjs.com/features/cameras
  49288. */
  49289. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49290. /**
  49291. * Creates a new StereoscopicArcRotateCamera
  49292. * @param name defines camera name
  49293. * @param alpha defines alpha angle (in radians)
  49294. * @param beta defines beta angle (in radians)
  49295. * @param radius defines radius
  49296. * @param target defines camera target
  49297. * @param interaxialDistance defines distance between each color axis
  49298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49299. * @param scene defines the hosting scene
  49300. */
  49301. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49302. /**
  49303. * Gets camera class name
  49304. * @returns StereoscopicArcRotateCamera
  49305. */
  49306. getClassName(): string;
  49307. }
  49308. }
  49309. declare module BABYLON {
  49310. /**
  49311. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49312. * @see https://doc.babylonjs.com/features/cameras
  49313. */
  49314. export class StereoscopicFreeCamera extends FreeCamera {
  49315. /**
  49316. * Creates a new StereoscopicFreeCamera
  49317. * @param name defines camera name
  49318. * @param position defines initial position
  49319. * @param interaxialDistance defines distance between each color axis
  49320. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49321. * @param scene defines the hosting scene
  49322. */
  49323. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49324. /**
  49325. * Gets camera class name
  49326. * @returns StereoscopicFreeCamera
  49327. */
  49328. getClassName(): string;
  49329. }
  49330. }
  49331. declare module BABYLON {
  49332. /**
  49333. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49334. * @see https://doc.babylonjs.com/features/cameras
  49335. */
  49336. export class StereoscopicGamepadCamera extends GamepadCamera {
  49337. /**
  49338. * Creates a new StereoscopicGamepadCamera
  49339. * @param name defines camera name
  49340. * @param position defines initial position
  49341. * @param interaxialDistance defines distance between each color axis
  49342. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49343. * @param scene defines the hosting scene
  49344. */
  49345. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49346. /**
  49347. * Gets camera class name
  49348. * @returns StereoscopicGamepadCamera
  49349. */
  49350. getClassName(): string;
  49351. }
  49352. }
  49353. declare module BABYLON {
  49354. /**
  49355. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49356. * @see https://doc.babylonjs.com/features/cameras
  49357. */
  49358. export class StereoscopicUniversalCamera extends UniversalCamera {
  49359. /**
  49360. * Creates a new StereoscopicUniversalCamera
  49361. * @param name defines camera name
  49362. * @param position defines initial position
  49363. * @param interaxialDistance defines distance between each color axis
  49364. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49365. * @param scene defines the hosting scene
  49366. */
  49367. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49368. /**
  49369. * Gets camera class name
  49370. * @returns StereoscopicUniversalCamera
  49371. */
  49372. getClassName(): string;
  49373. }
  49374. }
  49375. declare module BABYLON {
  49376. /**
  49377. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49378. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49379. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49380. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49381. */
  49382. export class VirtualJoysticksCamera extends FreeCamera {
  49383. /**
  49384. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49385. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49386. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49387. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49388. * @param name Define the name of the camera in the scene
  49389. * @param position Define the start position of the camera in the scene
  49390. * @param scene Define the scene the camera belongs to
  49391. */
  49392. constructor(name: string, position: Vector3, scene: Scene);
  49393. /**
  49394. * Gets the current object class name.
  49395. * @return the class name
  49396. */
  49397. getClassName(): string;
  49398. }
  49399. }
  49400. declare module BABYLON {
  49401. /**
  49402. * This represents all the required metrics to create a VR camera.
  49403. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49404. */
  49405. export class VRCameraMetrics {
  49406. /**
  49407. * Define the horizontal resolution off the screen.
  49408. */
  49409. hResolution: number;
  49410. /**
  49411. * Define the vertical resolution off the screen.
  49412. */
  49413. vResolution: number;
  49414. /**
  49415. * Define the horizontal screen size.
  49416. */
  49417. hScreenSize: number;
  49418. /**
  49419. * Define the vertical screen size.
  49420. */
  49421. vScreenSize: number;
  49422. /**
  49423. * Define the vertical screen center position.
  49424. */
  49425. vScreenCenter: number;
  49426. /**
  49427. * Define the distance of the eyes to the screen.
  49428. */
  49429. eyeToScreenDistance: number;
  49430. /**
  49431. * Define the distance between both lenses
  49432. */
  49433. lensSeparationDistance: number;
  49434. /**
  49435. * Define the distance between both viewer's eyes.
  49436. */
  49437. interpupillaryDistance: number;
  49438. /**
  49439. * Define the distortion factor of the VR postprocess.
  49440. * Please, touch with care.
  49441. */
  49442. distortionK: number[];
  49443. /**
  49444. * Define the chromatic aberration correction factors for the VR post process.
  49445. */
  49446. chromaAbCorrection: number[];
  49447. /**
  49448. * Define the scale factor of the post process.
  49449. * The smaller the better but the slower.
  49450. */
  49451. postProcessScaleFactor: number;
  49452. /**
  49453. * Define an offset for the lens center.
  49454. */
  49455. lensCenterOffset: number;
  49456. /**
  49457. * Define if the current vr camera should compensate the distortion of the lense or not.
  49458. */
  49459. compensateDistortion: boolean;
  49460. /**
  49461. * Defines if multiview should be enabled when rendering (Default: false)
  49462. */
  49463. multiviewEnabled: boolean;
  49464. /**
  49465. * Gets the rendering aspect ratio based on the provided resolutions.
  49466. */
  49467. get aspectRatio(): number;
  49468. /**
  49469. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49470. */
  49471. get aspectRatioFov(): number;
  49472. /**
  49473. * @hidden
  49474. */
  49475. get leftHMatrix(): Matrix;
  49476. /**
  49477. * @hidden
  49478. */
  49479. get rightHMatrix(): Matrix;
  49480. /**
  49481. * @hidden
  49482. */
  49483. get leftPreViewMatrix(): Matrix;
  49484. /**
  49485. * @hidden
  49486. */
  49487. get rightPreViewMatrix(): Matrix;
  49488. /**
  49489. * Get the default VRMetrics based on the most generic setup.
  49490. * @returns the default vr metrics
  49491. */
  49492. static GetDefault(): VRCameraMetrics;
  49493. }
  49494. }
  49495. declare module BABYLON {
  49496. /** @hidden */
  49497. export var vrDistortionCorrectionPixelShader: {
  49498. name: string;
  49499. shader: string;
  49500. };
  49501. }
  49502. declare module BABYLON {
  49503. /**
  49504. * VRDistortionCorrectionPostProcess used for mobile VR
  49505. */
  49506. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49507. private _isRightEye;
  49508. private _distortionFactors;
  49509. private _postProcessScaleFactor;
  49510. private _lensCenterOffset;
  49511. private _scaleIn;
  49512. private _scaleFactor;
  49513. private _lensCenter;
  49514. /**
  49515. * Gets a string identifying the name of the class
  49516. * @returns "VRDistortionCorrectionPostProcess" string
  49517. */
  49518. getClassName(): string;
  49519. /**
  49520. * Initializes the VRDistortionCorrectionPostProcess
  49521. * @param name The name of the effect.
  49522. * @param camera The camera to apply the render pass to.
  49523. * @param isRightEye If this is for the right eye distortion
  49524. * @param vrMetrics All the required metrics for the VR camera
  49525. */
  49526. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49527. }
  49528. }
  49529. declare module BABYLON {
  49530. /**
  49531. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49532. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49533. */
  49534. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49535. /**
  49536. * Creates a new VRDeviceOrientationArcRotateCamera
  49537. * @param name defines camera name
  49538. * @param alpha defines the camera rotation along the logitudinal axis
  49539. * @param beta defines the camera rotation along the latitudinal axis
  49540. * @param radius defines the camera distance from its target
  49541. * @param target defines the camera target
  49542. * @param scene defines the scene the camera belongs to
  49543. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49544. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49545. */
  49546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49547. /**
  49548. * Gets camera class name
  49549. * @returns VRDeviceOrientationArcRotateCamera
  49550. */
  49551. getClassName(): string;
  49552. }
  49553. }
  49554. declare module BABYLON {
  49555. /**
  49556. * Camera used to simulate VR rendering (based on FreeCamera)
  49557. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49558. */
  49559. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49560. /**
  49561. * Creates a new VRDeviceOrientationFreeCamera
  49562. * @param name defines camera name
  49563. * @param position defines the start position of the camera
  49564. * @param scene defines the scene the camera belongs to
  49565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49567. */
  49568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49569. /**
  49570. * Gets camera class name
  49571. * @returns VRDeviceOrientationFreeCamera
  49572. */
  49573. getClassName(): string;
  49574. }
  49575. }
  49576. declare module BABYLON {
  49577. /**
  49578. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49579. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49580. */
  49581. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49582. /**
  49583. * Creates a new VRDeviceOrientationGamepadCamera
  49584. * @param name defines camera name
  49585. * @param position defines the start position of the camera
  49586. * @param scene defines the scene the camera belongs to
  49587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49589. */
  49590. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49591. /**
  49592. * Gets camera class name
  49593. * @returns VRDeviceOrientationGamepadCamera
  49594. */
  49595. getClassName(): string;
  49596. }
  49597. }
  49598. declare module BABYLON {
  49599. /**
  49600. * A class extending Texture allowing drawing on a texture
  49601. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49602. */
  49603. export class DynamicTexture extends Texture {
  49604. private _generateMipMaps;
  49605. private _canvas;
  49606. private _context;
  49607. /**
  49608. * Creates a DynamicTexture
  49609. * @param name defines the name of the texture
  49610. * @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
  49611. * @param scene defines the scene where you want the texture
  49612. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49613. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49614. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49615. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49616. */
  49617. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49618. /**
  49619. * Get the current class name of the texture useful for serialization or dynamic coding.
  49620. * @returns "DynamicTexture"
  49621. */
  49622. getClassName(): string;
  49623. /**
  49624. * Gets the current state of canRescale
  49625. */
  49626. get canRescale(): boolean;
  49627. private _recreate;
  49628. /**
  49629. * Scales the texture
  49630. * @param ratio the scale factor to apply to both width and height
  49631. */
  49632. scale(ratio: number): void;
  49633. /**
  49634. * Resizes the texture
  49635. * @param width the new width
  49636. * @param height the new height
  49637. */
  49638. scaleTo(width: number, height: number): void;
  49639. /**
  49640. * Gets the context of the canvas used by the texture
  49641. * @returns the canvas context of the dynamic texture
  49642. */
  49643. getContext(): CanvasRenderingContext2D;
  49644. /**
  49645. * Clears the texture
  49646. */
  49647. clear(): void;
  49648. /**
  49649. * Updates the texture
  49650. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49651. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49652. */
  49653. update(invertY?: boolean, premulAlpha?: boolean): void;
  49654. /**
  49655. * Draws text onto the texture
  49656. * @param text defines the text to be drawn
  49657. * @param x defines the placement of the text from the left
  49658. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49659. * @param font defines the font to be used with font-style, font-size, font-name
  49660. * @param color defines the color used for the text
  49661. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49662. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49663. * @param update defines whether texture is immediately update (default is true)
  49664. */
  49665. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49666. /**
  49667. * Clones the texture
  49668. * @returns the clone of the texture.
  49669. */
  49670. clone(): DynamicTexture;
  49671. /**
  49672. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49673. * @returns a serialized dynamic texture object
  49674. */
  49675. serialize(): any;
  49676. private _IsCanvasElement;
  49677. /** @hidden */
  49678. _rebuild(): void;
  49679. }
  49680. }
  49681. declare module BABYLON {
  49682. /**
  49683. * Class containing static functions to help procedurally build meshes
  49684. */
  49685. export class GroundBuilder {
  49686. /**
  49687. * Creates a ground mesh
  49688. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49689. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49691. * @param name defines the name of the mesh
  49692. * @param options defines the options used to create the mesh
  49693. * @param scene defines the hosting scene
  49694. * @returns the ground mesh
  49695. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49696. */
  49697. static CreateGround(name: string, options: {
  49698. width?: number;
  49699. height?: number;
  49700. subdivisions?: number;
  49701. subdivisionsX?: number;
  49702. subdivisionsY?: number;
  49703. updatable?: boolean;
  49704. }, scene: any): Mesh;
  49705. /**
  49706. * Creates a tiled ground mesh
  49707. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49708. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49709. * * 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
  49710. * * 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
  49711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49712. * @param name defines the name of the mesh
  49713. * @param options defines the options used to create the mesh
  49714. * @param scene defines the hosting scene
  49715. * @returns the tiled ground mesh
  49716. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49717. */
  49718. static CreateTiledGround(name: string, options: {
  49719. xmin: number;
  49720. zmin: number;
  49721. xmax: number;
  49722. zmax: number;
  49723. subdivisions?: {
  49724. w: number;
  49725. h: number;
  49726. };
  49727. precision?: {
  49728. w: number;
  49729. h: number;
  49730. };
  49731. updatable?: boolean;
  49732. }, scene?: Nullable<Scene>): Mesh;
  49733. /**
  49734. * Creates a ground mesh from a height map
  49735. * * The parameter `url` sets the URL of the height map image resource.
  49736. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49737. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49738. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49739. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49740. * * 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.
  49741. * * 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).
  49742. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49744. * @param name defines the name of the mesh
  49745. * @param url defines the url to the height map
  49746. * @param options defines the options used to create the mesh
  49747. * @param scene defines the hosting scene
  49748. * @returns the ground mesh
  49749. * @see https://doc.babylonjs.com/babylon101/height_map
  49750. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49751. */
  49752. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49753. width?: number;
  49754. height?: number;
  49755. subdivisions?: number;
  49756. minHeight?: number;
  49757. maxHeight?: number;
  49758. colorFilter?: Color3;
  49759. alphaFilter?: number;
  49760. updatable?: boolean;
  49761. onReady?: (mesh: GroundMesh) => void;
  49762. }, scene?: Nullable<Scene>): GroundMesh;
  49763. }
  49764. }
  49765. declare module BABYLON {
  49766. /**
  49767. * Class containing static functions to help procedurally build meshes
  49768. */
  49769. export class TorusBuilder {
  49770. /**
  49771. * Creates a torus mesh
  49772. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49773. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49774. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49776. * * 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
  49777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49778. * @param name defines the name of the mesh
  49779. * @param options defines the options used to create the mesh
  49780. * @param scene defines the hosting scene
  49781. * @returns the torus mesh
  49782. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49783. */
  49784. static CreateTorus(name: string, options: {
  49785. diameter?: number;
  49786. thickness?: number;
  49787. tessellation?: number;
  49788. updatable?: boolean;
  49789. sideOrientation?: number;
  49790. frontUVs?: Vector4;
  49791. backUVs?: Vector4;
  49792. }, scene: any): Mesh;
  49793. }
  49794. }
  49795. declare module BABYLON {
  49796. /**
  49797. * Class containing static functions to help procedurally build meshes
  49798. */
  49799. export class CylinderBuilder {
  49800. /**
  49801. * Creates a cylinder or a cone mesh
  49802. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49803. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49804. * * 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.
  49805. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49806. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49807. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49808. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49809. * * 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).
  49810. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49811. * * 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).
  49812. * * 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
  49813. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49814. * * 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
  49815. * * 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.
  49816. * * If `enclose` is false, a ring surface is one element.
  49817. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49818. * * 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
  49819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49820. * * 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
  49821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49822. * @param name defines the name of the mesh
  49823. * @param options defines the options used to create the mesh
  49824. * @param scene defines the hosting scene
  49825. * @returns the cylinder mesh
  49826. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49827. */
  49828. static CreateCylinder(name: string, options: {
  49829. height?: number;
  49830. diameterTop?: number;
  49831. diameterBottom?: number;
  49832. diameter?: number;
  49833. tessellation?: number;
  49834. subdivisions?: number;
  49835. arc?: number;
  49836. faceColors?: Color4[];
  49837. faceUV?: Vector4[];
  49838. updatable?: boolean;
  49839. hasRings?: boolean;
  49840. enclose?: boolean;
  49841. cap?: number;
  49842. sideOrientation?: number;
  49843. frontUVs?: Vector4;
  49844. backUVs?: Vector4;
  49845. }, scene: any): Mesh;
  49846. }
  49847. }
  49848. declare module BABYLON {
  49849. /**
  49850. * States of the webXR experience
  49851. */
  49852. export enum WebXRState {
  49853. /**
  49854. * Transitioning to being in XR mode
  49855. */
  49856. ENTERING_XR = 0,
  49857. /**
  49858. * Transitioning to non XR mode
  49859. */
  49860. EXITING_XR = 1,
  49861. /**
  49862. * In XR mode and presenting
  49863. */
  49864. IN_XR = 2,
  49865. /**
  49866. * Not entered XR mode
  49867. */
  49868. NOT_IN_XR = 3
  49869. }
  49870. /**
  49871. * The state of the XR camera's tracking
  49872. */
  49873. export enum WebXRTrackingState {
  49874. /**
  49875. * No transformation received, device is not being tracked
  49876. */
  49877. NOT_TRACKING = 0,
  49878. /**
  49879. * Tracking lost - using emulated position
  49880. */
  49881. TRACKING_LOST = 1,
  49882. /**
  49883. * Transformation tracking works normally
  49884. */
  49885. TRACKING = 2
  49886. }
  49887. /**
  49888. * Abstraction of the XR render target
  49889. */
  49890. export interface WebXRRenderTarget extends IDisposable {
  49891. /**
  49892. * xrpresent context of the canvas which can be used to display/mirror xr content
  49893. */
  49894. canvasContext: WebGLRenderingContext;
  49895. /**
  49896. * xr layer for the canvas
  49897. */
  49898. xrLayer: Nullable<XRWebGLLayer>;
  49899. /**
  49900. * Initializes the xr layer for the session
  49901. * @param xrSession xr session
  49902. * @returns a promise that will resolve once the XR Layer has been created
  49903. */
  49904. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49905. }
  49906. }
  49907. declare module BABYLON {
  49908. /**
  49909. * COnfiguration object for WebXR output canvas
  49910. */
  49911. export class WebXRManagedOutputCanvasOptions {
  49912. /**
  49913. * An optional canvas in case you wish to create it yourself and provide it here.
  49914. * If not provided, a new canvas will be created
  49915. */
  49916. canvasElement?: HTMLCanvasElement;
  49917. /**
  49918. * Options for this XR Layer output
  49919. */
  49920. canvasOptions?: XRWebGLLayerOptions;
  49921. /**
  49922. * CSS styling for a newly created canvas (if not provided)
  49923. */
  49924. newCanvasCssStyle?: string;
  49925. /**
  49926. * Get the default values of the configuration object
  49927. * @param engine defines the engine to use (can be null)
  49928. * @returns default values of this configuration object
  49929. */
  49930. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  49931. }
  49932. /**
  49933. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  49934. */
  49935. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  49936. private _options;
  49937. private _canvas;
  49938. private _engine;
  49939. private _originalCanvasSize;
  49940. /**
  49941. * Rendering context of the canvas which can be used to display/mirror xr content
  49942. */
  49943. canvasContext: WebGLRenderingContext;
  49944. /**
  49945. * xr layer for the canvas
  49946. */
  49947. xrLayer: Nullable<XRWebGLLayer>;
  49948. /**
  49949. * Obseervers registered here will be triggered when the xr layer was initialized
  49950. */
  49951. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  49952. /**
  49953. * Initializes the canvas to be added/removed upon entering/exiting xr
  49954. * @param _xrSessionManager The XR Session manager
  49955. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  49956. */
  49957. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  49958. /**
  49959. * Disposes of the object
  49960. */
  49961. dispose(): void;
  49962. /**
  49963. * Initializes the xr layer for the session
  49964. * @param xrSession xr session
  49965. * @returns a promise that will resolve once the XR Layer has been created
  49966. */
  49967. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49968. private _addCanvas;
  49969. private _removeCanvas;
  49970. private _setCanvasSize;
  49971. private _setManagedOutputCanvas;
  49972. }
  49973. }
  49974. declare module BABYLON {
  49975. /**
  49976. * Manages an XRSession to work with Babylon's engine
  49977. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  49978. */
  49979. export class WebXRSessionManager implements IDisposable {
  49980. /** The scene which the session should be created for */
  49981. scene: Scene;
  49982. private _referenceSpace;
  49983. private _rttProvider;
  49984. private _sessionEnded;
  49985. private _xrNavigator;
  49986. private baseLayer;
  49987. /**
  49988. * The base reference space from which the session started. good if you want to reset your
  49989. * reference space
  49990. */
  49991. baseReferenceSpace: XRReferenceSpace;
  49992. /**
  49993. * Current XR frame
  49994. */
  49995. currentFrame: Nullable<XRFrame>;
  49996. /** WebXR timestamp updated every frame */
  49997. currentTimestamp: number;
  49998. /**
  49999. * Used just in case of a failure to initialize an immersive session.
  50000. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50001. */
  50002. defaultHeightCompensation: number;
  50003. /**
  50004. * Fires every time a new xrFrame arrives which can be used to update the camera
  50005. */
  50006. onXRFrameObservable: Observable<XRFrame>;
  50007. /**
  50008. * Fires when the reference space changed
  50009. */
  50010. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50011. /**
  50012. * Fires when the xr session is ended either by the device or manually done
  50013. */
  50014. onXRSessionEnded: Observable<any>;
  50015. /**
  50016. * Fires when the xr session is ended either by the device or manually done
  50017. */
  50018. onXRSessionInit: Observable<XRSession>;
  50019. /**
  50020. * Underlying xr session
  50021. */
  50022. session: XRSession;
  50023. /**
  50024. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50025. * or get the offset the player is currently at.
  50026. */
  50027. viewerReferenceSpace: XRReferenceSpace;
  50028. /**
  50029. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50030. * @param scene The scene which the session should be created for
  50031. */
  50032. constructor(
  50033. /** The scene which the session should be created for */
  50034. scene: Scene);
  50035. /**
  50036. * The current reference space used in this session. This reference space can constantly change!
  50037. * It is mainly used to offset the camera's position.
  50038. */
  50039. get referenceSpace(): XRReferenceSpace;
  50040. /**
  50041. * Set a new reference space and triggers the observable
  50042. */
  50043. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50044. /**
  50045. * Disposes of the session manager
  50046. */
  50047. dispose(): void;
  50048. /**
  50049. * Stops the xrSession and restores the render loop
  50050. * @returns Promise which resolves after it exits XR
  50051. */
  50052. exitXRAsync(): Promise<void>;
  50053. /**
  50054. * Gets the correct render target texture to be rendered this frame for this eye
  50055. * @param eye the eye for which to get the render target
  50056. * @returns the render target for the specified eye
  50057. */
  50058. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50059. /**
  50060. * Creates a WebXRRenderTarget object for the XR session
  50061. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50062. * @param options optional options to provide when creating a new render target
  50063. * @returns a WebXR render target to which the session can render
  50064. */
  50065. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50066. /**
  50067. * Initializes the manager
  50068. * After initialization enterXR can be called to start an XR session
  50069. * @returns Promise which resolves after it is initialized
  50070. */
  50071. initializeAsync(): Promise<void>;
  50072. /**
  50073. * Initializes an xr session
  50074. * @param xrSessionMode mode to initialize
  50075. * @param xrSessionInit defines optional and required values to pass to the session builder
  50076. * @returns a promise which will resolve once the session has been initialized
  50077. */
  50078. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50079. /**
  50080. * Checks if a session would be supported for the creation options specified
  50081. * @param sessionMode session mode to check if supported eg. immersive-vr
  50082. * @returns A Promise that resolves to true if supported and false if not
  50083. */
  50084. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50085. /**
  50086. * Resets the reference space to the one started the session
  50087. */
  50088. resetReferenceSpace(): void;
  50089. /**
  50090. * Starts rendering to the xr layer
  50091. */
  50092. runXRRenderLoop(): void;
  50093. /**
  50094. * Sets the reference space on the xr session
  50095. * @param referenceSpaceType space to set
  50096. * @returns a promise that will resolve once the reference space has been set
  50097. */
  50098. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50099. /**
  50100. * Updates the render state of the session
  50101. * @param state state to set
  50102. * @returns a promise that resolves once the render state has been updated
  50103. */
  50104. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50105. /**
  50106. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50107. * @param sessionMode defines the session to test
  50108. * @returns a promise with boolean as final value
  50109. */
  50110. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50111. private _createRenderTargetTexture;
  50112. }
  50113. }
  50114. declare module BABYLON {
  50115. /**
  50116. * WebXR Camera which holds the views for the xrSession
  50117. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50118. */
  50119. export class WebXRCamera extends FreeCamera {
  50120. private _xrSessionManager;
  50121. private _firstFrame;
  50122. private _referenceQuaternion;
  50123. private _referencedPosition;
  50124. private _xrInvPositionCache;
  50125. private _xrInvQuaternionCache;
  50126. private _trackingState;
  50127. /**
  50128. * Observable raised before camera teleportation
  50129. */
  50130. onBeforeCameraTeleport: Observable<Vector3>;
  50131. /**
  50132. * Observable raised after camera teleportation
  50133. */
  50134. onAfterCameraTeleport: Observable<Vector3>;
  50135. /**
  50136. * Notifies when the camera's tracking state has changed.
  50137. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50138. */
  50139. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50140. /**
  50141. * Should position compensation execute on first frame.
  50142. * This is used when copying the position from a native (non XR) camera
  50143. */
  50144. compensateOnFirstFrame: boolean;
  50145. /**
  50146. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50147. * @param name the name of the camera
  50148. * @param scene the scene to add the camera to
  50149. * @param _xrSessionManager a constructed xr session manager
  50150. */
  50151. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50152. /**
  50153. * Get the current XR tracking state of the camera
  50154. */
  50155. get trackingState(): WebXRTrackingState;
  50156. private _setTrackingState;
  50157. /**
  50158. * Return the user's height, unrelated to the current ground.
  50159. * This will be the y position of this camera, when ground level is 0.
  50160. */
  50161. get realWorldHeight(): number;
  50162. /** @hidden */
  50163. _updateForDualEyeDebugging(): void;
  50164. /**
  50165. * Sets this camera's transformation based on a non-vr camera
  50166. * @param otherCamera the non-vr camera to copy the transformation from
  50167. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50168. */
  50169. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50170. /**
  50171. * Gets the current instance class name ("WebXRCamera").
  50172. * @returns the class name
  50173. */
  50174. getClassName(): string;
  50175. private _rotate180;
  50176. private _updateFromXRSession;
  50177. private _updateNumberOfRigCameras;
  50178. private _updateReferenceSpace;
  50179. private _updateReferenceSpaceOffset;
  50180. }
  50181. }
  50182. declare module BABYLON {
  50183. /**
  50184. * Defining the interface required for a (webxr) feature
  50185. */
  50186. export interface IWebXRFeature extends IDisposable {
  50187. /**
  50188. * Is this feature attached
  50189. */
  50190. attached: boolean;
  50191. /**
  50192. * Should auto-attach be disabled?
  50193. */
  50194. disableAutoAttach: boolean;
  50195. /**
  50196. * Attach the feature to the session
  50197. * Will usually be called by the features manager
  50198. *
  50199. * @param force should attachment be forced (even when already attached)
  50200. * @returns true if successful.
  50201. */
  50202. attach(force?: boolean): boolean;
  50203. /**
  50204. * Detach the feature from the session
  50205. * Will usually be called by the features manager
  50206. *
  50207. * @returns true if successful.
  50208. */
  50209. detach(): boolean;
  50210. /**
  50211. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50212. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50213. *
  50214. * @returns whether or not the feature is compatible in this environment
  50215. */
  50216. isCompatible(): boolean;
  50217. /**
  50218. * Was this feature disposed;
  50219. */
  50220. isDisposed: boolean;
  50221. /**
  50222. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50223. */
  50224. xrNativeFeatureName?: string;
  50225. /**
  50226. * A list of (Babylon WebXR) features this feature depends on
  50227. */
  50228. dependsOn?: string[];
  50229. }
  50230. /**
  50231. * A list of the currently available features without referencing them
  50232. */
  50233. export class WebXRFeatureName {
  50234. /**
  50235. * The name of the anchor system feature
  50236. */
  50237. static readonly ANCHOR_SYSTEM: string;
  50238. /**
  50239. * The name of the background remover feature
  50240. */
  50241. static readonly BACKGROUND_REMOVER: string;
  50242. /**
  50243. * The name of the hit test feature
  50244. */
  50245. static readonly HIT_TEST: string;
  50246. /**
  50247. * physics impostors for xr controllers feature
  50248. */
  50249. static readonly PHYSICS_CONTROLLERS: string;
  50250. /**
  50251. * The name of the plane detection feature
  50252. */
  50253. static readonly PLANE_DETECTION: string;
  50254. /**
  50255. * The name of the pointer selection feature
  50256. */
  50257. static readonly POINTER_SELECTION: string;
  50258. /**
  50259. * The name of the teleportation feature
  50260. */
  50261. static readonly TELEPORTATION: string;
  50262. /**
  50263. * The name of the feature points feature.
  50264. */
  50265. static readonly FEATURE_POINTS: string;
  50266. /**
  50267. * The name of the hand tracking feature.
  50268. */
  50269. static readonly HAND_TRACKING: string;
  50270. }
  50271. /**
  50272. * Defining the constructor of a feature. Used to register the modules.
  50273. */
  50274. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50275. /**
  50276. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50277. * It is mainly used in AR sessions.
  50278. *
  50279. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50280. */
  50281. export class WebXRFeaturesManager implements IDisposable {
  50282. private _xrSessionManager;
  50283. private static readonly _AvailableFeatures;
  50284. private _features;
  50285. /**
  50286. * constructs a new features manages.
  50287. *
  50288. * @param _xrSessionManager an instance of WebXRSessionManager
  50289. */
  50290. constructor(_xrSessionManager: WebXRSessionManager);
  50291. /**
  50292. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50293. * Mainly used internally.
  50294. *
  50295. * @param featureName the name of the feature to register
  50296. * @param constructorFunction the function used to construct the module
  50297. * @param version the (babylon) version of the module
  50298. * @param stable is that a stable version of this module
  50299. */
  50300. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50301. /**
  50302. * Returns a constructor of a specific feature.
  50303. *
  50304. * @param featureName the name of the feature to construct
  50305. * @param version the version of the feature to load
  50306. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50307. * @param options optional options provided to the module.
  50308. * @returns a function that, when called, will return a new instance of this feature
  50309. */
  50310. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50311. /**
  50312. * Can be used to return the list of features currently registered
  50313. *
  50314. * @returns an Array of available features
  50315. */
  50316. static GetAvailableFeatures(): string[];
  50317. /**
  50318. * Gets the versions available for a specific feature
  50319. * @param featureName the name of the feature
  50320. * @returns an array with the available versions
  50321. */
  50322. static GetAvailableVersions(featureName: string): string[];
  50323. /**
  50324. * Return the latest unstable version of this feature
  50325. * @param featureName the name of the feature to search
  50326. * @returns the version number. if not found will return -1
  50327. */
  50328. static GetLatestVersionOfFeature(featureName: string): number;
  50329. /**
  50330. * Return the latest stable version of this feature
  50331. * @param featureName the name of the feature to search
  50332. * @returns the version number. if not found will return -1
  50333. */
  50334. static GetStableVersionOfFeature(featureName: string): number;
  50335. /**
  50336. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50337. * Can be used during a session to start a feature
  50338. * @param featureName the name of feature to attach
  50339. */
  50340. attachFeature(featureName: string): void;
  50341. /**
  50342. * Can be used inside a session or when the session ends to detach a specific feature
  50343. * @param featureName the name of the feature to detach
  50344. */
  50345. detachFeature(featureName: string): void;
  50346. /**
  50347. * Used to disable an already-enabled feature
  50348. * The feature will be disposed and will be recreated once enabled.
  50349. * @param featureName the feature to disable
  50350. * @returns true if disable was successful
  50351. */
  50352. disableFeature(featureName: string | {
  50353. Name: string;
  50354. }): boolean;
  50355. /**
  50356. * dispose this features manager
  50357. */
  50358. dispose(): void;
  50359. /**
  50360. * 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.
  50361. * 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.
  50362. *
  50363. * @param featureName the name of the feature to load or the class of the feature
  50364. * @param version optional version to load. if not provided the latest version will be enabled
  50365. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50366. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50367. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50368. * @returns a new constructed feature or throws an error if feature not found.
  50369. */
  50370. enableFeature(featureName: string | {
  50371. Name: string;
  50372. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50373. /**
  50374. * get the implementation of an enabled feature.
  50375. * @param featureName the name of the feature to load
  50376. * @returns the feature class, if found
  50377. */
  50378. getEnabledFeature(featureName: string): IWebXRFeature;
  50379. /**
  50380. * Get the list of enabled features
  50381. * @returns an array of enabled features
  50382. */
  50383. getEnabledFeatures(): string[];
  50384. /**
  50385. * This function will exten the session creation configuration object with enabled features.
  50386. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50387. * according to the defined "required" variable, provided during enableFeature call
  50388. * @param xrSessionInit the xr Session init object to extend
  50389. *
  50390. * @returns an extended XRSessionInit object
  50391. */
  50392. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50393. }
  50394. }
  50395. declare module BABYLON {
  50396. /**
  50397. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50398. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50399. */
  50400. export class WebXRExperienceHelper implements IDisposable {
  50401. private scene;
  50402. private _nonVRCamera;
  50403. private _originalSceneAutoClear;
  50404. private _supported;
  50405. /**
  50406. * Camera used to render xr content
  50407. */
  50408. camera: WebXRCamera;
  50409. /** A features manager for this xr session */
  50410. featuresManager: WebXRFeaturesManager;
  50411. /**
  50412. * Observers registered here will be triggered after the camera's initial transformation is set
  50413. * This can be used to set a different ground level or an extra rotation.
  50414. *
  50415. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50416. * to the position set after this observable is done executing.
  50417. */
  50418. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50419. /**
  50420. * Fires when the state of the experience helper has changed
  50421. */
  50422. onStateChangedObservable: Observable<WebXRState>;
  50423. /** Session manager used to keep track of xr session */
  50424. sessionManager: WebXRSessionManager;
  50425. /**
  50426. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50427. */
  50428. state: WebXRState;
  50429. /**
  50430. * Creates a WebXRExperienceHelper
  50431. * @param scene The scene the helper should be created in
  50432. */
  50433. private constructor();
  50434. /**
  50435. * Creates the experience helper
  50436. * @param scene the scene to attach the experience helper to
  50437. * @returns a promise for the experience helper
  50438. */
  50439. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50440. /**
  50441. * Disposes of the experience helper
  50442. */
  50443. dispose(): void;
  50444. /**
  50445. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50446. * @param sessionMode options for the XR session
  50447. * @param referenceSpaceType frame of reference of the XR session
  50448. * @param renderTarget the output canvas that will be used to enter XR mode
  50449. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50450. * @returns promise that resolves after xr mode has entered
  50451. */
  50452. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50453. /**
  50454. * Exits XR mode and returns the scene to its original state
  50455. * @returns promise that resolves after xr mode has exited
  50456. */
  50457. exitXRAsync(): Promise<void>;
  50458. private _nonXRToXRCamera;
  50459. private _setState;
  50460. }
  50461. }
  50462. declare module BABYLON {
  50463. /**
  50464. * X-Y values for axes in WebXR
  50465. */
  50466. export interface IWebXRMotionControllerAxesValue {
  50467. /**
  50468. * The value of the x axis
  50469. */
  50470. x: number;
  50471. /**
  50472. * The value of the y-axis
  50473. */
  50474. y: number;
  50475. }
  50476. /**
  50477. * changed / previous values for the values of this component
  50478. */
  50479. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50480. /**
  50481. * current (this frame) value
  50482. */
  50483. current: T;
  50484. /**
  50485. * previous (last change) value
  50486. */
  50487. previous: T;
  50488. }
  50489. /**
  50490. * Represents changes in the component between current frame and last values recorded
  50491. */
  50492. export interface IWebXRMotionControllerComponentChanges {
  50493. /**
  50494. * will be populated with previous and current values if axes changed
  50495. */
  50496. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50497. /**
  50498. * will be populated with previous and current values if pressed changed
  50499. */
  50500. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50501. /**
  50502. * will be populated with previous and current values if touched changed
  50503. */
  50504. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50505. /**
  50506. * will be populated with previous and current values if value changed
  50507. */
  50508. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50509. }
  50510. /**
  50511. * This class represents a single component (for example button or thumbstick) of a motion controller
  50512. */
  50513. export class WebXRControllerComponent implements IDisposable {
  50514. /**
  50515. * the id of this component
  50516. */
  50517. id: string;
  50518. /**
  50519. * the type of the component
  50520. */
  50521. type: MotionControllerComponentType;
  50522. private _buttonIndex;
  50523. private _axesIndices;
  50524. private _axes;
  50525. private _changes;
  50526. private _currentValue;
  50527. private _hasChanges;
  50528. private _pressed;
  50529. private _touched;
  50530. /**
  50531. * button component type
  50532. */
  50533. static BUTTON_TYPE: MotionControllerComponentType;
  50534. /**
  50535. * squeeze component type
  50536. */
  50537. static SQUEEZE_TYPE: MotionControllerComponentType;
  50538. /**
  50539. * Thumbstick component type
  50540. */
  50541. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50542. /**
  50543. * Touchpad component type
  50544. */
  50545. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50546. /**
  50547. * trigger component type
  50548. */
  50549. static TRIGGER_TYPE: MotionControllerComponentType;
  50550. /**
  50551. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50552. * the axes data changes
  50553. */
  50554. onAxisValueChangedObservable: Observable<{
  50555. x: number;
  50556. y: number;
  50557. }>;
  50558. /**
  50559. * Observers registered here will be triggered when the state of a button changes
  50560. * State change is either pressed / touched / value
  50561. */
  50562. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50563. /**
  50564. * Creates a new component for a motion controller.
  50565. * It is created by the motion controller itself
  50566. *
  50567. * @param id the id of this component
  50568. * @param type the type of the component
  50569. * @param _buttonIndex index in the buttons array of the gamepad
  50570. * @param _axesIndices indices of the values in the axes array of the gamepad
  50571. */
  50572. constructor(
  50573. /**
  50574. * the id of this component
  50575. */
  50576. id: string,
  50577. /**
  50578. * the type of the component
  50579. */
  50580. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50581. /**
  50582. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50583. */
  50584. get axes(): IWebXRMotionControllerAxesValue;
  50585. /**
  50586. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50587. */
  50588. get changes(): IWebXRMotionControllerComponentChanges;
  50589. /**
  50590. * Return whether or not the component changed the last frame
  50591. */
  50592. get hasChanges(): boolean;
  50593. /**
  50594. * is the button currently pressed
  50595. */
  50596. get pressed(): boolean;
  50597. /**
  50598. * is the button currently touched
  50599. */
  50600. get touched(): boolean;
  50601. /**
  50602. * Get the current value of this component
  50603. */
  50604. get value(): number;
  50605. /**
  50606. * Dispose this component
  50607. */
  50608. dispose(): void;
  50609. /**
  50610. * Are there axes correlating to this component
  50611. * @return true is axes data is available
  50612. */
  50613. isAxes(): boolean;
  50614. /**
  50615. * Is this component a button (hence - pressable)
  50616. * @returns true if can be pressed
  50617. */
  50618. isButton(): boolean;
  50619. /**
  50620. * update this component using the gamepad object it is in. Called on every frame
  50621. * @param nativeController the native gamepad controller object
  50622. */
  50623. update(nativeController: IMinimalMotionControllerObject): void;
  50624. }
  50625. }
  50626. declare module BABYLON {
  50627. /**
  50628. * Interface used to represent data loading progression
  50629. */
  50630. export interface ISceneLoaderProgressEvent {
  50631. /**
  50632. * Defines if data length to load can be evaluated
  50633. */
  50634. readonly lengthComputable: boolean;
  50635. /**
  50636. * Defines the loaded data length
  50637. */
  50638. readonly loaded: number;
  50639. /**
  50640. * Defines the data length to load
  50641. */
  50642. readonly total: number;
  50643. }
  50644. /**
  50645. * Interface used by SceneLoader plugins to define supported file extensions
  50646. */
  50647. export interface ISceneLoaderPluginExtensions {
  50648. /**
  50649. * Defines the list of supported extensions
  50650. */
  50651. [extension: string]: {
  50652. isBinary: boolean;
  50653. };
  50654. }
  50655. /**
  50656. * Interface used by SceneLoader plugin factory
  50657. */
  50658. export interface ISceneLoaderPluginFactory {
  50659. /**
  50660. * Defines the name of the factory
  50661. */
  50662. name: string;
  50663. /**
  50664. * Function called to create a new plugin
  50665. * @return the new plugin
  50666. */
  50667. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50668. /**
  50669. * The callback that returns true if the data can be directly loaded.
  50670. * @param data string containing the file data
  50671. * @returns if the data can be loaded directly
  50672. */
  50673. canDirectLoad?(data: string): boolean;
  50674. }
  50675. /**
  50676. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50677. */
  50678. export interface ISceneLoaderPluginBase {
  50679. /**
  50680. * The friendly name of this plugin.
  50681. */
  50682. name: string;
  50683. /**
  50684. * The file extensions supported by this plugin.
  50685. */
  50686. extensions: string | ISceneLoaderPluginExtensions;
  50687. /**
  50688. * The callback called when loading from a url.
  50689. * @param scene scene loading this url
  50690. * @param url url to load
  50691. * @param onSuccess callback called when the file successfully loads
  50692. * @param onProgress callback called while file is loading (if the server supports this mode)
  50693. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50694. * @param onError callback called when the file fails to load
  50695. * @returns a file request object
  50696. */
  50697. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50698. /**
  50699. * The callback called when loading from a file object.
  50700. * @param scene scene loading this file
  50701. * @param file defines the file to load
  50702. * @param onSuccess defines the callback to call when data is loaded
  50703. * @param onProgress defines the callback to call during loading process
  50704. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50705. * @param onError defines the callback to call when an error occurs
  50706. * @returns a file request object
  50707. */
  50708. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50709. /**
  50710. * The callback that returns true if the data can be directly loaded.
  50711. * @param data string containing the file data
  50712. * @returns if the data can be loaded directly
  50713. */
  50714. canDirectLoad?(data: string): boolean;
  50715. /**
  50716. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50717. * @param scene scene loading this data
  50718. * @param data string containing the data
  50719. * @returns data to pass to the plugin
  50720. */
  50721. directLoad?(scene: Scene, data: string): any;
  50722. /**
  50723. * The callback that allows custom handling of the root url based on the response url.
  50724. * @param rootUrl the original root url
  50725. * @param responseURL the response url if available
  50726. * @returns the new root url
  50727. */
  50728. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50729. }
  50730. /**
  50731. * Interface used to define a SceneLoader plugin
  50732. */
  50733. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50734. /**
  50735. * Import meshes into a scene.
  50736. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50737. * @param scene The scene to import into
  50738. * @param data The data to import
  50739. * @param rootUrl The root url for scene and resources
  50740. * @param meshes The meshes array to import into
  50741. * @param particleSystems The particle systems array to import into
  50742. * @param skeletons The skeletons array to import into
  50743. * @param onError The callback when import fails
  50744. * @returns True if successful or false otherwise
  50745. */
  50746. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  50747. /**
  50748. * Load into a scene.
  50749. * @param scene The scene to load into
  50750. * @param data The data to import
  50751. * @param rootUrl The root url for scene and resources
  50752. * @param onError The callback when import fails
  50753. * @returns True if successful or false otherwise
  50754. */
  50755. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  50756. /**
  50757. * Load into an asset container.
  50758. * @param scene The scene to load into
  50759. * @param data The data to import
  50760. * @param rootUrl The root url for scene and resources
  50761. * @param onError The callback when import fails
  50762. * @returns The loaded asset container
  50763. */
  50764. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  50765. }
  50766. /**
  50767. * Interface used to define an async SceneLoader plugin
  50768. */
  50769. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  50770. /**
  50771. * Import meshes into a scene.
  50772. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50773. * @param scene The scene to import into
  50774. * @param data The data to import
  50775. * @param rootUrl The root url for scene and resources
  50776. * @param onProgress The callback when the load progresses
  50777. * @param fileName Defines the name of the file to load
  50778. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  50779. */
  50780. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  50781. meshes: AbstractMesh[];
  50782. particleSystems: IParticleSystem[];
  50783. skeletons: Skeleton[];
  50784. animationGroups: AnimationGroup[];
  50785. }>;
  50786. /**
  50787. * Load into a scene.
  50788. * @param scene The scene to load into
  50789. * @param data The data to import
  50790. * @param rootUrl The root url for scene and resources
  50791. * @param onProgress The callback when the load progresses
  50792. * @param fileName Defines the name of the file to load
  50793. * @returns Nothing
  50794. */
  50795. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  50796. /**
  50797. * Load into an asset container.
  50798. * @param scene The scene to load into
  50799. * @param data The data to import
  50800. * @param rootUrl The root url for scene and resources
  50801. * @param onProgress The callback when the load progresses
  50802. * @param fileName Defines the name of the file to load
  50803. * @returns The loaded asset container
  50804. */
  50805. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  50806. }
  50807. /**
  50808. * Mode that determines how to handle old animation groups before loading new ones.
  50809. */
  50810. export enum SceneLoaderAnimationGroupLoadingMode {
  50811. /**
  50812. * Reset all old animations to initial state then dispose them.
  50813. */
  50814. Clean = 0,
  50815. /**
  50816. * Stop all old animations.
  50817. */
  50818. Stop = 1,
  50819. /**
  50820. * Restart old animations from first frame.
  50821. */
  50822. Sync = 2,
  50823. /**
  50824. * Old animations remains untouched.
  50825. */
  50826. NoSync = 3
  50827. }
  50828. /**
  50829. * Defines a plugin registered by the SceneLoader
  50830. */
  50831. interface IRegisteredPlugin {
  50832. /**
  50833. * Defines the plugin to use
  50834. */
  50835. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50836. /**
  50837. * Defines if the plugin supports binary data
  50838. */
  50839. isBinary: boolean;
  50840. }
  50841. /**
  50842. * Class used to load scene from various file formats using registered plugins
  50843. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  50844. */
  50845. export class SceneLoader {
  50846. /**
  50847. * No logging while loading
  50848. */
  50849. static readonly NO_LOGGING: number;
  50850. /**
  50851. * Minimal logging while loading
  50852. */
  50853. static readonly MINIMAL_LOGGING: number;
  50854. /**
  50855. * Summary logging while loading
  50856. */
  50857. static readonly SUMMARY_LOGGING: number;
  50858. /**
  50859. * Detailled logging while loading
  50860. */
  50861. static readonly DETAILED_LOGGING: number;
  50862. /**
  50863. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50864. */
  50865. static get ForceFullSceneLoadingForIncremental(): boolean;
  50866. static set ForceFullSceneLoadingForIncremental(value: boolean);
  50867. /**
  50868. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50869. */
  50870. static get ShowLoadingScreen(): boolean;
  50871. static set ShowLoadingScreen(value: boolean);
  50872. /**
  50873. * Defines the current logging level (while loading the scene)
  50874. * @ignorenaming
  50875. */
  50876. static get loggingLevel(): number;
  50877. static set loggingLevel(value: number);
  50878. /**
  50879. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50880. */
  50881. static get CleanBoneMatrixWeights(): boolean;
  50882. static set CleanBoneMatrixWeights(value: boolean);
  50883. /**
  50884. * Event raised when a plugin is used to load a scene
  50885. */
  50886. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  50887. private static _registeredPlugins;
  50888. private static _showingLoadingScreen;
  50889. /**
  50890. * Gets the default plugin (used to load Babylon files)
  50891. * @returns the .babylon plugin
  50892. */
  50893. static GetDefaultPlugin(): IRegisteredPlugin;
  50894. private static _GetPluginForExtension;
  50895. private static _GetPluginForDirectLoad;
  50896. private static _GetPluginForFilename;
  50897. private static _GetDirectLoad;
  50898. private static _LoadData;
  50899. private static _GetFileInfo;
  50900. /**
  50901. * Gets a plugin that can load the given extension
  50902. * @param extension defines the extension to load
  50903. * @returns a plugin or null if none works
  50904. */
  50905. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50906. /**
  50907. * Gets a boolean indicating that the given extension can be loaded
  50908. * @param extension defines the extension to load
  50909. * @returns true if the extension is supported
  50910. */
  50911. static IsPluginForExtensionAvailable(extension: string): boolean;
  50912. /**
  50913. * Adds a new plugin to the list of registered plugins
  50914. * @param plugin defines the plugin to add
  50915. */
  50916. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  50917. /**
  50918. * Import meshes into a scene
  50919. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50920. * @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)
  50921. * @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)
  50922. * @param scene the instance of BABYLON.Scene to append to
  50923. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  50924. * @param onProgress a callback with a progress event for each file being loaded
  50925. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50926. * @param pluginExtension the extension used to determine the plugin
  50927. * @returns The loaded plugin
  50928. */
  50929. 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>;
  50930. /**
  50931. * Import meshes into a scene
  50932. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50933. * @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)
  50934. * @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)
  50935. * @param scene the instance of BABYLON.Scene to append to
  50936. * @param onProgress a callback with a progress event for each file being loaded
  50937. * @param pluginExtension the extension used to determine the plugin
  50938. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50939. */
  50940. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  50941. meshes: AbstractMesh[];
  50942. particleSystems: IParticleSystem[];
  50943. skeletons: Skeleton[];
  50944. animationGroups: AnimationGroup[];
  50945. }>;
  50946. /**
  50947. * Load a scene
  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 engine is the instance of BABYLON.Engine to use to create the scene
  50951. * @param onSuccess a callback with the scene 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 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>;
  50958. /**
  50959. * Load a scene
  50960. * @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)
  50961. * @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)
  50962. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50963. * @param onProgress a callback with a progress event for each file being loaded
  50964. * @param pluginExtension the extension used to determine the plugin
  50965. * @returns The loaded scene
  50966. */
  50967. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50968. /**
  50969. * Append a scene
  50970. * @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)
  50971. * @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)
  50972. * @param scene is the instance of BABYLON.Scene to append to
  50973. * @param onSuccess a callback with the scene when import succeeds
  50974. * @param onProgress a callback with a progress event for each file being loaded
  50975. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50976. * @param pluginExtension the extension used to determine the plugin
  50977. * @returns The loaded plugin
  50978. */
  50979. 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>;
  50980. /**
  50981. * Append a scene
  50982. * @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)
  50983. * @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)
  50984. * @param scene is the instance of BABYLON.Scene to append to
  50985. * @param onProgress a callback with a progress event for each file being loaded
  50986. * @param pluginExtension the extension used to determine the plugin
  50987. * @returns The given scene
  50988. */
  50989. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50990. /**
  50991. * Load a scene into an asset container
  50992. * @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)
  50993. * @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)
  50994. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50995. * @param onSuccess a callback with the scene when import succeeds
  50996. * @param onProgress a callback with a progress event for each file being loaded
  50997. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50998. * @param pluginExtension the extension used to determine the plugin
  50999. * @returns The loaded plugin
  51000. */
  51001. 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>;
  51002. /**
  51003. * Load a scene into an asset container
  51004. * @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)
  51005. * @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)
  51006. * @param scene is the instance of Scene to append to
  51007. * @param onProgress a callback with a progress event for each file being loaded
  51008. * @param pluginExtension the extension used to determine the plugin
  51009. * @returns The loaded asset container
  51010. */
  51011. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51012. /**
  51013. * Import animations from a file into a scene
  51014. * @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)
  51015. * @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)
  51016. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51017. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51018. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51019. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51020. * @param onSuccess a callback with the scene when import succeeds
  51021. * @param onProgress a callback with a progress event for each file being loaded
  51022. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51023. * @param pluginExtension the extension used to determine the plugin
  51024. */
  51025. 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;
  51026. /**
  51027. * Import animations from a file into a scene
  51028. * @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)
  51029. * @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)
  51030. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51031. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51032. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51033. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51034. * @param onSuccess a callback with the scene when import succeeds
  51035. * @param onProgress a callback with a progress event for each file being loaded
  51036. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51037. * @param pluginExtension the extension used to determine the plugin
  51038. * @returns the updated scene with imported animations
  51039. */
  51040. 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>;
  51041. }
  51042. }
  51043. declare module BABYLON {
  51044. /**
  51045. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51046. */
  51047. export type MotionControllerHandedness = "none" | "left" | "right";
  51048. /**
  51049. * The type of components available in motion controllers.
  51050. * This is not the name of the component.
  51051. */
  51052. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51053. /**
  51054. * The state of a controller component
  51055. */
  51056. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51057. /**
  51058. * The schema of motion controller layout.
  51059. * No object will be initialized using this interface
  51060. * This is used just to define the profile.
  51061. */
  51062. export interface IMotionControllerLayout {
  51063. /**
  51064. * Path to load the assets. Usually relative to the base path
  51065. */
  51066. assetPath: string;
  51067. /**
  51068. * Available components (unsorted)
  51069. */
  51070. components: {
  51071. /**
  51072. * A map of component Ids
  51073. */
  51074. [componentId: string]: {
  51075. /**
  51076. * The type of input the component outputs
  51077. */
  51078. type: MotionControllerComponentType;
  51079. /**
  51080. * The indices of this component in the gamepad object
  51081. */
  51082. gamepadIndices: {
  51083. /**
  51084. * Index of button
  51085. */
  51086. button?: number;
  51087. /**
  51088. * If available, index of x-axis
  51089. */
  51090. xAxis?: number;
  51091. /**
  51092. * If available, index of y-axis
  51093. */
  51094. yAxis?: number;
  51095. };
  51096. /**
  51097. * The mesh's root node name
  51098. */
  51099. rootNodeName: string;
  51100. /**
  51101. * Animation definitions for this model
  51102. */
  51103. visualResponses: {
  51104. [stateKey: string]: {
  51105. /**
  51106. * What property will be animated
  51107. */
  51108. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51109. /**
  51110. * What states influence this visual response
  51111. */
  51112. states: MotionControllerComponentStateType[];
  51113. /**
  51114. * Type of animation - movement or visibility
  51115. */
  51116. valueNodeProperty: "transform" | "visibility";
  51117. /**
  51118. * Base node name to move. Its position will be calculated according to the min and max nodes
  51119. */
  51120. valueNodeName?: string;
  51121. /**
  51122. * Minimum movement node
  51123. */
  51124. minNodeName?: string;
  51125. /**
  51126. * Max movement node
  51127. */
  51128. maxNodeName?: string;
  51129. };
  51130. };
  51131. /**
  51132. * If touch enabled, what is the name of node to display user feedback
  51133. */
  51134. touchPointNodeName?: string;
  51135. };
  51136. };
  51137. /**
  51138. * Is it xr standard mapping or not
  51139. */
  51140. gamepadMapping: "" | "xr-standard";
  51141. /**
  51142. * Base root node of this entire model
  51143. */
  51144. rootNodeName: string;
  51145. /**
  51146. * Defines the main button component id
  51147. */
  51148. selectComponentId: string;
  51149. }
  51150. /**
  51151. * A definition for the layout map in the input profile
  51152. */
  51153. export interface IMotionControllerLayoutMap {
  51154. /**
  51155. * Layouts with handedness type as a key
  51156. */
  51157. [handedness: string]: IMotionControllerLayout;
  51158. }
  51159. /**
  51160. * The XR Input profile schema
  51161. * Profiles can be found here:
  51162. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51163. */
  51164. export interface IMotionControllerProfile {
  51165. /**
  51166. * fallback profiles for this profileId
  51167. */
  51168. fallbackProfileIds: string[];
  51169. /**
  51170. * The layout map, with handedness as key
  51171. */
  51172. layouts: IMotionControllerLayoutMap;
  51173. /**
  51174. * The id of this profile
  51175. * correlates to the profile(s) in the xrInput.profiles array
  51176. */
  51177. profileId: string;
  51178. }
  51179. /**
  51180. * A helper-interface for the 3 meshes needed for controller button animation
  51181. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51182. */
  51183. export interface IMotionControllerButtonMeshMap {
  51184. /**
  51185. * the mesh that defines the pressed value mesh position.
  51186. * This is used to find the max-position of this button
  51187. */
  51188. pressedMesh: AbstractMesh;
  51189. /**
  51190. * the mesh that defines the unpressed value mesh position.
  51191. * This is used to find the min (or initial) position of this button
  51192. */
  51193. unpressedMesh: AbstractMesh;
  51194. /**
  51195. * The mesh that will be changed when value changes
  51196. */
  51197. valueMesh: AbstractMesh;
  51198. }
  51199. /**
  51200. * A helper-interface for the 3 meshes needed for controller axis animation.
  51201. * This will be expanded when touchpad animations are fully supported
  51202. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51203. */
  51204. export interface IMotionControllerMeshMap {
  51205. /**
  51206. * the mesh that defines the maximum value mesh position.
  51207. */
  51208. maxMesh?: AbstractMesh;
  51209. /**
  51210. * the mesh that defines the minimum value mesh position.
  51211. */
  51212. minMesh?: AbstractMesh;
  51213. /**
  51214. * The mesh that will be changed when axis value changes
  51215. */
  51216. valueMesh?: AbstractMesh;
  51217. }
  51218. /**
  51219. * The elements needed for change-detection of the gamepad objects in motion controllers
  51220. */
  51221. export interface IMinimalMotionControllerObject {
  51222. /**
  51223. * Available axes of this controller
  51224. */
  51225. axes: number[];
  51226. /**
  51227. * An array of available buttons
  51228. */
  51229. buttons: Array<{
  51230. /**
  51231. * Value of the button/trigger
  51232. */
  51233. value: number;
  51234. /**
  51235. * If the button/trigger is currently touched
  51236. */
  51237. touched: boolean;
  51238. /**
  51239. * If the button/trigger is currently pressed
  51240. */
  51241. pressed: boolean;
  51242. }>;
  51243. /**
  51244. * EXPERIMENTAL haptic support.
  51245. */
  51246. hapticActuators?: Array<{
  51247. pulse: (value: number, duration: number) => Promise<boolean>;
  51248. }>;
  51249. }
  51250. /**
  51251. * An Abstract Motion controller
  51252. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51253. * Each component has an observable to check for changes in value and state
  51254. */
  51255. export abstract class WebXRAbstractMotionController implements IDisposable {
  51256. protected scene: Scene;
  51257. protected layout: IMotionControllerLayout;
  51258. /**
  51259. * The gamepad object correlating to this controller
  51260. */
  51261. gamepadObject: IMinimalMotionControllerObject;
  51262. /**
  51263. * handedness (left/right/none) of this controller
  51264. */
  51265. handedness: MotionControllerHandedness;
  51266. private _initComponent;
  51267. private _modelReady;
  51268. /**
  51269. * A map of components (WebXRControllerComponent) in this motion controller
  51270. * Components have a ComponentType and can also have both button and axis definitions
  51271. */
  51272. readonly components: {
  51273. [id: string]: WebXRControllerComponent;
  51274. };
  51275. /**
  51276. * Disable the model's animation. Can be set at any time.
  51277. */
  51278. disableAnimation: boolean;
  51279. /**
  51280. * Observers registered here will be triggered when the model of this controller is done loading
  51281. */
  51282. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51283. /**
  51284. * The profile id of this motion controller
  51285. */
  51286. abstract profileId: string;
  51287. /**
  51288. * The root mesh of the model. It is null if the model was not yet initialized
  51289. */
  51290. rootMesh: Nullable<AbstractMesh>;
  51291. /**
  51292. * constructs a new abstract motion controller
  51293. * @param scene the scene to which the model of the controller will be added
  51294. * @param layout The profile layout to load
  51295. * @param gamepadObject The gamepad object correlating to this controller
  51296. * @param handedness handedness (left/right/none) of this controller
  51297. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51298. */
  51299. constructor(scene: Scene, layout: IMotionControllerLayout,
  51300. /**
  51301. * The gamepad object correlating to this controller
  51302. */
  51303. gamepadObject: IMinimalMotionControllerObject,
  51304. /**
  51305. * handedness (left/right/none) of this controller
  51306. */
  51307. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51308. /**
  51309. * Dispose this controller, the model mesh and all its components
  51310. */
  51311. dispose(): void;
  51312. /**
  51313. * Returns all components of specific type
  51314. * @param type the type to search for
  51315. * @return an array of components with this type
  51316. */
  51317. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51318. /**
  51319. * get a component based an its component id as defined in layout.components
  51320. * @param id the id of the component
  51321. * @returns the component correlates to the id or undefined if not found
  51322. */
  51323. getComponent(id: string): WebXRControllerComponent;
  51324. /**
  51325. * Get the list of components available in this motion controller
  51326. * @returns an array of strings correlating to available components
  51327. */
  51328. getComponentIds(): string[];
  51329. /**
  51330. * Get the first component of specific type
  51331. * @param type type of component to find
  51332. * @return a controller component or null if not found
  51333. */
  51334. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51335. /**
  51336. * Get the main (Select) component of this controller as defined in the layout
  51337. * @returns the main component of this controller
  51338. */
  51339. getMainComponent(): WebXRControllerComponent;
  51340. /**
  51341. * Loads the model correlating to this controller
  51342. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51343. * @returns A promise fulfilled with the result of the model loading
  51344. */
  51345. loadModel(): Promise<boolean>;
  51346. /**
  51347. * Update this model using the current XRFrame
  51348. * @param xrFrame the current xr frame to use and update the model
  51349. */
  51350. updateFromXRFrame(xrFrame: XRFrame): void;
  51351. /**
  51352. * Backwards compatibility due to a deeply-integrated typo
  51353. */
  51354. get handness(): XREye;
  51355. /**
  51356. * Pulse (vibrate) this controller
  51357. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51358. * Consecutive calls to this function will cancel the last pulse call
  51359. *
  51360. * @param value the strength of the pulse in 0.0...1.0 range
  51361. * @param duration Duration of the pulse in milliseconds
  51362. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51363. * @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
  51364. */
  51365. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51366. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51367. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51368. /**
  51369. * Moves the axis on the controller mesh based on its current state
  51370. * @param axis the index of the axis
  51371. * @param axisValue the value of the axis which determines the meshes new position
  51372. * @hidden
  51373. */
  51374. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51375. /**
  51376. * Update the model itself with the current frame data
  51377. * @param xrFrame the frame to use for updating the model mesh
  51378. */
  51379. protected updateModel(xrFrame: XRFrame): void;
  51380. /**
  51381. * Get the filename and path for this controller's model
  51382. * @returns a map of filename and path
  51383. */
  51384. protected abstract _getFilenameAndPath(): {
  51385. filename: string;
  51386. path: string;
  51387. };
  51388. /**
  51389. * This function is called before the mesh is loaded. It checks for loading constraints.
  51390. * For example, this function can check if the GLB loader is available
  51391. * If this function returns false, the generic controller will be loaded instead
  51392. * @returns Is the client ready to load the mesh
  51393. */
  51394. protected abstract _getModelLoadingConstraints(): boolean;
  51395. /**
  51396. * This function will be called after the model was successfully loaded and can be used
  51397. * for mesh transformations before it is available for the user
  51398. * @param meshes the loaded meshes
  51399. */
  51400. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51401. /**
  51402. * Set the root mesh for this controller. Important for the WebXR controller class
  51403. * @param meshes the loaded meshes
  51404. */
  51405. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51406. /**
  51407. * A function executed each frame that updates the mesh (if needed)
  51408. * @param xrFrame the current xrFrame
  51409. */
  51410. protected abstract _updateModel(xrFrame: XRFrame): void;
  51411. private _getGenericFilenameAndPath;
  51412. private _getGenericParentMesh;
  51413. }
  51414. }
  51415. declare module BABYLON {
  51416. /**
  51417. * A generic trigger-only motion controller for WebXR
  51418. */
  51419. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51420. /**
  51421. * Static version of the profile id of this controller
  51422. */
  51423. static ProfileId: string;
  51424. profileId: string;
  51425. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51426. protected _getFilenameAndPath(): {
  51427. filename: string;
  51428. path: string;
  51429. };
  51430. protected _getModelLoadingConstraints(): boolean;
  51431. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51432. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51433. protected _updateModel(): void;
  51434. }
  51435. }
  51436. declare module BABYLON {
  51437. /**
  51438. * Class containing static functions to help procedurally build meshes
  51439. */
  51440. export class SphereBuilder {
  51441. /**
  51442. * Creates a sphere mesh
  51443. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51444. * * 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`)
  51445. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51446. * * 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
  51447. * * 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)
  51448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51449. * * 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
  51450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51451. * @param name defines the name of the mesh
  51452. * @param options defines the options used to create the mesh
  51453. * @param scene defines the hosting scene
  51454. * @returns the sphere mesh
  51455. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51456. */
  51457. static CreateSphere(name: string, options: {
  51458. segments?: number;
  51459. diameter?: number;
  51460. diameterX?: number;
  51461. diameterY?: number;
  51462. diameterZ?: number;
  51463. arc?: number;
  51464. slice?: number;
  51465. sideOrientation?: number;
  51466. frontUVs?: Vector4;
  51467. backUVs?: Vector4;
  51468. updatable?: boolean;
  51469. }, scene?: Nullable<Scene>): Mesh;
  51470. }
  51471. }
  51472. declare module BABYLON {
  51473. /**
  51474. * A profiled motion controller has its profile loaded from an online repository.
  51475. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51476. */
  51477. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51478. private _repositoryUrl;
  51479. private _buttonMeshMapping;
  51480. private _touchDots;
  51481. /**
  51482. * The profile ID of this controller. Will be populated when the controller initializes.
  51483. */
  51484. profileId: string;
  51485. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51486. dispose(): void;
  51487. protected _getFilenameAndPath(): {
  51488. filename: string;
  51489. path: string;
  51490. };
  51491. protected _getModelLoadingConstraints(): boolean;
  51492. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51493. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51494. protected _updateModel(_xrFrame: XRFrame): void;
  51495. }
  51496. }
  51497. declare module BABYLON {
  51498. /**
  51499. * A construction function type to create a new controller based on an xrInput object
  51500. */
  51501. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51502. /**
  51503. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51504. *
  51505. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51506. * it should be replaced with auto-loaded controllers.
  51507. *
  51508. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51509. */
  51510. export class WebXRMotionControllerManager {
  51511. private static _AvailableControllers;
  51512. private static _Fallbacks;
  51513. private static _ProfileLoadingPromises;
  51514. private static _ProfilesList;
  51515. /**
  51516. * The base URL of the online controller repository. Can be changed at any time.
  51517. */
  51518. static BaseRepositoryUrl: string;
  51519. /**
  51520. * Which repository gets priority - local or online
  51521. */
  51522. static PrioritizeOnlineRepository: boolean;
  51523. /**
  51524. * Use the online repository, or use only locally-defined controllers
  51525. */
  51526. static UseOnlineRepository: boolean;
  51527. /**
  51528. * Clear the cache used for profile loading and reload when requested again
  51529. */
  51530. static ClearProfilesCache(): void;
  51531. /**
  51532. * Register the default fallbacks.
  51533. * This function is called automatically when this file is imported.
  51534. */
  51535. static DefaultFallbacks(): void;
  51536. /**
  51537. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51538. * @param profileId the profile to which a fallback needs to be found
  51539. * @return an array with corresponding fallback profiles
  51540. */
  51541. static FindFallbackWithProfileId(profileId: string): string[];
  51542. /**
  51543. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51544. * The order of search:
  51545. *
  51546. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51547. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51548. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51549. * 4) return the generic trigger controller if none were found
  51550. *
  51551. * @param xrInput the xrInput to which a new controller is initialized
  51552. * @param scene the scene to which the model will be added
  51553. * @param forceProfile force a certain profile for this controller
  51554. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51555. */
  51556. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51557. /**
  51558. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51559. *
  51560. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51561. *
  51562. * @param type the profile type to register
  51563. * @param constructFunction the function to be called when loading this profile
  51564. */
  51565. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51566. /**
  51567. * Register a fallback to a specific profile.
  51568. * @param profileId the profileId that will receive the fallbacks
  51569. * @param fallbacks A list of fallback profiles
  51570. */
  51571. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51572. /**
  51573. * Will update the list of profiles available in the repository
  51574. * @return a promise that resolves to a map of profiles available online
  51575. */
  51576. static UpdateProfilesList(): Promise<{
  51577. [profile: string]: string;
  51578. }>;
  51579. private static _LoadProfileFromRepository;
  51580. private static _LoadProfilesFromAvailableControllers;
  51581. }
  51582. }
  51583. declare module BABYLON {
  51584. /**
  51585. * Configuration options for the WebXR controller creation
  51586. */
  51587. export interface IWebXRControllerOptions {
  51588. /**
  51589. * Should the controller mesh be animated when a user interacts with it
  51590. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51591. */
  51592. disableMotionControllerAnimation?: boolean;
  51593. /**
  51594. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51595. */
  51596. doNotLoadControllerMesh?: boolean;
  51597. /**
  51598. * Force a specific controller type for this controller.
  51599. * This can be used when creating your own profile or when testing different controllers
  51600. */
  51601. forceControllerProfile?: string;
  51602. /**
  51603. * Defines a rendering group ID for meshes that will be loaded.
  51604. * This is for the default controllers only.
  51605. */
  51606. renderingGroupId?: number;
  51607. }
  51608. /**
  51609. * Represents an XR controller
  51610. */
  51611. export class WebXRInputSource {
  51612. private _scene;
  51613. /** The underlying input source for the controller */
  51614. inputSource: XRInputSource;
  51615. private _options;
  51616. private _tmpVector;
  51617. private _uniqueId;
  51618. private _disposed;
  51619. /**
  51620. * 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
  51621. */
  51622. grip?: AbstractMesh;
  51623. /**
  51624. * If available, this is the gamepad object related to this controller.
  51625. * Using this object it is possible to get click events and trackpad changes of the
  51626. * webxr controller that is currently being used.
  51627. */
  51628. motionController?: WebXRAbstractMotionController;
  51629. /**
  51630. * Event that fires when the controller is removed/disposed.
  51631. * The object provided as event data is this controller, after associated assets were disposed.
  51632. * uniqueId is still available.
  51633. */
  51634. onDisposeObservable: Observable<WebXRInputSource>;
  51635. /**
  51636. * Will be triggered when the mesh associated with the motion controller is done loading.
  51637. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51638. * A shortened version of controller -> motion controller -> on mesh loaded.
  51639. */
  51640. onMeshLoadedObservable: Observable<AbstractMesh>;
  51641. /**
  51642. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51643. */
  51644. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51645. /**
  51646. * Pointer which can be used to select objects or attach a visible laser to
  51647. */
  51648. pointer: AbstractMesh;
  51649. /**
  51650. * Creates the input source object
  51651. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51652. * @param _scene the scene which the controller should be associated to
  51653. * @param inputSource the underlying input source for the controller
  51654. * @param _options options for this controller creation
  51655. */
  51656. constructor(_scene: Scene,
  51657. /** The underlying input source for the controller */
  51658. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51659. /**
  51660. * Get this controllers unique id
  51661. */
  51662. get uniqueId(): string;
  51663. /**
  51664. * Disposes of the object
  51665. */
  51666. dispose(): void;
  51667. /**
  51668. * Gets a world space ray coming from the pointer or grip
  51669. * @param result the resulting ray
  51670. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51671. */
  51672. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51673. /**
  51674. * Updates the controller pose based on the given XRFrame
  51675. * @param xrFrame xr frame to update the pose with
  51676. * @param referenceSpace reference space to use
  51677. */
  51678. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51679. }
  51680. }
  51681. declare module BABYLON {
  51682. /**
  51683. * The schema for initialization options of the XR Input class
  51684. */
  51685. export interface IWebXRInputOptions {
  51686. /**
  51687. * If set to true no model will be automatically loaded
  51688. */
  51689. doNotLoadControllerMeshes?: boolean;
  51690. /**
  51691. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51692. * If not found, the xr input profile data will be used.
  51693. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51694. */
  51695. forceInputProfile?: string;
  51696. /**
  51697. * Do not send a request to the controller repository to load the profile.
  51698. *
  51699. * Instead, use the controllers available in babylon itself.
  51700. */
  51701. disableOnlineControllerRepository?: boolean;
  51702. /**
  51703. * A custom URL for the controllers repository
  51704. */
  51705. customControllersRepositoryURL?: string;
  51706. /**
  51707. * Should the controller model's components not move according to the user input
  51708. */
  51709. disableControllerAnimation?: boolean;
  51710. /**
  51711. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51712. */
  51713. controllerOptions?: IWebXRControllerOptions;
  51714. }
  51715. /**
  51716. * XR input used to track XR inputs such as controllers/rays
  51717. */
  51718. export class WebXRInput implements IDisposable {
  51719. /**
  51720. * the xr session manager for this session
  51721. */
  51722. xrSessionManager: WebXRSessionManager;
  51723. /**
  51724. * the WebXR camera for this session. Mainly used for teleportation
  51725. */
  51726. xrCamera: WebXRCamera;
  51727. private readonly options;
  51728. /**
  51729. * XR controllers being tracked
  51730. */
  51731. controllers: Array<WebXRInputSource>;
  51732. private _frameObserver;
  51733. private _sessionEndedObserver;
  51734. private _sessionInitObserver;
  51735. /**
  51736. * Event when a controller has been connected/added
  51737. */
  51738. onControllerAddedObservable: Observable<WebXRInputSource>;
  51739. /**
  51740. * Event when a controller has been removed/disconnected
  51741. */
  51742. onControllerRemovedObservable: Observable<WebXRInputSource>;
  51743. /**
  51744. * Initializes the WebXRInput
  51745. * @param xrSessionManager the xr session manager for this session
  51746. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  51747. * @param options = initialization options for this xr input
  51748. */
  51749. constructor(
  51750. /**
  51751. * the xr session manager for this session
  51752. */
  51753. xrSessionManager: WebXRSessionManager,
  51754. /**
  51755. * the WebXR camera for this session. Mainly used for teleportation
  51756. */
  51757. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  51758. private _onInputSourcesChange;
  51759. private _addAndRemoveControllers;
  51760. /**
  51761. * Disposes of the object
  51762. */
  51763. dispose(): void;
  51764. }
  51765. }
  51766. declare module BABYLON {
  51767. /**
  51768. * This is the base class for all WebXR features.
  51769. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  51770. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  51771. */
  51772. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  51773. protected _xrSessionManager: WebXRSessionManager;
  51774. private _attached;
  51775. private _removeOnDetach;
  51776. /**
  51777. * Is this feature disposed?
  51778. */
  51779. isDisposed: boolean;
  51780. /**
  51781. * Should auto-attach be disabled?
  51782. */
  51783. disableAutoAttach: boolean;
  51784. /**
  51785. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  51786. */
  51787. xrNativeFeatureName: string;
  51788. /**
  51789. * Construct a new (abstract) WebXR feature
  51790. * @param _xrSessionManager the xr session manager for this feature
  51791. */
  51792. constructor(_xrSessionManager: WebXRSessionManager);
  51793. /**
  51794. * Is this feature attached
  51795. */
  51796. get attached(): boolean;
  51797. /**
  51798. * attach this feature
  51799. *
  51800. * @param force should attachment be forced (even when already attached)
  51801. * @returns true if successful, false is failed or already attached
  51802. */
  51803. attach(force?: boolean): boolean;
  51804. /**
  51805. * detach this feature.
  51806. *
  51807. * @returns true if successful, false if failed or already detached
  51808. */
  51809. detach(): boolean;
  51810. /**
  51811. * Dispose this feature and all of the resources attached
  51812. */
  51813. dispose(): void;
  51814. /**
  51815. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  51816. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  51817. *
  51818. * @returns whether or not the feature is compatible in this environment
  51819. */
  51820. isCompatible(): boolean;
  51821. /**
  51822. * This is used to register callbacks that will automatically be removed when detach is called.
  51823. * @param observable the observable to which the observer will be attached
  51824. * @param callback the callback to register
  51825. */
  51826. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  51827. /**
  51828. * Code in this function will be executed on each xrFrame received from the browser.
  51829. * This function will not execute after the feature is detached.
  51830. * @param _xrFrame the current frame
  51831. */
  51832. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  51833. }
  51834. }
  51835. declare module BABYLON {
  51836. /**
  51837. * Renders a layer on top of an existing scene
  51838. */
  51839. export class UtilityLayerRenderer implements IDisposable {
  51840. /** the original scene that will be rendered on top of */
  51841. originalScene: Scene;
  51842. private _pointerCaptures;
  51843. private _lastPointerEvents;
  51844. private static _DefaultUtilityLayer;
  51845. private static _DefaultKeepDepthUtilityLayer;
  51846. private _sharedGizmoLight;
  51847. private _renderCamera;
  51848. /**
  51849. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  51850. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  51851. * @returns the camera that is used when rendering the utility layer
  51852. */
  51853. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  51854. /**
  51855. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  51856. * @param cam the camera that should be used when rendering the utility layer
  51857. */
  51858. setRenderCamera(cam: Nullable<Camera>): void;
  51859. /**
  51860. * @hidden
  51861. * Light which used by gizmos to get light shading
  51862. */
  51863. _getSharedGizmoLight(): HemisphericLight;
  51864. /**
  51865. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  51866. */
  51867. pickUtilitySceneFirst: boolean;
  51868. /**
  51869. * 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)
  51870. */
  51871. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  51872. /**
  51873. * 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)
  51874. */
  51875. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  51876. /**
  51877. * The scene that is rendered on top of the original scene
  51878. */
  51879. utilityLayerScene: Scene;
  51880. /**
  51881. * If the utility layer should automatically be rendered on top of existing scene
  51882. */
  51883. shouldRender: boolean;
  51884. /**
  51885. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  51886. */
  51887. onlyCheckPointerDownEvents: boolean;
  51888. /**
  51889. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  51890. */
  51891. processAllEvents: boolean;
  51892. /**
  51893. * Observable raised when the pointer move from the utility layer scene to the main scene
  51894. */
  51895. onPointerOutObservable: Observable<number>;
  51896. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  51897. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  51898. private _afterRenderObserver;
  51899. private _sceneDisposeObserver;
  51900. private _originalPointerObserver;
  51901. /**
  51902. * Instantiates a UtilityLayerRenderer
  51903. * @param originalScene the original scene that will be rendered on top of
  51904. * @param handleEvents boolean indicating if the utility layer should handle events
  51905. */
  51906. constructor(
  51907. /** the original scene that will be rendered on top of */
  51908. originalScene: Scene, handleEvents?: boolean);
  51909. private _notifyObservers;
  51910. /**
  51911. * Renders the utility layers scene on top of the original scene
  51912. */
  51913. render(): void;
  51914. /**
  51915. * Disposes of the renderer
  51916. */
  51917. dispose(): void;
  51918. private _updateCamera;
  51919. }
  51920. }
  51921. declare module BABYLON {
  51922. /**
  51923. * Options interface for the pointer selection module
  51924. */
  51925. export interface IWebXRControllerPointerSelectionOptions {
  51926. /**
  51927. * if provided, this scene will be used to render meshes.
  51928. */
  51929. customUtilityLayerScene?: Scene;
  51930. /**
  51931. * 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)
  51932. * If not disabled, the last picked point will be used to execute a pointer up event
  51933. * If disabled, pointer up event will be triggered right after the pointer down event.
  51934. * Used in screen and gaze target ray mode only
  51935. */
  51936. disablePointerUpOnTouchOut: boolean;
  51937. /**
  51938. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  51939. */
  51940. forceGazeMode: boolean;
  51941. /**
  51942. * 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
  51943. * to start a new countdown to the pointer down event.
  51944. * Defaults to 1.
  51945. */
  51946. gazeModePointerMovedFactor?: number;
  51947. /**
  51948. * Different button type to use instead of the main component
  51949. */
  51950. overrideButtonId?: string;
  51951. /**
  51952. * use this rendering group id for the meshes (optional)
  51953. */
  51954. renderingGroupId?: number;
  51955. /**
  51956. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  51957. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  51958. * 3000 means 3 seconds between pointing at something and selecting it
  51959. */
  51960. timeToSelect?: number;
  51961. /**
  51962. * Should meshes created here be added to a utility layer or the main scene
  51963. */
  51964. useUtilityLayer?: boolean;
  51965. /**
  51966. * Optional WebXR camera to be used for gaze selection
  51967. */
  51968. gazeCamera?: WebXRCamera;
  51969. /**
  51970. * the xr input to use with this pointer selection
  51971. */
  51972. xrInput: WebXRInput;
  51973. /**
  51974. * Should the scene pointerX and pointerY update be disabled
  51975. * This is required for fullscreen AR GUI, but might slow down other experiences.
  51976. * Disable in VR, if not needed.
  51977. * The first rig camera (left eye) will be used to calculate the projection
  51978. */
  51979. disableScenePointerVectorUpdate: boolean;
  51980. }
  51981. /**
  51982. * A module that will enable pointer selection for motion controllers of XR Input Sources
  51983. */
  51984. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  51985. private readonly _options;
  51986. private static _idCounter;
  51987. private _attachController;
  51988. private _controllers;
  51989. private _scene;
  51990. private _tmpVectorForPickCompare;
  51991. /**
  51992. * The module's name
  51993. */
  51994. static readonly Name: string;
  51995. /**
  51996. * The (Babylon) version of this module.
  51997. * This is an integer representing the implementation version.
  51998. * This number does not correspond to the WebXR specs version
  51999. */
  52000. static readonly Version: number;
  52001. /**
  52002. * Disable lighting on the laser pointer (so it will always be visible)
  52003. */
  52004. disablePointerLighting: boolean;
  52005. /**
  52006. * Disable lighting on the selection mesh (so it will always be visible)
  52007. */
  52008. disableSelectionMeshLighting: boolean;
  52009. /**
  52010. * Should the laser pointer be displayed
  52011. */
  52012. displayLaserPointer: boolean;
  52013. /**
  52014. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52015. */
  52016. displaySelectionMesh: boolean;
  52017. /**
  52018. * This color will be set to the laser pointer when selection is triggered
  52019. */
  52020. laserPointerPickedColor: Color3;
  52021. /**
  52022. * Default color of the laser pointer
  52023. */
  52024. laserPointerDefaultColor: Color3;
  52025. /**
  52026. * default color of the selection ring
  52027. */
  52028. selectionMeshDefaultColor: Color3;
  52029. /**
  52030. * This color will be applied to the selection ring when selection is triggered
  52031. */
  52032. selectionMeshPickedColor: Color3;
  52033. /**
  52034. * Optional filter to be used for ray selection. This predicate shares behavior with
  52035. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52036. */
  52037. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52038. /**
  52039. * constructs a new background remover module
  52040. * @param _xrSessionManager the session manager for this module
  52041. * @param _options read-only options to be used in this module
  52042. */
  52043. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52044. /**
  52045. * attach this feature
  52046. * Will usually be called by the features manager
  52047. *
  52048. * @returns true if successful.
  52049. */
  52050. attach(): boolean;
  52051. /**
  52052. * detach this feature.
  52053. * Will usually be called by the features manager
  52054. *
  52055. * @returns true if successful.
  52056. */
  52057. detach(): boolean;
  52058. /**
  52059. * Will get the mesh under a specific pointer.
  52060. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52061. * @param controllerId the controllerId to check
  52062. * @returns The mesh under pointer or null if no mesh is under the pointer
  52063. */
  52064. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52065. /**
  52066. * Get the xr controller that correlates to the pointer id in the pointer event
  52067. *
  52068. * @param id the pointer id to search for
  52069. * @returns the controller that correlates to this id or null if not found
  52070. */
  52071. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52072. private _identityMatrix;
  52073. private _screenCoordinatesRef;
  52074. private _viewportRef;
  52075. protected _onXRFrame(_xrFrame: XRFrame): void;
  52076. private _attachGazeMode;
  52077. private _attachScreenRayMode;
  52078. private _attachTrackedPointerRayMode;
  52079. private _convertNormalToDirectionOfRay;
  52080. private _detachController;
  52081. private _generateNewMeshPair;
  52082. private _pickingMoved;
  52083. private _updatePointerDistance;
  52084. /** @hidden */
  52085. get lasterPointerDefaultColor(): Color3;
  52086. }
  52087. }
  52088. declare module BABYLON {
  52089. /**
  52090. * Button which can be used to enter a different mode of XR
  52091. */
  52092. export class WebXREnterExitUIButton {
  52093. /** button element */
  52094. element: HTMLElement;
  52095. /** XR initialization options for the button */
  52096. sessionMode: XRSessionMode;
  52097. /** Reference space type */
  52098. referenceSpaceType: XRReferenceSpaceType;
  52099. /**
  52100. * Creates a WebXREnterExitUIButton
  52101. * @param element button element
  52102. * @param sessionMode XR initialization session mode
  52103. * @param referenceSpaceType the type of reference space to be used
  52104. */
  52105. constructor(
  52106. /** button element */
  52107. element: HTMLElement,
  52108. /** XR initialization options for the button */
  52109. sessionMode: XRSessionMode,
  52110. /** Reference space type */
  52111. referenceSpaceType: XRReferenceSpaceType);
  52112. /**
  52113. * Extendable function which can be used to update the button's visuals when the state changes
  52114. * @param activeButton the current active button in the UI
  52115. */
  52116. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52117. }
  52118. /**
  52119. * Options to create the webXR UI
  52120. */
  52121. export class WebXREnterExitUIOptions {
  52122. /**
  52123. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52124. */
  52125. customButtons?: Array<WebXREnterExitUIButton>;
  52126. /**
  52127. * A reference space type to use when creating the default button.
  52128. * Default is local-floor
  52129. */
  52130. referenceSpaceType?: XRReferenceSpaceType;
  52131. /**
  52132. * Context to enter xr with
  52133. */
  52134. renderTarget?: Nullable<WebXRRenderTarget>;
  52135. /**
  52136. * A session mode to use when creating the default button.
  52137. * Default is immersive-vr
  52138. */
  52139. sessionMode?: XRSessionMode;
  52140. /**
  52141. * A list of optional features to init the session with
  52142. */
  52143. optionalFeatures?: string[];
  52144. /**
  52145. * A list of optional features to init the session with
  52146. */
  52147. requiredFeatures?: string[];
  52148. }
  52149. /**
  52150. * UI to allow the user to enter/exit XR mode
  52151. */
  52152. export class WebXREnterExitUI implements IDisposable {
  52153. private scene;
  52154. /** version of the options passed to this UI */
  52155. options: WebXREnterExitUIOptions;
  52156. private _activeButton;
  52157. private _buttons;
  52158. /**
  52159. * The HTML Div Element to which buttons are added.
  52160. */
  52161. readonly overlay: HTMLDivElement;
  52162. /**
  52163. * Fired every time the active button is changed.
  52164. *
  52165. * When xr is entered via a button that launches xr that button will be the callback parameter
  52166. *
  52167. * When exiting xr the callback parameter will be null)
  52168. */
  52169. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52170. /**
  52171. *
  52172. * @param scene babylon scene object to use
  52173. * @param options (read-only) version of the options passed to this UI
  52174. */
  52175. private constructor();
  52176. /**
  52177. * Creates UI to allow the user to enter/exit XR mode
  52178. * @param scene the scene to add the ui to
  52179. * @param helper the xr experience helper to enter/exit xr with
  52180. * @param options options to configure the UI
  52181. * @returns the created ui
  52182. */
  52183. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52184. /**
  52185. * Disposes of the XR UI component
  52186. */
  52187. dispose(): void;
  52188. private _updateButtons;
  52189. }
  52190. }
  52191. declare module BABYLON {
  52192. /**
  52193. * Class containing static functions to help procedurally build meshes
  52194. */
  52195. export class LinesBuilder {
  52196. /**
  52197. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52198. * * 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
  52199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52200. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52201. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52202. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52204. * * 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
  52205. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52208. * @param name defines the name of the new line system
  52209. * @param options defines the options used to create the line system
  52210. * @param scene defines the hosting scene
  52211. * @returns a new line system mesh
  52212. */
  52213. static CreateLineSystem(name: string, options: {
  52214. lines: Vector3[][];
  52215. updatable?: boolean;
  52216. instance?: Nullable<LinesMesh>;
  52217. colors?: Nullable<Color4[][]>;
  52218. useVertexAlpha?: boolean;
  52219. }, scene: Nullable<Scene>): LinesMesh;
  52220. /**
  52221. * Creates a line mesh
  52222. * 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
  52223. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52224. * * The parameter `points` is an array successive Vector3
  52225. * * 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
  52226. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52227. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52228. * * When updating an instance, remember that only point positions can change, not the number of points
  52229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52231. * @param name defines the name of the new line system
  52232. * @param options defines the options used to create the line system
  52233. * @param scene defines the hosting scene
  52234. * @returns a new line mesh
  52235. */
  52236. static CreateLines(name: string, options: {
  52237. points: Vector3[];
  52238. updatable?: boolean;
  52239. instance?: Nullable<LinesMesh>;
  52240. colors?: Color4[];
  52241. useVertexAlpha?: boolean;
  52242. }, scene?: Nullable<Scene>): LinesMesh;
  52243. /**
  52244. * Creates a dashed line mesh
  52245. * * 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
  52246. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52247. * * The parameter `points` is an array successive Vector3
  52248. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52249. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52250. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52251. * * 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
  52252. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52253. * * When updating an instance, remember that only point positions can change, not the number of points
  52254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52255. * @param name defines the name of the mesh
  52256. * @param options defines the options used to create the mesh
  52257. * @param scene defines the hosting scene
  52258. * @returns the dashed line mesh
  52259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52260. */
  52261. static CreateDashedLines(name: string, options: {
  52262. points: Vector3[];
  52263. dashSize?: number;
  52264. gapSize?: number;
  52265. dashNb?: number;
  52266. updatable?: boolean;
  52267. instance?: LinesMesh;
  52268. useVertexAlpha?: boolean;
  52269. }, scene?: Nullable<Scene>): LinesMesh;
  52270. }
  52271. }
  52272. declare module BABYLON {
  52273. /**
  52274. * Construction options for a timer
  52275. */
  52276. export interface ITimerOptions<T> {
  52277. /**
  52278. * Time-to-end
  52279. */
  52280. timeout: number;
  52281. /**
  52282. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52283. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52284. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52285. */
  52286. contextObservable: Observable<T>;
  52287. /**
  52288. * Optional parameters when adding an observer to the observable
  52289. */
  52290. observableParameters?: {
  52291. mask?: number;
  52292. insertFirst?: boolean;
  52293. scope?: any;
  52294. };
  52295. /**
  52296. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52297. */
  52298. breakCondition?: (data?: ITimerData<T>) => boolean;
  52299. /**
  52300. * Will be triggered when the time condition has met
  52301. */
  52302. onEnded?: (data: ITimerData<any>) => void;
  52303. /**
  52304. * Will be triggered when the break condition has met (prematurely ended)
  52305. */
  52306. onAborted?: (data: ITimerData<any>) => void;
  52307. /**
  52308. * Optional function to execute on each tick (or count)
  52309. */
  52310. onTick?: (data: ITimerData<any>) => void;
  52311. }
  52312. /**
  52313. * An interface defining the data sent by the timer
  52314. */
  52315. export interface ITimerData<T> {
  52316. /**
  52317. * When did it start
  52318. */
  52319. startTime: number;
  52320. /**
  52321. * Time now
  52322. */
  52323. currentTime: number;
  52324. /**
  52325. * Time passed since started
  52326. */
  52327. deltaTime: number;
  52328. /**
  52329. * How much is completed, in [0.0...1.0].
  52330. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52331. */
  52332. completeRate: number;
  52333. /**
  52334. * What the registered observable sent in the last count
  52335. */
  52336. payload: T;
  52337. }
  52338. /**
  52339. * The current state of the timer
  52340. */
  52341. export enum TimerState {
  52342. /**
  52343. * Timer initialized, not yet started
  52344. */
  52345. INIT = 0,
  52346. /**
  52347. * Timer started and counting
  52348. */
  52349. STARTED = 1,
  52350. /**
  52351. * Timer ended (whether aborted or time reached)
  52352. */
  52353. ENDED = 2
  52354. }
  52355. /**
  52356. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52357. *
  52358. * @param options options with which to initialize this timer
  52359. */
  52360. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52361. /**
  52362. * An advanced implementation of a timer class
  52363. */
  52364. export class AdvancedTimer<T = any> implements IDisposable {
  52365. /**
  52366. * Will notify each time the timer calculates the remaining time
  52367. */
  52368. onEachCountObservable: Observable<ITimerData<T>>;
  52369. /**
  52370. * Will trigger when the timer was aborted due to the break condition
  52371. */
  52372. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52373. /**
  52374. * Will trigger when the timer ended successfully
  52375. */
  52376. onTimerEndedObservable: Observable<ITimerData<T>>;
  52377. /**
  52378. * Will trigger when the timer state has changed
  52379. */
  52380. onStateChangedObservable: Observable<TimerState>;
  52381. private _observer;
  52382. private _contextObservable;
  52383. private _observableParameters;
  52384. private _startTime;
  52385. private _timer;
  52386. private _state;
  52387. private _breakCondition;
  52388. private _timeToEnd;
  52389. private _breakOnNextTick;
  52390. /**
  52391. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52392. * @param options construction options for this advanced timer
  52393. */
  52394. constructor(options: ITimerOptions<T>);
  52395. /**
  52396. * set a breaking condition for this timer. Default is to never break during count
  52397. * @param predicate the new break condition. Returns true to break, false otherwise
  52398. */
  52399. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52400. /**
  52401. * Reset ALL associated observables in this advanced timer
  52402. */
  52403. clearObservables(): void;
  52404. /**
  52405. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52406. *
  52407. * @param timeToEnd how much time to measure until timer ended
  52408. */
  52409. start(timeToEnd?: number): void;
  52410. /**
  52411. * Will force a stop on the next tick.
  52412. */
  52413. stop(): void;
  52414. /**
  52415. * Dispose this timer, clearing all resources
  52416. */
  52417. dispose(): void;
  52418. private _setState;
  52419. private _tick;
  52420. private _stop;
  52421. }
  52422. }
  52423. declare module BABYLON {
  52424. /**
  52425. * The options container for the teleportation module
  52426. */
  52427. export interface IWebXRTeleportationOptions {
  52428. /**
  52429. * if provided, this scene will be used to render meshes.
  52430. */
  52431. customUtilityLayerScene?: Scene;
  52432. /**
  52433. * Values to configure the default target mesh
  52434. */
  52435. defaultTargetMeshOptions?: {
  52436. /**
  52437. * Fill color of the teleportation area
  52438. */
  52439. teleportationFillColor?: string;
  52440. /**
  52441. * Border color for the teleportation area
  52442. */
  52443. teleportationBorderColor?: string;
  52444. /**
  52445. * Disable the mesh's animation sequence
  52446. */
  52447. disableAnimation?: boolean;
  52448. /**
  52449. * Disable lighting on the material or the ring and arrow
  52450. */
  52451. disableLighting?: boolean;
  52452. /**
  52453. * Override the default material of the torus and arrow
  52454. */
  52455. torusArrowMaterial?: Material;
  52456. };
  52457. /**
  52458. * A list of meshes to use as floor meshes.
  52459. * Meshes can be added and removed after initializing the feature using the
  52460. * addFloorMesh and removeFloorMesh functions
  52461. * If empty, rotation will still work
  52462. */
  52463. floorMeshes?: AbstractMesh[];
  52464. /**
  52465. * use this rendering group id for the meshes (optional)
  52466. */
  52467. renderingGroupId?: number;
  52468. /**
  52469. * Should teleportation move only to snap points
  52470. */
  52471. snapPointsOnly?: boolean;
  52472. /**
  52473. * An array of points to which the teleportation will snap to.
  52474. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52475. */
  52476. snapPositions?: Vector3[];
  52477. /**
  52478. * How close should the teleportation ray be in order to snap to position.
  52479. * Default to 0.8 units (meters)
  52480. */
  52481. snapToPositionRadius?: number;
  52482. /**
  52483. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52484. * If you want to support rotation, make sure your mesh has a direction indicator.
  52485. *
  52486. * When left untouched, the default mesh will be initialized.
  52487. */
  52488. teleportationTargetMesh?: AbstractMesh;
  52489. /**
  52490. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52491. */
  52492. timeToTeleport?: number;
  52493. /**
  52494. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52495. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52496. */
  52497. useMainComponentOnly?: boolean;
  52498. /**
  52499. * Should meshes created here be added to a utility layer or the main scene
  52500. */
  52501. useUtilityLayer?: boolean;
  52502. /**
  52503. * Babylon XR Input class for controller
  52504. */
  52505. xrInput: WebXRInput;
  52506. /**
  52507. * Meshes that the teleportation ray cannot go through
  52508. */
  52509. pickBlockerMeshes?: AbstractMesh[];
  52510. }
  52511. /**
  52512. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52513. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52514. * the input of the attached controllers.
  52515. */
  52516. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52517. private _options;
  52518. private _controllers;
  52519. private _currentTeleportationControllerId;
  52520. private _floorMeshes;
  52521. private _quadraticBezierCurve;
  52522. private _selectionFeature;
  52523. private _snapToPositions;
  52524. private _snappedToPoint;
  52525. private _teleportationRingMaterial?;
  52526. private _tmpRay;
  52527. private _tmpVector;
  52528. private _tmpQuaternion;
  52529. /**
  52530. * The module's name
  52531. */
  52532. static readonly Name: string;
  52533. /**
  52534. * The (Babylon) version of this module.
  52535. * This is an integer representing the implementation version.
  52536. * This number does not correspond to the webxr specs version
  52537. */
  52538. static readonly Version: number;
  52539. /**
  52540. * Is movement backwards enabled
  52541. */
  52542. backwardsMovementEnabled: boolean;
  52543. /**
  52544. * Distance to travel when moving backwards
  52545. */
  52546. backwardsTeleportationDistance: number;
  52547. /**
  52548. * The distance from the user to the inspection point in the direction of the controller
  52549. * A higher number will allow the user to move further
  52550. * defaults to 5 (meters, in xr units)
  52551. */
  52552. parabolicCheckRadius: number;
  52553. /**
  52554. * Should the module support parabolic ray on top of direct ray
  52555. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52556. * Very helpful when moving between floors / different heights
  52557. */
  52558. parabolicRayEnabled: boolean;
  52559. /**
  52560. * How much rotation should be applied when rotating right and left
  52561. */
  52562. rotationAngle: number;
  52563. /**
  52564. * Is rotation enabled when moving forward?
  52565. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52566. */
  52567. rotationEnabled: boolean;
  52568. /**
  52569. * constructs a new anchor system
  52570. * @param _xrSessionManager an instance of WebXRSessionManager
  52571. * @param _options configuration object for this feature
  52572. */
  52573. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52574. /**
  52575. * Get the snapPointsOnly flag
  52576. */
  52577. get snapPointsOnly(): boolean;
  52578. /**
  52579. * Sets the snapPointsOnly flag
  52580. * @param snapToPoints should teleportation be exclusively to snap points
  52581. */
  52582. set snapPointsOnly(snapToPoints: boolean);
  52583. /**
  52584. * Add a new mesh to the floor meshes array
  52585. * @param mesh the mesh to use as floor mesh
  52586. */
  52587. addFloorMesh(mesh: AbstractMesh): void;
  52588. /**
  52589. * Add a new snap-to point to fix teleportation to this position
  52590. * @param newSnapPoint The new Snap-To point
  52591. */
  52592. addSnapPoint(newSnapPoint: Vector3): void;
  52593. attach(): boolean;
  52594. detach(): boolean;
  52595. dispose(): void;
  52596. /**
  52597. * Remove a mesh from the floor meshes array
  52598. * @param mesh the mesh to remove
  52599. */
  52600. removeFloorMesh(mesh: AbstractMesh): void;
  52601. /**
  52602. * Remove a mesh from the floor meshes array using its name
  52603. * @param name the mesh name to remove
  52604. */
  52605. removeFloorMeshByName(name: string): void;
  52606. /**
  52607. * 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
  52608. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52609. * @returns was the point found and removed or not
  52610. */
  52611. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52612. /**
  52613. * This function sets a selection feature that will be disabled when
  52614. * the forward ray is shown and will be reattached when hidden.
  52615. * This is used to remove the selection rays when moving.
  52616. * @param selectionFeature the feature to disable when forward movement is enabled
  52617. */
  52618. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52619. protected _onXRFrame(_xrFrame: XRFrame): void;
  52620. private _attachController;
  52621. private _createDefaultTargetMesh;
  52622. private _detachController;
  52623. private _findClosestSnapPointWithRadius;
  52624. private _setTargetMeshPosition;
  52625. private _setTargetMeshVisibility;
  52626. private _showParabolicPath;
  52627. private _teleportForward;
  52628. }
  52629. }
  52630. declare module BABYLON {
  52631. /**
  52632. * Options for the default xr helper
  52633. */
  52634. export class WebXRDefaultExperienceOptions {
  52635. /**
  52636. * Enable or disable default UI to enter XR
  52637. */
  52638. disableDefaultUI?: boolean;
  52639. /**
  52640. * Should teleportation not initialize. defaults to false.
  52641. */
  52642. disableTeleportation?: boolean;
  52643. /**
  52644. * Floor meshes that will be used for teleport
  52645. */
  52646. floorMeshes?: Array<AbstractMesh>;
  52647. /**
  52648. * If set to true, the first frame will not be used to reset position
  52649. * The first frame is mainly used when copying transformation from the old camera
  52650. * Mainly used in AR
  52651. */
  52652. ignoreNativeCameraTransformation?: boolean;
  52653. /**
  52654. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52655. */
  52656. inputOptions?: IWebXRInputOptions;
  52657. /**
  52658. * optional configuration for the output canvas
  52659. */
  52660. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52661. /**
  52662. * optional UI options. This can be used among other to change session mode and reference space type
  52663. */
  52664. uiOptions?: WebXREnterExitUIOptions;
  52665. /**
  52666. * When loading teleportation and pointer select, use stable versions instead of latest.
  52667. */
  52668. useStablePlugins?: boolean;
  52669. /**
  52670. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52671. */
  52672. renderingGroupId?: number;
  52673. /**
  52674. * A list of optional features to init the session with
  52675. * If set to true, all features we support will be added
  52676. */
  52677. optionalFeatures?: boolean | string[];
  52678. }
  52679. /**
  52680. * Default experience which provides a similar setup to the previous webVRExperience
  52681. */
  52682. export class WebXRDefaultExperience {
  52683. /**
  52684. * Base experience
  52685. */
  52686. baseExperience: WebXRExperienceHelper;
  52687. /**
  52688. * Enables ui for entering/exiting xr
  52689. */
  52690. enterExitUI: WebXREnterExitUI;
  52691. /**
  52692. * Input experience extension
  52693. */
  52694. input: WebXRInput;
  52695. /**
  52696. * Enables laser pointer and selection
  52697. */
  52698. pointerSelection: WebXRControllerPointerSelection;
  52699. /**
  52700. * Default target xr should render to
  52701. */
  52702. renderTarget: WebXRRenderTarget;
  52703. /**
  52704. * Enables teleportation
  52705. */
  52706. teleportation: WebXRMotionControllerTeleportation;
  52707. private constructor();
  52708. /**
  52709. * Creates the default xr experience
  52710. * @param scene scene
  52711. * @param options options for basic configuration
  52712. * @returns resulting WebXRDefaultExperience
  52713. */
  52714. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52715. /**
  52716. * DIsposes of the experience helper
  52717. */
  52718. dispose(): void;
  52719. }
  52720. }
  52721. declare module BABYLON {
  52722. /**
  52723. * Options to modify the vr teleportation behavior.
  52724. */
  52725. export interface VRTeleportationOptions {
  52726. /**
  52727. * The name of the mesh which should be used as the teleportation floor. (default: null)
  52728. */
  52729. floorMeshName?: string;
  52730. /**
  52731. * A list of meshes to be used as the teleportation floor. (default: empty)
  52732. */
  52733. floorMeshes?: Mesh[];
  52734. /**
  52735. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  52736. */
  52737. teleportationMode?: number;
  52738. /**
  52739. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  52740. */
  52741. teleportationTime?: number;
  52742. /**
  52743. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  52744. */
  52745. teleportationSpeed?: number;
  52746. /**
  52747. * The easing function used in the animation or null for Linear. (default CircleEase)
  52748. */
  52749. easingFunction?: EasingFunction;
  52750. }
  52751. /**
  52752. * Options to modify the vr experience helper's behavior.
  52753. */
  52754. export interface VRExperienceHelperOptions extends WebVROptions {
  52755. /**
  52756. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  52757. */
  52758. createDeviceOrientationCamera?: boolean;
  52759. /**
  52760. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  52761. */
  52762. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  52763. /**
  52764. * Uses the main button on the controller to toggle the laser casted. (default: true)
  52765. */
  52766. laserToggle?: boolean;
  52767. /**
  52768. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  52769. */
  52770. floorMeshes?: Mesh[];
  52771. /**
  52772. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  52773. */
  52774. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  52775. /**
  52776. * Defines if WebXR should be used instead of WebVR (if available)
  52777. */
  52778. useXR?: boolean;
  52779. }
  52780. /**
  52781. * Event containing information after VR has been entered
  52782. */
  52783. export class OnAfterEnteringVRObservableEvent {
  52784. /**
  52785. * If entering vr was successful
  52786. */
  52787. success: boolean;
  52788. }
  52789. /**
  52790. * Helps to quickly add VR support to an existing scene.
  52791. * See https://doc.babylonjs.com/how_to/webvr_helper
  52792. */
  52793. export class VRExperienceHelper {
  52794. /** Options to modify the vr experience helper's behavior. */
  52795. webVROptions: VRExperienceHelperOptions;
  52796. private _scene;
  52797. private _position;
  52798. private _btnVR;
  52799. private _btnVRDisplayed;
  52800. private _webVRsupported;
  52801. private _webVRready;
  52802. private _webVRrequesting;
  52803. private _webVRpresenting;
  52804. private _hasEnteredVR;
  52805. private _fullscreenVRpresenting;
  52806. private _inputElement;
  52807. private _webVRCamera;
  52808. private _vrDeviceOrientationCamera;
  52809. private _deviceOrientationCamera;
  52810. private _existingCamera;
  52811. private _onKeyDown;
  52812. private _onVrDisplayPresentChange;
  52813. private _onVRDisplayChanged;
  52814. private _onVRRequestPresentStart;
  52815. private _onVRRequestPresentComplete;
  52816. /**
  52817. * 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)
  52818. */
  52819. enableGazeEvenWhenNoPointerLock: boolean;
  52820. /**
  52821. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  52822. */
  52823. exitVROnDoubleTap: boolean;
  52824. /**
  52825. * Observable raised right before entering VR.
  52826. */
  52827. onEnteringVRObservable: Observable<VRExperienceHelper>;
  52828. /**
  52829. * Observable raised when entering VR has completed.
  52830. */
  52831. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  52832. /**
  52833. * Observable raised when exiting VR.
  52834. */
  52835. onExitingVRObservable: Observable<VRExperienceHelper>;
  52836. /**
  52837. * Observable raised when controller mesh is loaded.
  52838. */
  52839. onControllerMeshLoadedObservable: Observable<WebVRController>;
  52840. /** Return this.onEnteringVRObservable
  52841. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  52842. */
  52843. get onEnteringVR(): Observable<VRExperienceHelper>;
  52844. /** Return this.onExitingVRObservable
  52845. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  52846. */
  52847. get onExitingVR(): Observable<VRExperienceHelper>;
  52848. /** Return this.onControllerMeshLoadedObservable
  52849. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  52850. */
  52851. get onControllerMeshLoaded(): Observable<WebVRController>;
  52852. private _rayLength;
  52853. private _useCustomVRButton;
  52854. private _teleportationRequested;
  52855. private _teleportActive;
  52856. private _floorMeshName;
  52857. private _floorMeshesCollection;
  52858. private _teleportationMode;
  52859. private _teleportationTime;
  52860. private _teleportationSpeed;
  52861. private _teleportationEasing;
  52862. private _rotationAllowed;
  52863. private _teleportBackwardsVector;
  52864. private _teleportationTarget;
  52865. private _isDefaultTeleportationTarget;
  52866. private _postProcessMove;
  52867. private _teleportationFillColor;
  52868. private _teleportationBorderColor;
  52869. private _rotationAngle;
  52870. private _haloCenter;
  52871. private _cameraGazer;
  52872. private _padSensibilityUp;
  52873. private _padSensibilityDown;
  52874. private _leftController;
  52875. private _rightController;
  52876. private _gazeColor;
  52877. private _laserColor;
  52878. private _pickedLaserColor;
  52879. private _pickedGazeColor;
  52880. /**
  52881. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  52882. */
  52883. onNewMeshSelected: Observable<AbstractMesh>;
  52884. /**
  52885. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  52886. * This observable will provide the mesh and the controller used to select the mesh
  52887. */
  52888. onMeshSelectedWithController: Observable<{
  52889. mesh: AbstractMesh;
  52890. controller: WebVRController;
  52891. }>;
  52892. /**
  52893. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  52894. */
  52895. onNewMeshPicked: Observable<PickingInfo>;
  52896. private _circleEase;
  52897. /**
  52898. * Observable raised before camera teleportation
  52899. */
  52900. onBeforeCameraTeleport: Observable<Vector3>;
  52901. /**
  52902. * Observable raised after camera teleportation
  52903. */
  52904. onAfterCameraTeleport: Observable<Vector3>;
  52905. /**
  52906. * Observable raised when current selected mesh gets unselected
  52907. */
  52908. onSelectedMeshUnselected: Observable<AbstractMesh>;
  52909. private _raySelectionPredicate;
  52910. /**
  52911. * To be optionaly changed by user to define custom ray selection
  52912. */
  52913. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52914. /**
  52915. * To be optionaly changed by user to define custom selection logic (after ray selection)
  52916. */
  52917. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52918. /**
  52919. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  52920. */
  52921. teleportationEnabled: boolean;
  52922. private _defaultHeight;
  52923. private _teleportationInitialized;
  52924. private _interactionsEnabled;
  52925. private _interactionsRequested;
  52926. private _displayGaze;
  52927. private _displayLaserPointer;
  52928. /**
  52929. * The mesh used to display where the user is going to teleport.
  52930. */
  52931. get teleportationTarget(): Mesh;
  52932. /**
  52933. * Sets the mesh to be used to display where the user is going to teleport.
  52934. */
  52935. set teleportationTarget(value: Mesh);
  52936. /**
  52937. * 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
  52938. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  52939. * See https://doc.babylonjs.com/resources/baking_transformations
  52940. */
  52941. get gazeTrackerMesh(): Mesh;
  52942. set gazeTrackerMesh(value: Mesh);
  52943. /**
  52944. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  52945. */
  52946. updateGazeTrackerScale: boolean;
  52947. /**
  52948. * If the gaze trackers color should be updated when selecting meshes
  52949. */
  52950. updateGazeTrackerColor: boolean;
  52951. /**
  52952. * If the controller laser color should be updated when selecting meshes
  52953. */
  52954. updateControllerLaserColor: boolean;
  52955. /**
  52956. * The gaze tracking mesh corresponding to the left controller
  52957. */
  52958. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  52959. /**
  52960. * The gaze tracking mesh corresponding to the right controller
  52961. */
  52962. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  52963. /**
  52964. * If the ray of the gaze should be displayed.
  52965. */
  52966. get displayGaze(): boolean;
  52967. /**
  52968. * Sets if the ray of the gaze should be displayed.
  52969. */
  52970. set displayGaze(value: boolean);
  52971. /**
  52972. * If the ray of the LaserPointer should be displayed.
  52973. */
  52974. get displayLaserPointer(): boolean;
  52975. /**
  52976. * Sets if the ray of the LaserPointer should be displayed.
  52977. */
  52978. set displayLaserPointer(value: boolean);
  52979. /**
  52980. * The deviceOrientationCamera used as the camera when not in VR.
  52981. */
  52982. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  52983. /**
  52984. * Based on the current WebVR support, returns the current VR camera used.
  52985. */
  52986. get currentVRCamera(): Nullable<Camera>;
  52987. /**
  52988. * The webVRCamera which is used when in VR.
  52989. */
  52990. get webVRCamera(): WebVRFreeCamera;
  52991. /**
  52992. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  52993. */
  52994. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  52995. /**
  52996. * The html button that is used to trigger entering into VR.
  52997. */
  52998. get vrButton(): Nullable<HTMLButtonElement>;
  52999. private get _teleportationRequestInitiated();
  53000. /**
  53001. * Defines whether or not Pointer lock should be requested when switching to
  53002. * full screen.
  53003. */
  53004. requestPointerLockOnFullScreen: boolean;
  53005. /**
  53006. * If asking to force XR, this will be populated with the default xr experience
  53007. */
  53008. xr: WebXRDefaultExperience;
  53009. /**
  53010. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53011. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53012. */
  53013. xrTestDone: boolean;
  53014. /**
  53015. * Instantiates a VRExperienceHelper.
  53016. * Helps to quickly add VR support to an existing scene.
  53017. * @param scene The scene the VRExperienceHelper belongs to.
  53018. * @param webVROptions Options to modify the vr experience helper's behavior.
  53019. */
  53020. constructor(scene: Scene,
  53021. /** Options to modify the vr experience helper's behavior. */
  53022. webVROptions?: VRExperienceHelperOptions);
  53023. private completeVRInit;
  53024. private _onDefaultMeshLoaded;
  53025. private _onResize;
  53026. private _onFullscreenChange;
  53027. /**
  53028. * Gets a value indicating if we are currently in VR mode.
  53029. */
  53030. get isInVRMode(): boolean;
  53031. private onVrDisplayPresentChange;
  53032. private onVRDisplayChanged;
  53033. private moveButtonToBottomRight;
  53034. private displayVRButton;
  53035. private updateButtonVisibility;
  53036. private _cachedAngularSensibility;
  53037. /**
  53038. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53039. * Otherwise, will use the fullscreen API.
  53040. */
  53041. enterVR(): void;
  53042. /**
  53043. * Attempt to exit VR, or fullscreen.
  53044. */
  53045. exitVR(): void;
  53046. /**
  53047. * The position of the vr experience helper.
  53048. */
  53049. get position(): Vector3;
  53050. /**
  53051. * Sets the position of the vr experience helper.
  53052. */
  53053. set position(value: Vector3);
  53054. /**
  53055. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53056. */
  53057. enableInteractions(): void;
  53058. private get _noControllerIsActive();
  53059. private beforeRender;
  53060. private _isTeleportationFloor;
  53061. /**
  53062. * Adds a floor mesh to be used for teleportation.
  53063. * @param floorMesh the mesh to be used for teleportation.
  53064. */
  53065. addFloorMesh(floorMesh: Mesh): void;
  53066. /**
  53067. * Removes a floor mesh from being used for teleportation.
  53068. * @param floorMesh the mesh to be removed.
  53069. */
  53070. removeFloorMesh(floorMesh: Mesh): void;
  53071. /**
  53072. * Enables interactions and teleportation using the VR controllers and gaze.
  53073. * @param vrTeleportationOptions options to modify teleportation behavior.
  53074. */
  53075. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53076. private _onNewGamepadConnected;
  53077. private _tryEnableInteractionOnController;
  53078. private _onNewGamepadDisconnected;
  53079. private _enableInteractionOnController;
  53080. private _checkTeleportWithRay;
  53081. private _checkRotate;
  53082. private _checkTeleportBackwards;
  53083. private _enableTeleportationOnController;
  53084. private _createTeleportationCircles;
  53085. private _displayTeleportationTarget;
  53086. private _hideTeleportationTarget;
  53087. private _rotateCamera;
  53088. private _moveTeleportationSelectorTo;
  53089. private _workingVector;
  53090. private _workingQuaternion;
  53091. private _workingMatrix;
  53092. /**
  53093. * Time Constant Teleportation Mode
  53094. */
  53095. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53096. /**
  53097. * Speed Constant Teleportation Mode
  53098. */
  53099. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53100. /**
  53101. * Teleports the users feet to the desired location
  53102. * @param location The location where the user's feet should be placed
  53103. */
  53104. teleportCamera(location: Vector3): void;
  53105. private _convertNormalToDirectionOfRay;
  53106. private _castRayAndSelectObject;
  53107. private _notifySelectedMeshUnselected;
  53108. /**
  53109. * Permanently set new colors for the laser pointer
  53110. * @param color the new laser color
  53111. * @param pickedColor the new laser color when picked mesh detected
  53112. */
  53113. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53114. /**
  53115. * Set lighting enabled / disabled on the laser pointer of both controllers
  53116. * @param enabled should the lighting be enabled on the laser pointer
  53117. */
  53118. setLaserLightingState(enabled?: boolean): void;
  53119. /**
  53120. * Permanently set new colors for the gaze pointer
  53121. * @param color the new gaze color
  53122. * @param pickedColor the new gaze color when picked mesh detected
  53123. */
  53124. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53125. /**
  53126. * Sets the color of the laser ray from the vr controllers.
  53127. * @param color new color for the ray.
  53128. */
  53129. changeLaserColor(color: Color3): void;
  53130. /**
  53131. * Sets the color of the ray from the vr headsets gaze.
  53132. * @param color new color for the ray.
  53133. */
  53134. changeGazeColor(color: Color3): void;
  53135. /**
  53136. * Exits VR and disposes of the vr experience helper
  53137. */
  53138. dispose(): void;
  53139. /**
  53140. * Gets the name of the VRExperienceHelper class
  53141. * @returns "VRExperienceHelper"
  53142. */
  53143. getClassName(): string;
  53144. }
  53145. }
  53146. declare module BABYLON {
  53147. /**
  53148. * Contains an array of blocks representing the octree
  53149. */
  53150. export interface IOctreeContainer<T> {
  53151. /**
  53152. * Blocks within the octree
  53153. */
  53154. blocks: Array<OctreeBlock<T>>;
  53155. }
  53156. /**
  53157. * Class used to store a cell in an octree
  53158. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53159. */
  53160. export class OctreeBlock<T> {
  53161. /**
  53162. * Gets the content of the current block
  53163. */
  53164. entries: T[];
  53165. /**
  53166. * Gets the list of block children
  53167. */
  53168. blocks: Array<OctreeBlock<T>>;
  53169. private _depth;
  53170. private _maxDepth;
  53171. private _capacity;
  53172. private _minPoint;
  53173. private _maxPoint;
  53174. private _boundingVectors;
  53175. private _creationFunc;
  53176. /**
  53177. * Creates a new block
  53178. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53179. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53180. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53181. * @param depth defines the current depth of this block in the octree
  53182. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53183. * @param creationFunc defines a callback to call when an element is added to the block
  53184. */
  53185. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53186. /**
  53187. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53188. */
  53189. get capacity(): number;
  53190. /**
  53191. * Gets the minimum vector (in world space) of the block's bounding box
  53192. */
  53193. get minPoint(): Vector3;
  53194. /**
  53195. * Gets the maximum vector (in world space) of the block's bounding box
  53196. */
  53197. get maxPoint(): Vector3;
  53198. /**
  53199. * Add a new element to this block
  53200. * @param entry defines the element to add
  53201. */
  53202. addEntry(entry: T): void;
  53203. /**
  53204. * Remove an element from this block
  53205. * @param entry defines the element to remove
  53206. */
  53207. removeEntry(entry: T): void;
  53208. /**
  53209. * Add an array of elements to this block
  53210. * @param entries defines the array of elements to add
  53211. */
  53212. addEntries(entries: T[]): void;
  53213. /**
  53214. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53215. * @param frustumPlanes defines the frustum planes to test
  53216. * @param selection defines the array to store current content if selection is positive
  53217. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53218. */
  53219. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53220. /**
  53221. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53222. * @param sphereCenter defines the bounding sphere center
  53223. * @param sphereRadius defines the bounding sphere radius
  53224. * @param selection defines the array to store current content if selection is positive
  53225. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53226. */
  53227. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53228. /**
  53229. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53230. * @param ray defines the ray to test with
  53231. * @param selection defines the array to store current content if selection is positive
  53232. */
  53233. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53234. /**
  53235. * Subdivide the content into child blocks (this block will then be empty)
  53236. */
  53237. createInnerBlocks(): void;
  53238. /**
  53239. * @hidden
  53240. */
  53241. 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;
  53242. }
  53243. }
  53244. declare module BABYLON {
  53245. /**
  53246. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53247. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53248. */
  53249. export class Octree<T> {
  53250. /** 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.) */
  53251. maxDepth: number;
  53252. /**
  53253. * Blocks within the octree containing objects
  53254. */
  53255. blocks: Array<OctreeBlock<T>>;
  53256. /**
  53257. * Content stored in the octree
  53258. */
  53259. dynamicContent: T[];
  53260. private _maxBlockCapacity;
  53261. private _selectionContent;
  53262. private _creationFunc;
  53263. /**
  53264. * Creates a octree
  53265. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53266. * @param creationFunc function to be used to instatiate the octree
  53267. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53268. * @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.)
  53269. */
  53270. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53271. /** 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.) */
  53272. maxDepth?: number);
  53273. /**
  53274. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53275. * @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);
  53276. * @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);
  53277. * @param entries meshes to be added to the octree blocks
  53278. */
  53279. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53280. /**
  53281. * Adds a mesh to the octree
  53282. * @param entry Mesh to add to the octree
  53283. */
  53284. addMesh(entry: T): void;
  53285. /**
  53286. * Remove an element from the octree
  53287. * @param entry defines the element to remove
  53288. */
  53289. removeMesh(entry: T): void;
  53290. /**
  53291. * Selects an array of meshes within the frustum
  53292. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53293. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53294. * @returns array of meshes within the frustum
  53295. */
  53296. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53297. /**
  53298. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53299. * @param sphereCenter defines the bounding sphere center
  53300. * @param sphereRadius defines the bounding sphere radius
  53301. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53302. * @returns an array of objects that intersect the sphere
  53303. */
  53304. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53305. /**
  53306. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53307. * @param ray defines the ray to test with
  53308. * @returns array of intersected objects
  53309. */
  53310. intersectsRay(ray: Ray): SmartArray<T>;
  53311. /**
  53312. * Adds a mesh into the octree block if it intersects the block
  53313. */
  53314. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53315. /**
  53316. * Adds a submesh into the octree block if it intersects the block
  53317. */
  53318. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53319. }
  53320. }
  53321. declare module BABYLON {
  53322. interface Scene {
  53323. /**
  53324. * @hidden
  53325. * Backing Filed
  53326. */
  53327. _selectionOctree: Octree<AbstractMesh>;
  53328. /**
  53329. * Gets the octree used to boost mesh selection (picking)
  53330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53331. */
  53332. selectionOctree: Octree<AbstractMesh>;
  53333. /**
  53334. * Creates or updates the octree used to boost selection (picking)
  53335. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53336. * @param maxCapacity defines the maximum capacity per leaf
  53337. * @param maxDepth defines the maximum depth of the octree
  53338. * @returns an octree of AbstractMesh
  53339. */
  53340. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53341. }
  53342. interface AbstractMesh {
  53343. /**
  53344. * @hidden
  53345. * Backing Field
  53346. */
  53347. _submeshesOctree: Octree<SubMesh>;
  53348. /**
  53349. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53350. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53351. * @param maxCapacity defines the maximum size of each block (64 by default)
  53352. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53353. * @returns the new octree
  53354. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53355. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53356. */
  53357. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53358. }
  53359. /**
  53360. * Defines the octree scene component responsible to manage any octrees
  53361. * in a given scene.
  53362. */
  53363. export class OctreeSceneComponent {
  53364. /**
  53365. * The component name help to identify the component in the list of scene components.
  53366. */
  53367. readonly name: string;
  53368. /**
  53369. * The scene the component belongs to.
  53370. */
  53371. scene: Scene;
  53372. /**
  53373. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53374. */
  53375. readonly checksIsEnabled: boolean;
  53376. /**
  53377. * Creates a new instance of the component for the given scene
  53378. * @param scene Defines the scene to register the component in
  53379. */
  53380. constructor(scene: Scene);
  53381. /**
  53382. * Registers the component in a given scene
  53383. */
  53384. register(): void;
  53385. /**
  53386. * Return the list of active meshes
  53387. * @returns the list of active meshes
  53388. */
  53389. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53390. /**
  53391. * Return the list of active sub meshes
  53392. * @param mesh The mesh to get the candidates sub meshes from
  53393. * @returns the list of active sub meshes
  53394. */
  53395. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53396. private _tempRay;
  53397. /**
  53398. * Return the list of sub meshes intersecting with a given local ray
  53399. * @param mesh defines the mesh to find the submesh for
  53400. * @param localRay defines the ray in local space
  53401. * @returns the list of intersecting sub meshes
  53402. */
  53403. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53404. /**
  53405. * Return the list of sub meshes colliding with a collider
  53406. * @param mesh defines the mesh to find the submesh for
  53407. * @param collider defines the collider to evaluate the collision against
  53408. * @returns the list of colliding sub meshes
  53409. */
  53410. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53411. /**
  53412. * Rebuilds the elements related to this component in case of
  53413. * context lost for instance.
  53414. */
  53415. rebuild(): void;
  53416. /**
  53417. * Disposes the component and the associated ressources.
  53418. */
  53419. dispose(): void;
  53420. }
  53421. }
  53422. declare module BABYLON {
  53423. /**
  53424. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53425. */
  53426. export class Gizmo implements IDisposable {
  53427. /** The utility layer the gizmo will be added to */
  53428. gizmoLayer: UtilityLayerRenderer;
  53429. /**
  53430. * The root mesh of the gizmo
  53431. */
  53432. _rootMesh: Mesh;
  53433. private _attachedMesh;
  53434. private _attachedNode;
  53435. /**
  53436. * Ratio for the scale of the gizmo (Default: 1)
  53437. */
  53438. protected _scaleRatio: number;
  53439. /**
  53440. * boolean updated by pointermove when a gizmo mesh is hovered
  53441. */
  53442. protected _isHovered: boolean;
  53443. /**
  53444. * Ratio for the scale of the gizmo (Default: 1)
  53445. */
  53446. set scaleRatio(value: number);
  53447. get scaleRatio(): number;
  53448. /**
  53449. * True when the mouse pointer is hovered a gizmo mesh
  53450. */
  53451. get isHovered(): boolean;
  53452. /**
  53453. * If a custom mesh has been set (Default: false)
  53454. */
  53455. protected _customMeshSet: boolean;
  53456. /**
  53457. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53458. * * When set, interactions will be enabled
  53459. */
  53460. get attachedMesh(): Nullable<AbstractMesh>;
  53461. set attachedMesh(value: Nullable<AbstractMesh>);
  53462. /**
  53463. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53464. * * When set, interactions will be enabled
  53465. */
  53466. get attachedNode(): Nullable<Node>;
  53467. set attachedNode(value: Nullable<Node>);
  53468. /**
  53469. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53470. * @param mesh The mesh to replace the default mesh of the gizmo
  53471. */
  53472. setCustomMesh(mesh: Mesh): void;
  53473. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53474. /**
  53475. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53476. */
  53477. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53478. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53479. /**
  53480. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53481. */
  53482. updateGizmoPositionToMatchAttachedMesh: boolean;
  53483. /**
  53484. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53485. */
  53486. updateScale: boolean;
  53487. protected _interactionsEnabled: boolean;
  53488. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53489. private _beforeRenderObserver;
  53490. private _tempQuaternion;
  53491. private _tempVector;
  53492. private _tempVector2;
  53493. private _tempMatrix1;
  53494. private _tempMatrix2;
  53495. private _rightHandtoLeftHandMatrix;
  53496. /**
  53497. * Creates a gizmo
  53498. * @param gizmoLayer The utility layer the gizmo will be added to
  53499. */
  53500. constructor(
  53501. /** The utility layer the gizmo will be added to */
  53502. gizmoLayer?: UtilityLayerRenderer);
  53503. /**
  53504. * Updates the gizmo to match the attached mesh's position/rotation
  53505. */
  53506. protected _update(): void;
  53507. /**
  53508. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53509. * @param value Node, TransformNode or mesh
  53510. */
  53511. protected _matrixChanged(): void;
  53512. /**
  53513. * Disposes of the gizmo
  53514. */
  53515. dispose(): void;
  53516. }
  53517. }
  53518. declare module BABYLON {
  53519. /**
  53520. * Single plane drag gizmo
  53521. */
  53522. export class PlaneDragGizmo extends Gizmo {
  53523. /**
  53524. * Drag behavior responsible for the gizmos dragging interactions
  53525. */
  53526. dragBehavior: PointerDragBehavior;
  53527. private _pointerObserver;
  53528. /**
  53529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53530. */
  53531. snapDistance: number;
  53532. /**
  53533. * Event that fires each time the gizmo snaps to a new location.
  53534. * * snapDistance is the the change in distance
  53535. */
  53536. onSnapObservable: Observable<{
  53537. snapDistance: number;
  53538. }>;
  53539. private _plane;
  53540. private _coloredMaterial;
  53541. private _hoverMaterial;
  53542. private _isEnabled;
  53543. private _parent;
  53544. /** @hidden */
  53545. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53546. /** @hidden */
  53547. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53548. /**
  53549. * Creates a PlaneDragGizmo
  53550. * @param gizmoLayer The utility layer the gizmo will be added to
  53551. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53552. * @param color The color of the gizmo
  53553. */
  53554. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53555. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53556. /**
  53557. * If the gizmo is enabled
  53558. */
  53559. set isEnabled(value: boolean);
  53560. get isEnabled(): boolean;
  53561. /**
  53562. * Disposes of the gizmo
  53563. */
  53564. dispose(): void;
  53565. }
  53566. }
  53567. declare module BABYLON {
  53568. /**
  53569. * Gizmo that enables dragging a mesh along 3 axis
  53570. */
  53571. export class PositionGizmo extends Gizmo {
  53572. /**
  53573. * Internal gizmo used for interactions on the x axis
  53574. */
  53575. xGizmo: AxisDragGizmo;
  53576. /**
  53577. * Internal gizmo used for interactions on the y axis
  53578. */
  53579. yGizmo: AxisDragGizmo;
  53580. /**
  53581. * Internal gizmo used for interactions on the z axis
  53582. */
  53583. zGizmo: AxisDragGizmo;
  53584. /**
  53585. * Internal gizmo used for interactions on the yz plane
  53586. */
  53587. xPlaneGizmo: PlaneDragGizmo;
  53588. /**
  53589. * Internal gizmo used for interactions on the xz plane
  53590. */
  53591. yPlaneGizmo: PlaneDragGizmo;
  53592. /**
  53593. * Internal gizmo used for interactions on the xy plane
  53594. */
  53595. zPlaneGizmo: PlaneDragGizmo;
  53596. /**
  53597. * private variables
  53598. */
  53599. private _meshAttached;
  53600. private _nodeAttached;
  53601. private _snapDistance;
  53602. /** Fires an event when any of it's sub gizmos are dragged */
  53603. onDragStartObservable: Observable<unknown>;
  53604. /** Fires an event when any of it's sub gizmos are released from dragging */
  53605. onDragEndObservable: Observable<unknown>;
  53606. /**
  53607. * If set to true, planar drag is enabled
  53608. */
  53609. private _planarGizmoEnabled;
  53610. get attachedMesh(): Nullable<AbstractMesh>;
  53611. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53612. get attachedNode(): Nullable<Node>;
  53613. set attachedNode(node: Nullable<Node>);
  53614. /**
  53615. * True when the mouse pointer is hovering a gizmo mesh
  53616. */
  53617. get isHovered(): boolean;
  53618. /**
  53619. * Creates a PositionGizmo
  53620. * @param gizmoLayer The utility layer the gizmo will be added to
  53621. @param thickness display gizmo axis thickness
  53622. */
  53623. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53624. /**
  53625. * If the planar drag gizmo is enabled
  53626. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53627. */
  53628. set planarGizmoEnabled(value: boolean);
  53629. get planarGizmoEnabled(): boolean;
  53630. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53631. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53632. /**
  53633. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53634. */
  53635. set snapDistance(value: number);
  53636. get snapDistance(): number;
  53637. /**
  53638. * Ratio for the scale of the gizmo (Default: 1)
  53639. */
  53640. set scaleRatio(value: number);
  53641. get scaleRatio(): number;
  53642. /**
  53643. * Disposes of the gizmo
  53644. */
  53645. dispose(): void;
  53646. /**
  53647. * CustomMeshes are not supported by this gizmo
  53648. * @param mesh The mesh to replace the default mesh of the gizmo
  53649. */
  53650. setCustomMesh(mesh: Mesh): void;
  53651. }
  53652. }
  53653. declare module BABYLON {
  53654. /**
  53655. * Single axis drag gizmo
  53656. */
  53657. export class AxisDragGizmo extends Gizmo {
  53658. /**
  53659. * Drag behavior responsible for the gizmos dragging interactions
  53660. */
  53661. dragBehavior: PointerDragBehavior;
  53662. private _pointerObserver;
  53663. /**
  53664. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53665. */
  53666. snapDistance: number;
  53667. /**
  53668. * Event that fires each time the gizmo snaps to a new location.
  53669. * * snapDistance is the the change in distance
  53670. */
  53671. onSnapObservable: Observable<{
  53672. snapDistance: number;
  53673. }>;
  53674. private _isEnabled;
  53675. private _parent;
  53676. private _arrow;
  53677. private _coloredMaterial;
  53678. private _hoverMaterial;
  53679. /** @hidden */
  53680. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53681. /** @hidden */
  53682. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53683. /**
  53684. * Creates an AxisDragGizmo
  53685. * @param gizmoLayer The utility layer the gizmo will be added to
  53686. * @param dragAxis The axis which the gizmo will be able to drag on
  53687. * @param color The color of the gizmo
  53688. * @param thickness display gizmo axis thickness
  53689. */
  53690. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53691. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53692. /**
  53693. * If the gizmo is enabled
  53694. */
  53695. set isEnabled(value: boolean);
  53696. get isEnabled(): boolean;
  53697. /**
  53698. * Disposes of the gizmo
  53699. */
  53700. dispose(): void;
  53701. }
  53702. }
  53703. declare module BABYLON.Debug {
  53704. /**
  53705. * The Axes viewer will show 3 axes in a specific point in space
  53706. */
  53707. export class AxesViewer {
  53708. private _xAxis;
  53709. private _yAxis;
  53710. private _zAxis;
  53711. private _scaleLinesFactor;
  53712. private _instanced;
  53713. /**
  53714. * Gets the hosting scene
  53715. */
  53716. scene: Nullable<Scene>;
  53717. /**
  53718. * Gets or sets a number used to scale line length
  53719. */
  53720. scaleLines: number;
  53721. /** Gets the node hierarchy used to render x-axis */
  53722. get xAxis(): TransformNode;
  53723. /** Gets the node hierarchy used to render y-axis */
  53724. get yAxis(): TransformNode;
  53725. /** Gets the node hierarchy used to render z-axis */
  53726. get zAxis(): TransformNode;
  53727. /**
  53728. * Creates a new AxesViewer
  53729. * @param scene defines the hosting scene
  53730. * @param scaleLines defines a number used to scale line length (1 by default)
  53731. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  53732. * @param xAxis defines the node hierarchy used to render the x-axis
  53733. * @param yAxis defines the node hierarchy used to render the y-axis
  53734. * @param zAxis defines the node hierarchy used to render the z-axis
  53735. */
  53736. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  53737. /**
  53738. * Force the viewer to update
  53739. * @param position defines the position of the viewer
  53740. * @param xaxis defines the x axis of the viewer
  53741. * @param yaxis defines the y axis of the viewer
  53742. * @param zaxis defines the z axis of the viewer
  53743. */
  53744. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  53745. /**
  53746. * Creates an instance of this axes viewer.
  53747. * @returns a new axes viewer with instanced meshes
  53748. */
  53749. createInstance(): AxesViewer;
  53750. /** Releases resources */
  53751. dispose(): void;
  53752. private static _SetRenderingGroupId;
  53753. }
  53754. }
  53755. declare module BABYLON.Debug {
  53756. /**
  53757. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  53758. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  53759. */
  53760. export class BoneAxesViewer extends AxesViewer {
  53761. /**
  53762. * Gets or sets the target mesh where to display the axes viewer
  53763. */
  53764. mesh: Nullable<Mesh>;
  53765. /**
  53766. * Gets or sets the target bone where to display the axes viewer
  53767. */
  53768. bone: Nullable<Bone>;
  53769. /** Gets current position */
  53770. pos: Vector3;
  53771. /** Gets direction of X axis */
  53772. xaxis: Vector3;
  53773. /** Gets direction of Y axis */
  53774. yaxis: Vector3;
  53775. /** Gets direction of Z axis */
  53776. zaxis: Vector3;
  53777. /**
  53778. * Creates a new BoneAxesViewer
  53779. * @param scene defines the hosting scene
  53780. * @param bone defines the target bone
  53781. * @param mesh defines the target mesh
  53782. * @param scaleLines defines a scaling factor for line length (1 by default)
  53783. */
  53784. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  53785. /**
  53786. * Force the viewer to update
  53787. */
  53788. update(): void;
  53789. /** Releases resources */
  53790. dispose(): void;
  53791. }
  53792. }
  53793. declare module BABYLON {
  53794. /**
  53795. * Interface used to define scene explorer extensibility option
  53796. */
  53797. export interface IExplorerExtensibilityOption {
  53798. /**
  53799. * Define the option label
  53800. */
  53801. label: string;
  53802. /**
  53803. * Defines the action to execute on click
  53804. */
  53805. action: (entity: any) => void;
  53806. }
  53807. /**
  53808. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  53809. */
  53810. export interface IExplorerExtensibilityGroup {
  53811. /**
  53812. * Defines a predicate to test if a given type mut be extended
  53813. */
  53814. predicate: (entity: any) => boolean;
  53815. /**
  53816. * Gets the list of options added to a type
  53817. */
  53818. entries: IExplorerExtensibilityOption[];
  53819. }
  53820. /**
  53821. * Interface used to define the options to use to create the Inspector
  53822. */
  53823. export interface IInspectorOptions {
  53824. /**
  53825. * Display in overlay mode (default: false)
  53826. */
  53827. overlay?: boolean;
  53828. /**
  53829. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  53830. */
  53831. globalRoot?: HTMLElement;
  53832. /**
  53833. * Display the Scene explorer
  53834. */
  53835. showExplorer?: boolean;
  53836. /**
  53837. * Display the property inspector
  53838. */
  53839. showInspector?: boolean;
  53840. /**
  53841. * Display in embed mode (both panes on the right)
  53842. */
  53843. embedMode?: boolean;
  53844. /**
  53845. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53846. */
  53847. handleResize?: boolean;
  53848. /**
  53849. * Allow the panes to popup (default: true)
  53850. */
  53851. enablePopup?: boolean;
  53852. /**
  53853. * Allow the panes to be closed by users (default: true)
  53854. */
  53855. enableClose?: boolean;
  53856. /**
  53857. * Optional list of extensibility entries
  53858. */
  53859. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53860. /**
  53861. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53862. */
  53863. inspectorURL?: string;
  53864. /**
  53865. * Optional initial tab (default to DebugLayerTab.Properties)
  53866. */
  53867. initialTab?: DebugLayerTab;
  53868. }
  53869. interface Scene {
  53870. /**
  53871. * @hidden
  53872. * Backing field
  53873. */
  53874. _debugLayer: DebugLayer;
  53875. /**
  53876. * Gets the debug layer (aka Inspector) associated with the scene
  53877. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53878. */
  53879. debugLayer: DebugLayer;
  53880. }
  53881. /**
  53882. * Enum of inspector action tab
  53883. */
  53884. export enum DebugLayerTab {
  53885. /**
  53886. * Properties tag (default)
  53887. */
  53888. Properties = 0,
  53889. /**
  53890. * Debug tab
  53891. */
  53892. Debug = 1,
  53893. /**
  53894. * Statistics tab
  53895. */
  53896. Statistics = 2,
  53897. /**
  53898. * Tools tab
  53899. */
  53900. Tools = 3,
  53901. /**
  53902. * Settings tab
  53903. */
  53904. Settings = 4
  53905. }
  53906. /**
  53907. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53908. * what is happening in your scene
  53909. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53910. */
  53911. export class DebugLayer {
  53912. /**
  53913. * Define the url to get the inspector script from.
  53914. * By default it uses the babylonjs CDN.
  53915. * @ignoreNaming
  53916. */
  53917. static InspectorURL: string;
  53918. private _scene;
  53919. private BJSINSPECTOR;
  53920. private _onPropertyChangedObservable?;
  53921. /**
  53922. * Observable triggered when a property is changed through the inspector.
  53923. */
  53924. get onPropertyChangedObservable(): any;
  53925. /**
  53926. * Instantiates a new debug layer.
  53927. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53928. * what is happening in your scene
  53929. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53930. * @param scene Defines the scene to inspect
  53931. */
  53932. constructor(scene: Scene);
  53933. /** Creates the inspector window. */
  53934. private _createInspector;
  53935. /**
  53936. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53937. * @param entity defines the entity to select
  53938. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53939. */
  53940. select(entity: any, lineContainerTitles?: string | string[]): void;
  53941. /** Get the inspector from bundle or global */
  53942. private _getGlobalInspector;
  53943. /**
  53944. * Get if the inspector is visible or not.
  53945. * @returns true if visible otherwise, false
  53946. */
  53947. isVisible(): boolean;
  53948. /**
  53949. * Hide the inspector and close its window.
  53950. */
  53951. hide(): void;
  53952. /**
  53953. * Update the scene in the inspector
  53954. */
  53955. setAsActiveScene(): void;
  53956. /**
  53957. * Launch the debugLayer.
  53958. * @param config Define the configuration of the inspector
  53959. * @return a promise fulfilled when the debug layer is visible
  53960. */
  53961. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53962. }
  53963. }
  53964. declare module BABYLON {
  53965. /**
  53966. * Class containing static functions to help procedurally build meshes
  53967. */
  53968. export class BoxBuilder {
  53969. /**
  53970. * Creates a box mesh
  53971. * * The parameter `size` sets the size (float) of each box side (default 1)
  53972. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53973. * * 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)
  53974. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53976. * * 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
  53977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53978. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53979. * @param name defines the name of the mesh
  53980. * @param options defines the options used to create the mesh
  53981. * @param scene defines the hosting scene
  53982. * @returns the box mesh
  53983. */
  53984. static CreateBox(name: string, options: {
  53985. size?: number;
  53986. width?: number;
  53987. height?: number;
  53988. depth?: number;
  53989. faceUV?: Vector4[];
  53990. faceColors?: Color4[];
  53991. sideOrientation?: number;
  53992. frontUVs?: Vector4;
  53993. backUVs?: Vector4;
  53994. wrap?: boolean;
  53995. topBaseAt?: number;
  53996. bottomBaseAt?: number;
  53997. updatable?: boolean;
  53998. }, scene?: Nullable<Scene>): Mesh;
  53999. }
  54000. }
  54001. declare module BABYLON.Debug {
  54002. /**
  54003. * Used to show the physics impostor around the specific mesh
  54004. */
  54005. export class PhysicsViewer {
  54006. /** @hidden */
  54007. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54008. /** @hidden */
  54009. protected _meshes: Array<Nullable<AbstractMesh>>;
  54010. /** @hidden */
  54011. protected _scene: Nullable<Scene>;
  54012. /** @hidden */
  54013. protected _numMeshes: number;
  54014. /** @hidden */
  54015. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54016. private _renderFunction;
  54017. private _utilityLayer;
  54018. private _debugBoxMesh;
  54019. private _debugSphereMesh;
  54020. private _debugCylinderMesh;
  54021. private _debugMaterial;
  54022. private _debugMeshMeshes;
  54023. /**
  54024. * Creates a new PhysicsViewer
  54025. * @param scene defines the hosting scene
  54026. */
  54027. constructor(scene: Scene);
  54028. /** @hidden */
  54029. protected _updateDebugMeshes(): void;
  54030. /**
  54031. * Renders a specified physic impostor
  54032. * @param impostor defines the impostor to render
  54033. * @param targetMesh defines the mesh represented by the impostor
  54034. * @returns the new debug mesh used to render the impostor
  54035. */
  54036. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54037. /**
  54038. * Hides a specified physic impostor
  54039. * @param impostor defines the impostor to hide
  54040. */
  54041. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54042. private _getDebugMaterial;
  54043. private _getDebugBoxMesh;
  54044. private _getDebugSphereMesh;
  54045. private _getDebugCylinderMesh;
  54046. private _getDebugMeshMesh;
  54047. private _getDebugMesh;
  54048. /** Releases all resources */
  54049. dispose(): void;
  54050. }
  54051. }
  54052. declare module BABYLON {
  54053. /**
  54054. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54055. * in order to better appreciate the issue one might have.
  54056. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54057. */
  54058. export class RayHelper {
  54059. /**
  54060. * Defines the ray we are currently tryin to visualize.
  54061. */
  54062. ray: Nullable<Ray>;
  54063. private _renderPoints;
  54064. private _renderLine;
  54065. private _renderFunction;
  54066. private _scene;
  54067. private _onAfterRenderObserver;
  54068. private _onAfterStepObserver;
  54069. private _attachedToMesh;
  54070. private _meshSpaceDirection;
  54071. private _meshSpaceOrigin;
  54072. /**
  54073. * Helper function to create a colored helper in a scene in one line.
  54074. * @param ray Defines the ray we are currently tryin to visualize
  54075. * @param scene Defines the scene the ray is used in
  54076. * @param color Defines the color we want to see the ray in
  54077. * @returns The newly created ray helper.
  54078. */
  54079. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54080. /**
  54081. * Instantiate a new ray helper.
  54082. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54083. * in order to better appreciate the issue one might have.
  54084. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54085. * @param ray Defines the ray we are currently tryin to visualize
  54086. */
  54087. constructor(ray: Ray);
  54088. /**
  54089. * Shows the ray we are willing to debug.
  54090. * @param scene Defines the scene the ray needs to be rendered in
  54091. * @param color Defines the color the ray needs to be rendered in
  54092. */
  54093. show(scene: Scene, color?: Color3): void;
  54094. /**
  54095. * Hides the ray we are debugging.
  54096. */
  54097. hide(): void;
  54098. private _render;
  54099. /**
  54100. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54101. * @param mesh Defines the mesh we want the helper attached to
  54102. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54103. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54104. * @param length Defines the length of the ray
  54105. */
  54106. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54107. /**
  54108. * Detach the ray helper from the mesh it has previously been attached to.
  54109. */
  54110. detachFromMesh(): void;
  54111. private _updateToMesh;
  54112. /**
  54113. * Dispose the helper and release its associated resources.
  54114. */
  54115. dispose(): void;
  54116. }
  54117. }
  54118. declare module BABYLON {
  54119. /**
  54120. * Defines the options associated with the creation of a SkeletonViewer.
  54121. */
  54122. export interface ISkeletonViewerOptions {
  54123. /** Should the system pause animations before building the Viewer? */
  54124. pauseAnimations: boolean;
  54125. /** Should the system return the skeleton to rest before building? */
  54126. returnToRest: boolean;
  54127. /** public Display Mode of the Viewer */
  54128. displayMode: number;
  54129. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54130. displayOptions: ISkeletonViewerDisplayOptions;
  54131. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54132. computeBonesUsingShaders: boolean;
  54133. /** Flag ignore non weighted bones */
  54134. useAllBones: boolean;
  54135. }
  54136. /**
  54137. * Defines how to display the various bone meshes for the viewer.
  54138. */
  54139. export interface ISkeletonViewerDisplayOptions {
  54140. /** How far down to start tapering the bone spurs */
  54141. midStep?: number;
  54142. /** How big is the midStep? */
  54143. midStepFactor?: number;
  54144. /** Base for the Sphere Size */
  54145. sphereBaseSize?: number;
  54146. /** The ratio of the sphere to the longest bone in units */
  54147. sphereScaleUnit?: number;
  54148. /** Ratio for the Sphere Size */
  54149. sphereFactor?: number;
  54150. /** Whether a spur should attach its far end to the child bone position */
  54151. spurFollowsChild?: boolean;
  54152. /** Whether to show local axes or not */
  54153. showLocalAxes?: boolean;
  54154. /** Length of each local axis */
  54155. localAxesSize?: number;
  54156. }
  54157. /**
  54158. * Defines the constructor options for the BoneWeight Shader.
  54159. */
  54160. export interface IBoneWeightShaderOptions {
  54161. /** Skeleton to Map */
  54162. skeleton: Skeleton;
  54163. /** Colors for Uninfluenced bones */
  54164. colorBase?: Color3;
  54165. /** Colors for 0.0-0.25 Weight bones */
  54166. colorZero?: Color3;
  54167. /** Color for 0.25-0.5 Weight Influence */
  54168. colorQuarter?: Color3;
  54169. /** Color for 0.5-0.75 Weight Influence */
  54170. colorHalf?: Color3;
  54171. /** Color for 0.75-1 Weight Influence */
  54172. colorFull?: Color3;
  54173. /** Color for Zero Weight Influence */
  54174. targetBoneIndex?: number;
  54175. }
  54176. /**
  54177. * Simple structure of the gradient steps for the Color Map.
  54178. */
  54179. export interface ISkeletonMapShaderColorMapKnot {
  54180. /** Color of the Knot */
  54181. color: Color3;
  54182. /** Location of the Knot */
  54183. location: number;
  54184. }
  54185. /**
  54186. * Defines the constructor options for the SkeletonMap Shader.
  54187. */
  54188. export interface ISkeletonMapShaderOptions {
  54189. /** Skeleton to Map */
  54190. skeleton: Skeleton;
  54191. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54192. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54193. }
  54194. }
  54195. declare module BABYLON {
  54196. /**
  54197. * Class containing static functions to help procedurally build meshes
  54198. */
  54199. export class RibbonBuilder {
  54200. /**
  54201. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54202. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54203. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54204. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54205. * * 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
  54206. * * 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
  54207. * * 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
  54208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54209. * * 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
  54210. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54211. * * 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
  54212. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54213. * * 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
  54214. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54216. * @param name defines the name of the mesh
  54217. * @param options defines the options used to create the mesh
  54218. * @param scene defines the hosting scene
  54219. * @returns the ribbon mesh
  54220. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54221. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54222. */
  54223. static CreateRibbon(name: string, options: {
  54224. pathArray: Vector3[][];
  54225. closeArray?: boolean;
  54226. closePath?: boolean;
  54227. offset?: number;
  54228. updatable?: boolean;
  54229. sideOrientation?: number;
  54230. frontUVs?: Vector4;
  54231. backUVs?: Vector4;
  54232. instance?: Mesh;
  54233. invertUV?: boolean;
  54234. uvs?: Vector2[];
  54235. colors?: Color4[];
  54236. }, scene?: Nullable<Scene>): Mesh;
  54237. }
  54238. }
  54239. declare module BABYLON {
  54240. /**
  54241. * Class containing static functions to help procedurally build meshes
  54242. */
  54243. export class ShapeBuilder {
  54244. /**
  54245. * 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.
  54246. * * 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.
  54247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54248. * * 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.
  54249. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54250. * * 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
  54251. * * 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
  54252. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54254. * * 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
  54255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54257. * @param name defines the name of the mesh
  54258. * @param options defines the options used to create the mesh
  54259. * @param scene defines the hosting scene
  54260. * @returns the extruded shape mesh
  54261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54263. */
  54264. static ExtrudeShape(name: string, options: {
  54265. shape: Vector3[];
  54266. path: Vector3[];
  54267. scale?: number;
  54268. rotation?: number;
  54269. cap?: number;
  54270. updatable?: boolean;
  54271. sideOrientation?: number;
  54272. frontUVs?: Vector4;
  54273. backUVs?: Vector4;
  54274. instance?: Mesh;
  54275. invertUV?: boolean;
  54276. }, scene?: Nullable<Scene>): Mesh;
  54277. /**
  54278. * Creates an custom extruded shape mesh.
  54279. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54280. * * 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.
  54281. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54282. * * 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
  54283. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54284. * * 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
  54285. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54286. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54287. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54288. * * 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
  54289. * * 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
  54290. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54292. * * 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
  54293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54295. * @param name defines the name of the mesh
  54296. * @param options defines the options used to create the mesh
  54297. * @param scene defines the hosting scene
  54298. * @returns the custom extruded shape mesh
  54299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54302. */
  54303. static ExtrudeShapeCustom(name: string, options: {
  54304. shape: Vector3[];
  54305. path: Vector3[];
  54306. scaleFunction?: any;
  54307. rotationFunction?: any;
  54308. ribbonCloseArray?: boolean;
  54309. ribbonClosePath?: boolean;
  54310. cap?: number;
  54311. updatable?: boolean;
  54312. sideOrientation?: number;
  54313. frontUVs?: Vector4;
  54314. backUVs?: Vector4;
  54315. instance?: Mesh;
  54316. invertUV?: boolean;
  54317. }, scene?: Nullable<Scene>): Mesh;
  54318. private static _ExtrudeShapeGeneric;
  54319. }
  54320. }
  54321. declare module BABYLON.Debug {
  54322. /**
  54323. * Class used to render a debug view of a given skeleton
  54324. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54325. */
  54326. export class SkeletonViewer {
  54327. /** defines the skeleton to render */
  54328. skeleton: Skeleton;
  54329. /** defines the mesh attached to the skeleton */
  54330. mesh: AbstractMesh;
  54331. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54332. autoUpdateBonesMatrices: boolean;
  54333. /** defines the rendering group id to use with the viewer */
  54334. renderingGroupId: number;
  54335. /** is the options for the viewer */
  54336. options: Partial<ISkeletonViewerOptions>;
  54337. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54338. static readonly DISPLAY_LINES: number;
  54339. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54340. static readonly DISPLAY_SPHERES: number;
  54341. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54342. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54343. /** public static method to create a BoneWeight Shader
  54344. * @param options The constructor options
  54345. * @param scene The scene that the shader is scoped to
  54346. * @returns The created ShaderMaterial
  54347. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54348. */
  54349. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54350. /** public static method to create a BoneWeight Shader
  54351. * @param options The constructor options
  54352. * @param scene The scene that the shader is scoped to
  54353. * @returns The created ShaderMaterial
  54354. */
  54355. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54356. /** private static method to create a BoneWeight Shader
  54357. * @param size The size of the buffer to create (usually the bone count)
  54358. * @param colorMap The gradient data to generate
  54359. * @param scene The scene that the shader is scoped to
  54360. * @returns an Array of floats from the color gradient values
  54361. */
  54362. private static _CreateBoneMapColorBuffer;
  54363. /** If SkeletonViewer scene scope. */
  54364. private _scene;
  54365. /** Gets or sets the color used to render the skeleton */
  54366. color: Color3;
  54367. /** Array of the points of the skeleton fo the line view. */
  54368. private _debugLines;
  54369. /** The SkeletonViewers Mesh. */
  54370. private _debugMesh;
  54371. /** The local axes Meshes. */
  54372. private _localAxes;
  54373. /** If SkeletonViewer is enabled. */
  54374. private _isEnabled;
  54375. /** If SkeletonViewer is ready. */
  54376. private _ready;
  54377. /** SkeletonViewer render observable. */
  54378. private _obs;
  54379. /** The Utility Layer to render the gizmos in. */
  54380. private _utilityLayer;
  54381. private _boneIndices;
  54382. /** Gets the Scene. */
  54383. get scene(): Scene;
  54384. /** Gets the utilityLayer. */
  54385. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54386. /** Checks Ready Status. */
  54387. get isReady(): Boolean;
  54388. /** Sets Ready Status. */
  54389. set ready(value: boolean);
  54390. /** Gets the debugMesh */
  54391. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54392. /** Sets the debugMesh */
  54393. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54394. /** Gets the displayMode */
  54395. get displayMode(): number;
  54396. /** Sets the displayMode */
  54397. set displayMode(value: number);
  54398. /**
  54399. * Creates a new SkeletonViewer
  54400. * @param skeleton defines the skeleton to render
  54401. * @param mesh defines the mesh attached to the skeleton
  54402. * @param scene defines the hosting scene
  54403. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54404. * @param renderingGroupId defines the rendering group id to use with the viewer
  54405. * @param options All of the extra constructor options for the SkeletonViewer
  54406. */
  54407. constructor(
  54408. /** defines the skeleton to render */
  54409. skeleton: Skeleton,
  54410. /** defines the mesh attached to the skeleton */
  54411. mesh: AbstractMesh,
  54412. /** The Scene scope*/
  54413. scene: Scene,
  54414. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54415. autoUpdateBonesMatrices?: boolean,
  54416. /** defines the rendering group id to use with the viewer */
  54417. renderingGroupId?: number,
  54418. /** is the options for the viewer */
  54419. options?: Partial<ISkeletonViewerOptions>);
  54420. /** The Dynamic bindings for the update functions */
  54421. private _bindObs;
  54422. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54423. update(): void;
  54424. /** Gets or sets a boolean indicating if the viewer is enabled */
  54425. set isEnabled(value: boolean);
  54426. get isEnabled(): boolean;
  54427. private _getBonePosition;
  54428. private _getLinesForBonesWithLength;
  54429. private _getLinesForBonesNoLength;
  54430. /** function to revert the mesh and scene back to the initial state. */
  54431. private _revert;
  54432. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54433. private _getAbsoluteBindPoseToRef;
  54434. /** function to build and bind sphere joint points and spur bone representations. */
  54435. private _buildSpheresAndSpurs;
  54436. private _buildLocalAxes;
  54437. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54438. private _displayLinesUpdate;
  54439. /** Changes the displayMode of the skeleton viewer
  54440. * @param mode The displayMode numerical value
  54441. */
  54442. changeDisplayMode(mode: number): void;
  54443. /** Sets a display option of the skeleton viewer
  54444. *
  54445. * | Option | Type | Default | Description |
  54446. * | ---------------- | ------- | ------- | ----------- |
  54447. * | 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`. |
  54448. * | 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`. |
  54449. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54450. * | 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`. |
  54451. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54452. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54453. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54454. *
  54455. * @param option String of the option name
  54456. * @param value The numerical option value
  54457. */
  54458. changeDisplayOptions(option: string, value: number): void;
  54459. /** Release associated resources */
  54460. dispose(): void;
  54461. }
  54462. }
  54463. declare module BABYLON {
  54464. /**
  54465. * Enum for Device Types
  54466. */
  54467. export enum DeviceType {
  54468. /** Generic */
  54469. Generic = 0,
  54470. /** Keyboard */
  54471. Keyboard = 1,
  54472. /** Mouse */
  54473. Mouse = 2,
  54474. /** Touch Pointers */
  54475. Touch = 3,
  54476. /** PS4 Dual Shock */
  54477. DualShock = 4,
  54478. /** Xbox */
  54479. Xbox = 5,
  54480. /** Switch Controller */
  54481. Switch = 6
  54482. }
  54483. /**
  54484. * Enum for All Pointers (Touch/Mouse)
  54485. */
  54486. export enum PointerInput {
  54487. /** Horizontal Axis */
  54488. Horizontal = 0,
  54489. /** Vertical Axis */
  54490. Vertical = 1,
  54491. /** Left Click or Touch */
  54492. LeftClick = 2,
  54493. /** Middle Click */
  54494. MiddleClick = 3,
  54495. /** Right Click */
  54496. RightClick = 4,
  54497. /** Browser Back */
  54498. BrowserBack = 5,
  54499. /** Browser Forward */
  54500. BrowserForward = 6
  54501. }
  54502. /**
  54503. * Enum for Dual Shock Gamepad
  54504. */
  54505. export enum DualShockInput {
  54506. /** Cross */
  54507. Cross = 0,
  54508. /** Circle */
  54509. Circle = 1,
  54510. /** Square */
  54511. Square = 2,
  54512. /** Triangle */
  54513. Triangle = 3,
  54514. /** L1 */
  54515. L1 = 4,
  54516. /** R1 */
  54517. R1 = 5,
  54518. /** L2 */
  54519. L2 = 6,
  54520. /** R2 */
  54521. R2 = 7,
  54522. /** Share */
  54523. Share = 8,
  54524. /** Options */
  54525. Options = 9,
  54526. /** L3 */
  54527. L3 = 10,
  54528. /** R3 */
  54529. R3 = 11,
  54530. /** DPadUp */
  54531. DPadUp = 12,
  54532. /** DPadDown */
  54533. DPadDown = 13,
  54534. /** DPadLeft */
  54535. DPadLeft = 14,
  54536. /** DRight */
  54537. DPadRight = 15,
  54538. /** Home */
  54539. Home = 16,
  54540. /** TouchPad */
  54541. TouchPad = 17,
  54542. /** LStickXAxis */
  54543. LStickXAxis = 18,
  54544. /** LStickYAxis */
  54545. LStickYAxis = 19,
  54546. /** RStickXAxis */
  54547. RStickXAxis = 20,
  54548. /** RStickYAxis */
  54549. RStickYAxis = 21
  54550. }
  54551. /**
  54552. * Enum for Xbox Gamepad
  54553. */
  54554. export enum XboxInput {
  54555. /** A */
  54556. A = 0,
  54557. /** B */
  54558. B = 1,
  54559. /** X */
  54560. X = 2,
  54561. /** Y */
  54562. Y = 3,
  54563. /** LB */
  54564. LB = 4,
  54565. /** RB */
  54566. RB = 5,
  54567. /** LT */
  54568. LT = 6,
  54569. /** RT */
  54570. RT = 7,
  54571. /** Back */
  54572. Back = 8,
  54573. /** Start */
  54574. Start = 9,
  54575. /** LS */
  54576. LS = 10,
  54577. /** RS */
  54578. RS = 11,
  54579. /** DPadUp */
  54580. DPadUp = 12,
  54581. /** DPadDown */
  54582. DPadDown = 13,
  54583. /** DPadLeft */
  54584. DPadLeft = 14,
  54585. /** DRight */
  54586. DPadRight = 15,
  54587. /** Home */
  54588. Home = 16,
  54589. /** LStickXAxis */
  54590. LStickXAxis = 17,
  54591. /** LStickYAxis */
  54592. LStickYAxis = 18,
  54593. /** RStickXAxis */
  54594. RStickXAxis = 19,
  54595. /** RStickYAxis */
  54596. RStickYAxis = 20
  54597. }
  54598. /**
  54599. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54600. */
  54601. export enum SwitchInput {
  54602. /** B */
  54603. B = 0,
  54604. /** A */
  54605. A = 1,
  54606. /** Y */
  54607. Y = 2,
  54608. /** X */
  54609. X = 3,
  54610. /** L */
  54611. L = 4,
  54612. /** R */
  54613. R = 5,
  54614. /** ZL */
  54615. ZL = 6,
  54616. /** ZR */
  54617. ZR = 7,
  54618. /** Minus */
  54619. Minus = 8,
  54620. /** Plus */
  54621. Plus = 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. /** Capture */
  54637. Capture = 17,
  54638. /** LStickXAxis */
  54639. LStickXAxis = 18,
  54640. /** LStickYAxis */
  54641. LStickYAxis = 19,
  54642. /** RStickXAxis */
  54643. RStickXAxis = 20,
  54644. /** RStickYAxis */
  54645. RStickYAxis = 21
  54646. }
  54647. }
  54648. declare module BABYLON {
  54649. /**
  54650. * This class will take all inputs from Keyboard, Pointer, and
  54651. * any Gamepads and provide a polling system that all devices
  54652. * will use. This class assumes that there will only be one
  54653. * pointer device and one keyboard.
  54654. */
  54655. export class DeviceInputSystem implements IDisposable {
  54656. /**
  54657. * Callback to be triggered when a device is connected
  54658. */
  54659. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54660. /**
  54661. * Callback to be triggered when a device is disconnected
  54662. */
  54663. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54664. /**
  54665. * Callback to be triggered when event driven input is updated
  54666. */
  54667. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54668. private _inputs;
  54669. private _gamepads;
  54670. private _keyboardActive;
  54671. private _pointerActive;
  54672. private _elementToAttachTo;
  54673. private _keyboardDownEvent;
  54674. private _keyboardUpEvent;
  54675. private _pointerMoveEvent;
  54676. private _pointerDownEvent;
  54677. private _pointerUpEvent;
  54678. private _gamepadConnectedEvent;
  54679. private _gamepadDisconnectedEvent;
  54680. private static _MAX_KEYCODES;
  54681. private static _MAX_POINTER_INPUTS;
  54682. private constructor();
  54683. /**
  54684. * Creates a new DeviceInputSystem instance
  54685. * @param engine Engine to pull input element from
  54686. * @returns The new instance
  54687. */
  54688. static Create(engine: Engine): DeviceInputSystem;
  54689. /**
  54690. * Checks for current device input value, given an id and input index
  54691. * @param deviceName Id of connected device
  54692. * @param inputIndex Index of device input
  54693. * @returns Current value of input
  54694. */
  54695. /**
  54696. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54697. * @param deviceType Enum specifiying device type
  54698. * @param deviceSlot "Slot" or index that device is referenced in
  54699. * @param inputIndex Id of input to be checked
  54700. * @returns Current value of input
  54701. */
  54702. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54703. /**
  54704. * Dispose of all the eventlisteners
  54705. */
  54706. dispose(): void;
  54707. /**
  54708. * Add device and inputs to device array
  54709. * @param deviceType Enum specifiying device type
  54710. * @param deviceSlot "Slot" or index that device is referenced in
  54711. * @param numberOfInputs Number of input entries to create for given device
  54712. */
  54713. private _registerDevice;
  54714. /**
  54715. * Given a specific device name, remove that device from the device map
  54716. * @param deviceType Enum specifiying device type
  54717. * @param deviceSlot "Slot" or index that device is referenced in
  54718. */
  54719. private _unregisterDevice;
  54720. /**
  54721. * Handle all actions that come from keyboard interaction
  54722. */
  54723. private _handleKeyActions;
  54724. /**
  54725. * Handle all actions that come from pointer interaction
  54726. */
  54727. private _handlePointerActions;
  54728. /**
  54729. * Handle all actions that come from gamepad interaction
  54730. */
  54731. private _handleGamepadActions;
  54732. /**
  54733. * Update all non-event based devices with each frame
  54734. * @param deviceType Enum specifiying device type
  54735. * @param deviceSlot "Slot" or index that device is referenced in
  54736. * @param inputIndex Id of input to be checked
  54737. */
  54738. private _updateDevice;
  54739. /**
  54740. * Gets DeviceType from the device name
  54741. * @param deviceName Name of Device from DeviceInputSystem
  54742. * @returns DeviceType enum value
  54743. */
  54744. private _getGamepadDeviceType;
  54745. }
  54746. }
  54747. declare module BABYLON {
  54748. /**
  54749. * Type to handle enforcement of inputs
  54750. */
  54751. 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;
  54752. }
  54753. declare module BABYLON {
  54754. /**
  54755. * Class that handles all input for a specific device
  54756. */
  54757. export class DeviceSource<T extends DeviceType> {
  54758. /** Type of device */
  54759. readonly deviceType: DeviceType;
  54760. /** "Slot" or index that device is referenced in */
  54761. readonly deviceSlot: number;
  54762. /**
  54763. * Observable to handle device input changes per device
  54764. */
  54765. readonly onInputChangedObservable: Observable<{
  54766. inputIndex: DeviceInput<T>;
  54767. previousState: Nullable<number>;
  54768. currentState: Nullable<number>;
  54769. }>;
  54770. private readonly _deviceInputSystem;
  54771. /**
  54772. * Default Constructor
  54773. * @param deviceInputSystem Reference to DeviceInputSystem
  54774. * @param deviceType Type of device
  54775. * @param deviceSlot "Slot" or index that device is referenced in
  54776. */
  54777. constructor(deviceInputSystem: DeviceInputSystem,
  54778. /** Type of device */
  54779. deviceType: DeviceType,
  54780. /** "Slot" or index that device is referenced in */
  54781. deviceSlot?: number);
  54782. /**
  54783. * Get input for specific input
  54784. * @param inputIndex index of specific input on device
  54785. * @returns Input value from DeviceInputSystem
  54786. */
  54787. getInput(inputIndex: DeviceInput<T>): number;
  54788. }
  54789. /**
  54790. * Class to keep track of devices
  54791. */
  54792. export class DeviceSourceManager implements IDisposable {
  54793. /**
  54794. * Observable to be triggered when before a device is connected
  54795. */
  54796. readonly onBeforeDeviceConnectedObservable: Observable<{
  54797. deviceType: DeviceType;
  54798. deviceSlot: number;
  54799. }>;
  54800. /**
  54801. * Observable to be triggered when before a device is disconnected
  54802. */
  54803. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54804. deviceType: DeviceType;
  54805. deviceSlot: number;
  54806. }>;
  54807. /**
  54808. * Observable to be triggered when after a device is connected
  54809. */
  54810. readonly onAfterDeviceConnectedObservable: Observable<{
  54811. deviceType: DeviceType;
  54812. deviceSlot: number;
  54813. }>;
  54814. /**
  54815. * Observable to be triggered when after a device is disconnected
  54816. */
  54817. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54818. deviceType: DeviceType;
  54819. deviceSlot: number;
  54820. }>;
  54821. private readonly _devices;
  54822. private readonly _firstDevice;
  54823. private readonly _deviceInputSystem;
  54824. /**
  54825. * Default Constructor
  54826. * @param engine engine to pull input element from
  54827. */
  54828. constructor(engine: Engine);
  54829. /**
  54830. * Gets a DeviceSource, given a type and slot
  54831. * @param deviceType Enum specifying device type
  54832. * @param deviceSlot "Slot" or index that device is referenced in
  54833. * @returns DeviceSource object
  54834. */
  54835. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54836. /**
  54837. * Gets an array of DeviceSource objects for a given device type
  54838. * @param deviceType Enum specifying device type
  54839. * @returns Array of DeviceSource objects
  54840. */
  54841. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54842. /**
  54843. * Dispose of DeviceInputSystem and other parts
  54844. */
  54845. dispose(): void;
  54846. /**
  54847. * Function to add device name to device list
  54848. * @param deviceType Enum specifying device type
  54849. * @param deviceSlot "Slot" or index that device is referenced in
  54850. */
  54851. private _addDevice;
  54852. /**
  54853. * Function to remove device name to device list
  54854. * @param deviceType Enum specifying device type
  54855. * @param deviceSlot "Slot" or index that device is referenced in
  54856. */
  54857. private _removeDevice;
  54858. /**
  54859. * Updates array storing first connected device of each type
  54860. * @param type Type of Device
  54861. */
  54862. private _updateFirstDevices;
  54863. }
  54864. }
  54865. declare module BABYLON {
  54866. /**
  54867. * Options to create the null engine
  54868. */
  54869. export class NullEngineOptions {
  54870. /**
  54871. * Render width (Default: 512)
  54872. */
  54873. renderWidth: number;
  54874. /**
  54875. * Render height (Default: 256)
  54876. */
  54877. renderHeight: number;
  54878. /**
  54879. * Texture size (Default: 512)
  54880. */
  54881. textureSize: number;
  54882. /**
  54883. * If delta time between frames should be constant
  54884. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54885. */
  54886. deterministicLockstep: boolean;
  54887. /**
  54888. * Maximum about of steps between frames (Default: 4)
  54889. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54890. */
  54891. lockstepMaxSteps: number;
  54892. /**
  54893. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54894. */
  54895. useHighPrecisionMatrix?: boolean;
  54896. }
  54897. /**
  54898. * The null engine class provides support for headless version of babylon.js.
  54899. * This can be used in server side scenario or for testing purposes
  54900. */
  54901. export class NullEngine extends Engine {
  54902. private _options;
  54903. /**
  54904. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54905. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54906. * @returns true if engine is in deterministic lock step mode
  54907. */
  54908. isDeterministicLockStep(): boolean;
  54909. /**
  54910. * Gets the max steps when engine is running in deterministic lock step
  54911. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54912. * @returns the max steps
  54913. */
  54914. getLockstepMaxSteps(): number;
  54915. /**
  54916. * Gets the current hardware scaling level.
  54917. * By default the hardware scaling level is computed from the window device ratio.
  54918. * 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.
  54919. * @returns a number indicating the current hardware scaling level
  54920. */
  54921. getHardwareScalingLevel(): number;
  54922. constructor(options?: NullEngineOptions);
  54923. /**
  54924. * Creates a vertex buffer
  54925. * @param vertices the data for the vertex buffer
  54926. * @returns the new WebGL static buffer
  54927. */
  54928. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54929. /**
  54930. * Creates a new index buffer
  54931. * @param indices defines the content of the index buffer
  54932. * @param updatable defines if the index buffer must be updatable
  54933. * @returns a new webGL buffer
  54934. */
  54935. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54936. /**
  54937. * Clear the current render buffer or the current render target (if any is set up)
  54938. * @param color defines the color to use
  54939. * @param backBuffer defines if the back buffer must be cleared
  54940. * @param depth defines if the depth buffer must be cleared
  54941. * @param stencil defines if the stencil buffer must be cleared
  54942. */
  54943. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54944. /**
  54945. * Gets the current render width
  54946. * @param useScreen defines if screen size must be used (or the current render target if any)
  54947. * @returns a number defining the current render width
  54948. */
  54949. getRenderWidth(useScreen?: boolean): number;
  54950. /**
  54951. * Gets the current render height
  54952. * @param useScreen defines if screen size must be used (or the current render target if any)
  54953. * @returns a number defining the current render height
  54954. */
  54955. getRenderHeight(useScreen?: boolean): number;
  54956. /**
  54957. * Set the WebGL's viewport
  54958. * @param viewport defines the viewport element to be used
  54959. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54960. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54961. */
  54962. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54963. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54964. /**
  54965. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54966. * @param pipelineContext defines the pipeline context to use
  54967. * @param uniformsNames defines the list of uniform names
  54968. * @returns an array of webGL uniform locations
  54969. */
  54970. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54971. /**
  54972. * Gets the lsit of active attributes for a given webGL program
  54973. * @param pipelineContext defines the pipeline context to use
  54974. * @param attributesNames defines the list of attribute names to get
  54975. * @returns an array of indices indicating the offset of each attribute
  54976. */
  54977. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54978. /**
  54979. * Binds an effect to the webGL context
  54980. * @param effect defines the effect to bind
  54981. */
  54982. bindSamplers(effect: Effect): void;
  54983. /**
  54984. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54985. * @param effect defines the effect to activate
  54986. */
  54987. enableEffect(effect: Effect): void;
  54988. /**
  54989. * Set various states to the webGL context
  54990. * @param culling defines backface culling state
  54991. * @param zOffset defines the value to apply to zOffset (0 by default)
  54992. * @param force defines if states must be applied even if cache is up to date
  54993. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54994. */
  54995. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54996. /**
  54997. * Set the value of an uniform to an array of int32
  54998. * @param uniform defines the webGL uniform location where to store the value
  54999. * @param array defines the array of int32 to store
  55000. * @returns true if value was set
  55001. */
  55002. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55003. /**
  55004. * Set the value of an uniform to an array of int32 (stored as vec2)
  55005. * @param uniform defines the webGL uniform location where to store the value
  55006. * @param array defines the array of int32 to store
  55007. * @returns true if value was set
  55008. */
  55009. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55010. /**
  55011. * Set the value of an uniform to an array of int32 (stored as vec3)
  55012. * @param uniform defines the webGL uniform location where to store the value
  55013. * @param array defines the array of int32 to store
  55014. * @returns true if value was set
  55015. */
  55016. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55017. /**
  55018. * Set the value of an uniform to an array of int32 (stored as vec4)
  55019. * @param uniform defines the webGL uniform location where to store the value
  55020. * @param array defines the array of int32 to store
  55021. * @returns true if value was set
  55022. */
  55023. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55024. /**
  55025. * Set the value of an uniform to an array of float32
  55026. * @param uniform defines the webGL uniform location where to store the value
  55027. * @param array defines the array of float32 to store
  55028. * @returns true if value was set
  55029. */
  55030. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55031. /**
  55032. * Set the value of an uniform to an array of float32 (stored as vec2)
  55033. * @param uniform defines the webGL uniform location where to store the value
  55034. * @param array defines the array of float32 to store
  55035. * @returns true if value was set
  55036. */
  55037. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55038. /**
  55039. * Set the value of an uniform to an array of float32 (stored as vec3)
  55040. * @param uniform defines the webGL uniform location where to store the value
  55041. * @param array defines the array of float32 to store
  55042. * @returns true if value was set
  55043. */
  55044. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55045. /**
  55046. * Set the value of an uniform to an array of float32 (stored as vec4)
  55047. * @param uniform defines the webGL uniform location where to store the value
  55048. * @param array defines the array of float32 to store
  55049. * @returns true if value was set
  55050. */
  55051. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55052. /**
  55053. * Set the value of an uniform to an array of number
  55054. * @param uniform defines the webGL uniform location where to store the value
  55055. * @param array defines the array of number to store
  55056. * @returns true if value was set
  55057. */
  55058. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55059. /**
  55060. * Set the value of an uniform to an array of number (stored as vec2)
  55061. * @param uniform defines the webGL uniform location where to store the value
  55062. * @param array defines the array of number to store
  55063. * @returns true if value was set
  55064. */
  55065. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55066. /**
  55067. * Set the value of an uniform to an array of number (stored as vec3)
  55068. * @param uniform defines the webGL uniform location where to store the value
  55069. * @param array defines the array of number to store
  55070. * @returns true if value was set
  55071. */
  55072. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55073. /**
  55074. * Set the value of an uniform to an array of number (stored as vec4)
  55075. * @param uniform defines the webGL uniform location where to store the value
  55076. * @param array defines the array of number to store
  55077. * @returns true if value was set
  55078. */
  55079. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55080. /**
  55081. * Set the value of an uniform to an array of float32 (stored as matrices)
  55082. * @param uniform defines the webGL uniform location where to store the value
  55083. * @param matrices defines the array of float32 to store
  55084. * @returns true if value was set
  55085. */
  55086. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55087. /**
  55088. * Set the value of an uniform to a matrix (3x3)
  55089. * @param uniform defines the webGL uniform location where to store the value
  55090. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55091. * @returns true if value was set
  55092. */
  55093. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55094. /**
  55095. * Set the value of an uniform to a matrix (2x2)
  55096. * @param uniform defines the webGL uniform location where to store the value
  55097. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55098. * @returns true if value was set
  55099. */
  55100. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55101. /**
  55102. * Set the value of an uniform to a number (float)
  55103. * @param uniform defines the webGL uniform location where to store the value
  55104. * @param value defines the float number to store
  55105. * @returns true if value was set
  55106. */
  55107. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55108. /**
  55109. * Set the value of an uniform to a vec2
  55110. * @param uniform defines the webGL uniform location where to store the value
  55111. * @param x defines the 1st component of the value
  55112. * @param y defines the 2nd component of the value
  55113. * @returns true if value was set
  55114. */
  55115. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55116. /**
  55117. * Set the value of an uniform to a vec3
  55118. * @param uniform defines the webGL uniform location where to store the value
  55119. * @param x defines the 1st component of the value
  55120. * @param y defines the 2nd component of the value
  55121. * @param z defines the 3rd component of the value
  55122. * @returns true if value was set
  55123. */
  55124. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55125. /**
  55126. * Set the value of an uniform to a boolean
  55127. * @param uniform defines the webGL uniform location where to store the value
  55128. * @param bool defines the boolean to store
  55129. * @returns true if value was set
  55130. */
  55131. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55132. /**
  55133. * Set the value of an uniform to a vec4
  55134. * @param uniform defines the webGL uniform location where to store the value
  55135. * @param x defines the 1st component of the value
  55136. * @param y defines the 2nd component of the value
  55137. * @param z defines the 3rd component of the value
  55138. * @param w defines the 4th component of the value
  55139. * @returns true if value was set
  55140. */
  55141. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55142. /**
  55143. * Sets the current alpha mode
  55144. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55145. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55146. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55147. */
  55148. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55149. /**
  55150. * Bind webGl buffers directly to the webGL context
  55151. * @param vertexBuffers defines the vertex buffer to bind
  55152. * @param indexBuffer defines the index buffer to bind
  55153. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55154. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55155. * @param effect defines the effect associated with the vertex buffer
  55156. */
  55157. bindBuffers(vertexBuffers: {
  55158. [key: string]: VertexBuffer;
  55159. }, indexBuffer: DataBuffer, effect: Effect): void;
  55160. /**
  55161. * Force the entire cache to be cleared
  55162. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55163. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55164. */
  55165. wipeCaches(bruteForce?: boolean): void;
  55166. /**
  55167. * Send a draw order
  55168. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55169. * @param indexStart defines the starting index
  55170. * @param indexCount defines the number of index to draw
  55171. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55172. */
  55173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55174. /**
  55175. * Draw a list of indexed primitives
  55176. * @param fillMode defines the primitive to use
  55177. * @param indexStart defines the starting index
  55178. * @param indexCount defines the number of index to draw
  55179. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55180. */
  55181. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55182. /**
  55183. * Draw a list of unindexed primitives
  55184. * @param fillMode defines the primitive to use
  55185. * @param verticesStart defines the index of first vertex to draw
  55186. * @param verticesCount defines the count of vertices to draw
  55187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55188. */
  55189. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55190. /** @hidden */
  55191. _createTexture(): WebGLTexture;
  55192. /** @hidden */
  55193. _releaseTexture(texture: InternalTexture): void;
  55194. /**
  55195. * Usually called from Texture.ts.
  55196. * Passed information to create a WebGLTexture
  55197. * @param urlArg defines a value which contains one of the following:
  55198. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55199. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55200. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55201. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55202. * @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)
  55203. * @param scene needed for loading to the correct scene
  55204. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55205. * @param onLoad optional callback to be called upon successful completion
  55206. * @param onError optional callback to be called upon failure
  55207. * @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
  55208. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55209. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55210. * @param forcedExtension defines the extension to use to pick the right loader
  55211. * @param mimeType defines an optional mime type
  55212. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55213. */
  55214. 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;
  55215. /**
  55216. * Creates a new render target texture
  55217. * @param size defines the size of the texture
  55218. * @param options defines the options used to create the texture
  55219. * @returns a new render target texture stored in an InternalTexture
  55220. */
  55221. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55222. /**
  55223. * Update the sampling mode of a given texture
  55224. * @param samplingMode defines the required sampling mode
  55225. * @param texture defines the texture to update
  55226. */
  55227. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55228. /**
  55229. * Binds the frame buffer to the specified texture.
  55230. * @param texture The texture to render to or null for the default canvas
  55231. * @param faceIndex The face of the texture to render to in case of cube texture
  55232. * @param requiredWidth The width of the target to render to
  55233. * @param requiredHeight The height of the target to render to
  55234. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55235. * @param lodLevel defines le lod level to bind to the frame buffer
  55236. */
  55237. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55238. /**
  55239. * Unbind the current render target texture from the webGL context
  55240. * @param texture defines the render target texture to unbind
  55241. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55242. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55243. */
  55244. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55245. /**
  55246. * Creates a dynamic vertex buffer
  55247. * @param vertices the data for the dynamic vertex buffer
  55248. * @returns the new WebGL dynamic buffer
  55249. */
  55250. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55251. /**
  55252. * Update the content of a dynamic texture
  55253. * @param texture defines the texture to update
  55254. * @param canvas defines the canvas containing the source
  55255. * @param invertY defines if data must be stored with Y axis inverted
  55256. * @param premulAlpha defines if alpha is stored as premultiplied
  55257. * @param format defines the format of the data
  55258. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55259. */
  55260. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55261. /**
  55262. * Gets a boolean indicating if all created effects are ready
  55263. * @returns true if all effects are ready
  55264. */
  55265. areAllEffectsReady(): boolean;
  55266. /**
  55267. * @hidden
  55268. * Get the current error code of the webGL context
  55269. * @returns the error code
  55270. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55271. */
  55272. getError(): number;
  55273. /** @hidden */
  55274. _getUnpackAlignement(): number;
  55275. /** @hidden */
  55276. _unpackFlipY(value: boolean): void;
  55277. /**
  55278. * Update a dynamic index buffer
  55279. * @param indexBuffer defines the target index buffer
  55280. * @param indices defines the data to update
  55281. * @param offset defines the offset in the target index buffer where update should start
  55282. */
  55283. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55284. /**
  55285. * Updates a dynamic vertex buffer.
  55286. * @param vertexBuffer the vertex buffer to update
  55287. * @param vertices the data used to update the vertex buffer
  55288. * @param byteOffset the byte offset of the data (optional)
  55289. * @param byteLength the byte length of the data (optional)
  55290. */
  55291. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55292. /** @hidden */
  55293. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55294. /** @hidden */
  55295. _bindTexture(channel: number, texture: InternalTexture): void;
  55296. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55297. /**
  55298. * 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
  55299. */
  55300. releaseEffects(): void;
  55301. displayLoadingUI(): void;
  55302. hideLoadingUI(): void;
  55303. /** @hidden */
  55304. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55305. /** @hidden */
  55306. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55307. /** @hidden */
  55308. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55309. /** @hidden */
  55310. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55311. }
  55312. }
  55313. declare module BABYLON {
  55314. /**
  55315. * @hidden
  55316. **/
  55317. export class _TimeToken {
  55318. _startTimeQuery: Nullable<WebGLQuery>;
  55319. _endTimeQuery: Nullable<WebGLQuery>;
  55320. _timeElapsedQuery: Nullable<WebGLQuery>;
  55321. _timeElapsedQueryEnded: boolean;
  55322. }
  55323. }
  55324. declare module BABYLON {
  55325. /** @hidden */
  55326. export class _OcclusionDataStorage {
  55327. /** @hidden */
  55328. occlusionInternalRetryCounter: number;
  55329. /** @hidden */
  55330. isOcclusionQueryInProgress: boolean;
  55331. /** @hidden */
  55332. isOccluded: boolean;
  55333. /** @hidden */
  55334. occlusionRetryCount: number;
  55335. /** @hidden */
  55336. occlusionType: number;
  55337. /** @hidden */
  55338. occlusionQueryAlgorithmType: number;
  55339. }
  55340. interface Engine {
  55341. /**
  55342. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55343. * @return the new query
  55344. */
  55345. createQuery(): WebGLQuery;
  55346. /**
  55347. * Delete and release a webGL query
  55348. * @param query defines the query to delete
  55349. * @return the current engine
  55350. */
  55351. deleteQuery(query: WebGLQuery): Engine;
  55352. /**
  55353. * Check if a given query has resolved and got its value
  55354. * @param query defines the query to check
  55355. * @returns true if the query got its value
  55356. */
  55357. isQueryResultAvailable(query: WebGLQuery): boolean;
  55358. /**
  55359. * Gets the value of a given query
  55360. * @param query defines the query to check
  55361. * @returns the value of the query
  55362. */
  55363. getQueryResult(query: WebGLQuery): number;
  55364. /**
  55365. * Initiates an occlusion query
  55366. * @param algorithmType defines the algorithm to use
  55367. * @param query defines the query to use
  55368. * @returns the current engine
  55369. * @see https://doc.babylonjs.com/features/occlusionquery
  55370. */
  55371. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55372. /**
  55373. * Ends an occlusion query
  55374. * @see https://doc.babylonjs.com/features/occlusionquery
  55375. * @param algorithmType defines the algorithm to use
  55376. * @returns the current engine
  55377. */
  55378. endOcclusionQuery(algorithmType: number): Engine;
  55379. /**
  55380. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55381. * Please note that only one query can be issued at a time
  55382. * @returns a time token used to track the time span
  55383. */
  55384. startTimeQuery(): Nullable<_TimeToken>;
  55385. /**
  55386. * Ends a time query
  55387. * @param token defines the token used to measure the time span
  55388. * @returns the time spent (in ns)
  55389. */
  55390. endTimeQuery(token: _TimeToken): int;
  55391. /** @hidden */
  55392. _currentNonTimestampToken: Nullable<_TimeToken>;
  55393. /** @hidden */
  55394. _createTimeQuery(): WebGLQuery;
  55395. /** @hidden */
  55396. _deleteTimeQuery(query: WebGLQuery): void;
  55397. /** @hidden */
  55398. _getGlAlgorithmType(algorithmType: number): number;
  55399. /** @hidden */
  55400. _getTimeQueryResult(query: WebGLQuery): any;
  55401. /** @hidden */
  55402. _getTimeQueryAvailability(query: WebGLQuery): any;
  55403. }
  55404. interface AbstractMesh {
  55405. /**
  55406. * Backing filed
  55407. * @hidden
  55408. */
  55409. __occlusionDataStorage: _OcclusionDataStorage;
  55410. /**
  55411. * Access property
  55412. * @hidden
  55413. */
  55414. _occlusionDataStorage: _OcclusionDataStorage;
  55415. /**
  55416. * 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.
  55417. * The default value is -1 which means don't break the query and wait till the result
  55418. * @see https://doc.babylonjs.com/features/occlusionquery
  55419. */
  55420. occlusionRetryCount: number;
  55421. /**
  55422. * 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:
  55423. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55424. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55425. * * 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.
  55426. * @see https://doc.babylonjs.com/features/occlusionquery
  55427. */
  55428. occlusionType: number;
  55429. /**
  55430. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55431. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55432. * * 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.
  55433. * @see https://doc.babylonjs.com/features/occlusionquery
  55434. */
  55435. occlusionQueryAlgorithmType: number;
  55436. /**
  55437. * 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
  55438. * @see https://doc.babylonjs.com/features/occlusionquery
  55439. */
  55440. isOccluded: boolean;
  55441. /**
  55442. * Flag to check the progress status of the query
  55443. * @see https://doc.babylonjs.com/features/occlusionquery
  55444. */
  55445. isOcclusionQueryInProgress: boolean;
  55446. }
  55447. }
  55448. declare module BABYLON {
  55449. /** @hidden */
  55450. export var _forceTransformFeedbackToBundle: boolean;
  55451. interface Engine {
  55452. /**
  55453. * Creates a webGL transform feedback object
  55454. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55455. * @returns the webGL transform feedback object
  55456. */
  55457. createTransformFeedback(): WebGLTransformFeedback;
  55458. /**
  55459. * Delete a webGL transform feedback object
  55460. * @param value defines the webGL transform feedback object to delete
  55461. */
  55462. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55463. /**
  55464. * Bind a webGL transform feedback object to the webgl context
  55465. * @param value defines the webGL transform feedback object to bind
  55466. */
  55467. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55468. /**
  55469. * Begins a transform feedback operation
  55470. * @param usePoints defines if points or triangles must be used
  55471. */
  55472. beginTransformFeedback(usePoints: boolean): void;
  55473. /**
  55474. * Ends a transform feedback operation
  55475. */
  55476. endTransformFeedback(): void;
  55477. /**
  55478. * Specify the varyings to use with transform feedback
  55479. * @param program defines the associated webGL program
  55480. * @param value defines the list of strings representing the varying names
  55481. */
  55482. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55483. /**
  55484. * Bind a webGL buffer for a transform feedback operation
  55485. * @param value defines the webGL buffer to bind
  55486. */
  55487. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55488. }
  55489. }
  55490. declare module BABYLON {
  55491. /**
  55492. * Class used to define an additional view for the engine
  55493. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55494. */
  55495. export class EngineView {
  55496. /** Defines the canvas where to render the view */
  55497. target: HTMLCanvasElement;
  55498. /** Defines an optional camera used to render the view (will use active camera else) */
  55499. camera?: Camera;
  55500. }
  55501. interface Engine {
  55502. /**
  55503. * Gets or sets the HTML element to use for attaching events
  55504. */
  55505. inputElement: Nullable<HTMLElement>;
  55506. /**
  55507. * Gets the current engine view
  55508. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55509. */
  55510. activeView: Nullable<EngineView>;
  55511. /** Gets or sets the list of views */
  55512. views: EngineView[];
  55513. /**
  55514. * Register a new child canvas
  55515. * @param canvas defines the canvas to register
  55516. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55517. * @returns the associated view
  55518. */
  55519. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55520. /**
  55521. * Remove a registered child canvas
  55522. * @param canvas defines the canvas to remove
  55523. * @returns the current engine
  55524. */
  55525. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55526. }
  55527. }
  55528. declare module BABYLON {
  55529. interface Engine {
  55530. /** @hidden */
  55531. _excludedCompressedTextures: string[];
  55532. /** @hidden */
  55533. _textureFormatInUse: string;
  55534. /**
  55535. * Gets the list of texture formats supported
  55536. */
  55537. readonly texturesSupported: Array<string>;
  55538. /**
  55539. * Gets the texture format in use
  55540. */
  55541. readonly textureFormatInUse: Nullable<string>;
  55542. /**
  55543. * Set the compressed texture extensions or file names to skip.
  55544. *
  55545. * @param skippedFiles defines the list of those texture files you want to skip
  55546. * Example: [".dds", ".env", "myfile.png"]
  55547. */
  55548. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55549. /**
  55550. * Set the compressed texture format to use, based on the formats you have, and the formats
  55551. * supported by the hardware / browser.
  55552. *
  55553. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55554. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55555. * to API arguments needed to compressed textures. This puts the burden on the container
  55556. * generator to house the arcane code for determining these for current & future formats.
  55557. *
  55558. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55559. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55560. *
  55561. * Note: The result of this call is not taken into account when a texture is base64.
  55562. *
  55563. * @param formatsAvailable defines the list of those format families you have created
  55564. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55565. *
  55566. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55567. * @returns The extension selected.
  55568. */
  55569. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55570. }
  55571. }
  55572. declare module BABYLON {
  55573. /** @hidden */
  55574. export var rgbdEncodePixelShader: {
  55575. name: string;
  55576. shader: string;
  55577. };
  55578. }
  55579. declare module BABYLON {
  55580. /**
  55581. * Raw texture data and descriptor sufficient for WebGL texture upload
  55582. */
  55583. export interface EnvironmentTextureInfo {
  55584. /**
  55585. * Version of the environment map
  55586. */
  55587. version: number;
  55588. /**
  55589. * Width of image
  55590. */
  55591. width: number;
  55592. /**
  55593. * Irradiance information stored in the file.
  55594. */
  55595. irradiance: any;
  55596. /**
  55597. * Specular information stored in the file.
  55598. */
  55599. specular: any;
  55600. }
  55601. /**
  55602. * Defines One Image in the file. It requires only the position in the file
  55603. * as well as the length.
  55604. */
  55605. interface BufferImageData {
  55606. /**
  55607. * Length of the image data.
  55608. */
  55609. length: number;
  55610. /**
  55611. * Position of the data from the null terminator delimiting the end of the JSON.
  55612. */
  55613. position: number;
  55614. }
  55615. /**
  55616. * Defines the specular data enclosed in the file.
  55617. * This corresponds to the version 1 of the data.
  55618. */
  55619. export interface EnvironmentTextureSpecularInfoV1 {
  55620. /**
  55621. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55622. */
  55623. specularDataPosition?: number;
  55624. /**
  55625. * This contains all the images data needed to reconstruct the cubemap.
  55626. */
  55627. mipmaps: Array<BufferImageData>;
  55628. /**
  55629. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55630. */
  55631. lodGenerationScale: number;
  55632. }
  55633. /**
  55634. * Sets of helpers addressing the serialization and deserialization of environment texture
  55635. * stored in a BabylonJS env file.
  55636. * Those files are usually stored as .env files.
  55637. */
  55638. export class EnvironmentTextureTools {
  55639. /**
  55640. * Magic number identifying the env file.
  55641. */
  55642. private static _MagicBytes;
  55643. /**
  55644. * Gets the environment info from an env file.
  55645. * @param data The array buffer containing the .env bytes.
  55646. * @returns the environment file info (the json header) if successfully parsed.
  55647. */
  55648. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55649. /**
  55650. * Creates an environment texture from a loaded cube texture.
  55651. * @param texture defines the cube texture to convert in env file
  55652. * @return a promise containing the environment data if succesfull.
  55653. */
  55654. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55655. /**
  55656. * Creates a JSON representation of the spherical data.
  55657. * @param texture defines the texture containing the polynomials
  55658. * @return the JSON representation of the spherical info
  55659. */
  55660. private static _CreateEnvTextureIrradiance;
  55661. /**
  55662. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55663. * @param data the image data
  55664. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55665. * @return the views described by info providing access to the underlying buffer
  55666. */
  55667. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55668. /**
  55669. * Uploads the texture info contained in the env file to the GPU.
  55670. * @param texture defines the internal texture to upload to
  55671. * @param data defines the data to load
  55672. * @param info defines the texture info retrieved through the GetEnvInfo method
  55673. * @returns a promise
  55674. */
  55675. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55676. private static _OnImageReadyAsync;
  55677. /**
  55678. * Uploads the levels of image data to the GPU.
  55679. * @param texture defines the internal texture to upload to
  55680. * @param imageData defines the array buffer views of image data [mipmap][face]
  55681. * @returns a promise
  55682. */
  55683. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55684. /**
  55685. * Uploads spherical polynomials information to the texture.
  55686. * @param texture defines the texture we are trying to upload the information to
  55687. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55688. */
  55689. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55690. /** @hidden */
  55691. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55692. }
  55693. }
  55694. declare module BABYLON {
  55695. /**
  55696. * Class used to inline functions in shader code
  55697. */
  55698. export class ShaderCodeInliner {
  55699. private static readonly _RegexpFindFunctionNameAndType;
  55700. private _sourceCode;
  55701. private _functionDescr;
  55702. private _numMaxIterations;
  55703. /** Gets or sets the token used to mark the functions to inline */
  55704. inlineToken: string;
  55705. /** Gets or sets the debug mode */
  55706. debug: boolean;
  55707. /** Gets the code after the inlining process */
  55708. get code(): string;
  55709. /**
  55710. * Initializes the inliner
  55711. * @param sourceCode shader code source to inline
  55712. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55713. */
  55714. constructor(sourceCode: string, numMaxIterations?: number);
  55715. /**
  55716. * Start the processing of the shader code
  55717. */
  55718. processCode(): void;
  55719. private _collectFunctions;
  55720. private _processInlining;
  55721. private _extractBetweenMarkers;
  55722. private _skipWhitespaces;
  55723. private _removeComments;
  55724. private _replaceFunctionCallsByCode;
  55725. private _findBackward;
  55726. private _escapeRegExp;
  55727. private _replaceNames;
  55728. }
  55729. }
  55730. declare module BABYLON {
  55731. /**
  55732. * Container for accessors for natively-stored mesh data buffers.
  55733. */
  55734. class NativeDataBuffer extends DataBuffer {
  55735. /**
  55736. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55737. */
  55738. nativeIndexBuffer?: any;
  55739. /**
  55740. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55741. */
  55742. nativeVertexBuffer?: any;
  55743. }
  55744. /** @hidden */
  55745. class NativeTexture extends InternalTexture {
  55746. getInternalTexture(): InternalTexture;
  55747. getViewCount(): number;
  55748. }
  55749. /** @hidden */
  55750. export class NativeEngine extends Engine {
  55751. private readonly _native;
  55752. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55753. private readonly INVALID_HANDLE;
  55754. private _boundBuffersVertexArray;
  55755. private _currentDepthTest;
  55756. getHardwareScalingLevel(): number;
  55757. constructor();
  55758. dispose(): void;
  55759. /**
  55760. * Can be used to override the current requestAnimationFrame requester.
  55761. * @hidden
  55762. */
  55763. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55764. /**
  55765. * Override default engine behavior.
  55766. * @param color
  55767. * @param backBuffer
  55768. * @param depth
  55769. * @param stencil
  55770. */
  55771. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55772. /**
  55773. * Gets host document
  55774. * @returns the host document object
  55775. */
  55776. getHostDocument(): Nullable<Document>;
  55777. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55778. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55779. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55780. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55781. [key: string]: VertexBuffer;
  55782. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55783. bindBuffers(vertexBuffers: {
  55784. [key: string]: VertexBuffer;
  55785. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55786. recordVertexArrayObject(vertexBuffers: {
  55787. [key: string]: VertexBuffer;
  55788. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55789. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55790. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55791. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55792. /**
  55793. * Draw a list of indexed primitives
  55794. * @param fillMode defines the primitive to use
  55795. * @param indexStart defines the starting index
  55796. * @param indexCount defines the number of index to draw
  55797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55798. */
  55799. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55800. /**
  55801. * Draw a list of unindexed primitives
  55802. * @param fillMode defines the primitive to use
  55803. * @param verticesStart defines the index of first vertex to draw
  55804. * @param verticesCount defines the count of vertices to draw
  55805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55806. */
  55807. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55808. createPipelineContext(): IPipelineContext;
  55809. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55810. /** @hidden */
  55811. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55812. /** @hidden */
  55813. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55814. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55815. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55816. protected _setProgram(program: WebGLProgram): void;
  55817. _releaseEffect(effect: Effect): void;
  55818. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55819. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55820. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55821. bindSamplers(effect: Effect): void;
  55822. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55823. getRenderWidth(useScreen?: boolean): number;
  55824. getRenderHeight(useScreen?: boolean): number;
  55825. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55826. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55827. /**
  55828. * Set the z offset to apply to current rendering
  55829. * @param value defines the offset to apply
  55830. */
  55831. setZOffset(value: number): void;
  55832. /**
  55833. * Gets the current value of the zOffset
  55834. * @returns the current zOffset state
  55835. */
  55836. getZOffset(): number;
  55837. /**
  55838. * Enable or disable depth buffering
  55839. * @param enable defines the state to set
  55840. */
  55841. setDepthBuffer(enable: boolean): void;
  55842. /**
  55843. * Gets a boolean indicating if depth writing is enabled
  55844. * @returns the current depth writing state
  55845. */
  55846. getDepthWrite(): boolean;
  55847. setDepthFunctionToGreater(): void;
  55848. setDepthFunctionToGreaterOrEqual(): void;
  55849. setDepthFunctionToLess(): void;
  55850. setDepthFunctionToLessOrEqual(): void;
  55851. /**
  55852. * Enable or disable depth writing
  55853. * @param enable defines the state to set
  55854. */
  55855. setDepthWrite(enable: boolean): void;
  55856. /**
  55857. * Enable or disable color writing
  55858. * @param enable defines the state to set
  55859. */
  55860. setColorWrite(enable: boolean): void;
  55861. /**
  55862. * Gets a boolean indicating if color writing is enabled
  55863. * @returns the current color writing state
  55864. */
  55865. getColorWrite(): boolean;
  55866. /**
  55867. * Sets alpha constants used by some alpha blending modes
  55868. * @param r defines the red component
  55869. * @param g defines the green component
  55870. * @param b defines the blue component
  55871. * @param a defines the alpha component
  55872. */
  55873. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55874. /**
  55875. * Sets the current alpha mode
  55876. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55877. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55878. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55879. */
  55880. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55881. /**
  55882. * Gets the current alpha mode
  55883. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55884. * @returns the current alpha mode
  55885. */
  55886. getAlphaMode(): number;
  55887. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55888. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55889. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55890. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55891. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55892. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55893. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55894. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55895. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55896. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55897. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55898. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55899. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55900. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55901. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55902. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55903. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55904. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55905. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55906. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55907. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55908. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55909. wipeCaches(bruteForce?: boolean): void;
  55910. _createTexture(): WebGLTexture;
  55911. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55912. /**
  55913. * Update the content of a dynamic texture
  55914. * @param texture defines the texture to update
  55915. * @param canvas defines the canvas containing the source
  55916. * @param invertY defines if data must be stored with Y axis inverted
  55917. * @param premulAlpha defines if alpha is stored as premultiplied
  55918. * @param format defines the format of the data
  55919. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55920. */
  55921. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55922. /**
  55923. * Usually called from Texture.ts.
  55924. * Passed information to create a WebGLTexture
  55925. * @param url defines a value which contains one of the following:
  55926. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55927. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55928. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55929. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55930. * @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)
  55931. * @param scene needed for loading to the correct scene
  55932. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55933. * @param onLoad optional callback to be called upon successful completion
  55934. * @param onError optional callback to be called upon failure
  55935. * @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
  55936. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55937. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55938. * @param forcedExtension defines the extension to use to pick the right loader
  55939. * @param mimeType defines an optional mime type
  55940. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55941. */
  55942. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  55943. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  55944. _releaseFramebufferObjects(texture: InternalTexture): void;
  55945. /**
  55946. * Creates a cube texture
  55947. * @param rootUrl defines the url where the files to load is located
  55948. * @param scene defines the current scene
  55949. * @param files defines the list of files to load (1 per face)
  55950. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55951. * @param onLoad defines an optional callback raised when the texture is loaded
  55952. * @param onError defines an optional callback raised if there is an issue to load the texture
  55953. * @param format defines the format of the data
  55954. * @param forcedExtension defines the extension to use to pick the right loader
  55955. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55956. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55957. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55958. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55959. * @returns the cube texture as an InternalTexture
  55960. */
  55961. 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;
  55962. createRenderTargetTexture(size: number | {
  55963. width: number;
  55964. height: number;
  55965. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55966. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55967. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55968. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55969. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55970. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55971. /**
  55972. * Updates a dynamic vertex buffer.
  55973. * @param vertexBuffer the vertex buffer to update
  55974. * @param data the data used to update the vertex buffer
  55975. * @param byteOffset the byte offset of the data (optional)
  55976. * @param byteLength the byte length of the data (optional)
  55977. */
  55978. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55979. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55980. private _updateAnisotropicLevel;
  55981. private _getAddressMode;
  55982. /** @hidden */
  55983. _bindTexture(channel: number, texture: InternalTexture): void;
  55984. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55985. releaseEffects(): void;
  55986. /** @hidden */
  55987. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55988. /** @hidden */
  55989. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55990. /** @hidden */
  55991. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55992. /** @hidden */
  55993. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55994. private _getNativeSamplingMode;
  55995. private _getNativeTextureFormat;
  55996. private _getNativeAlphaMode;
  55997. private _getNativeAttribType;
  55998. }
  55999. }
  56000. declare module BABYLON {
  56001. /**
  56002. * Gather the list of clipboard event types as constants.
  56003. */
  56004. export class ClipboardEventTypes {
  56005. /**
  56006. * The clipboard event is fired when a copy command is active (pressed).
  56007. */
  56008. static readonly COPY: number;
  56009. /**
  56010. * The clipboard event is fired when a cut command is active (pressed).
  56011. */
  56012. static readonly CUT: number;
  56013. /**
  56014. * The clipboard event is fired when a paste command is active (pressed).
  56015. */
  56016. static readonly PASTE: number;
  56017. }
  56018. /**
  56019. * This class is used to store clipboard related info for the onClipboardObservable event.
  56020. */
  56021. export class ClipboardInfo {
  56022. /**
  56023. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56024. */
  56025. type: number;
  56026. /**
  56027. * Defines the related dom event
  56028. */
  56029. event: ClipboardEvent;
  56030. /**
  56031. *Creates an instance of ClipboardInfo.
  56032. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56033. * @param event Defines the related dom event
  56034. */
  56035. constructor(
  56036. /**
  56037. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56038. */
  56039. type: number,
  56040. /**
  56041. * Defines the related dom event
  56042. */
  56043. event: ClipboardEvent);
  56044. /**
  56045. * Get the clipboard event's type from the keycode.
  56046. * @param keyCode Defines the keyCode for the current keyboard event.
  56047. * @return {number}
  56048. */
  56049. static GetTypeFromCharacter(keyCode: number): number;
  56050. }
  56051. }
  56052. declare module BABYLON {
  56053. /**
  56054. * Google Daydream controller
  56055. */
  56056. export class DaydreamController extends WebVRController {
  56057. /**
  56058. * Base Url for the controller model.
  56059. */
  56060. static MODEL_BASE_URL: string;
  56061. /**
  56062. * File name for the controller model.
  56063. */
  56064. static MODEL_FILENAME: string;
  56065. /**
  56066. * Gamepad Id prefix used to identify Daydream Controller.
  56067. */
  56068. static readonly GAMEPAD_ID_PREFIX: string;
  56069. /**
  56070. * Creates a new DaydreamController from a gamepad
  56071. * @param vrGamepad the gamepad that the controller should be created from
  56072. */
  56073. constructor(vrGamepad: any);
  56074. /**
  56075. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56076. * @param scene scene in which to add meshes
  56077. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56078. */
  56079. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56080. /**
  56081. * Called once for each button that changed state since the last frame
  56082. * @param buttonIdx Which button index changed
  56083. * @param state New state of the button
  56084. * @param changes Which properties on the state changed since last frame
  56085. */
  56086. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56087. }
  56088. }
  56089. declare module BABYLON {
  56090. /**
  56091. * Gear VR Controller
  56092. */
  56093. export class GearVRController extends WebVRController {
  56094. /**
  56095. * Base Url for the controller model.
  56096. */
  56097. static MODEL_BASE_URL: string;
  56098. /**
  56099. * File name for the controller model.
  56100. */
  56101. static MODEL_FILENAME: string;
  56102. /**
  56103. * Gamepad Id prefix used to identify this controller.
  56104. */
  56105. static readonly GAMEPAD_ID_PREFIX: string;
  56106. private readonly _buttonIndexToObservableNameMap;
  56107. /**
  56108. * Creates a new GearVRController from a gamepad
  56109. * @param vrGamepad the gamepad that the controller should be created from
  56110. */
  56111. constructor(vrGamepad: any);
  56112. /**
  56113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56114. * @param scene scene in which to add meshes
  56115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56116. */
  56117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56118. /**
  56119. * Called once for each button that changed state since the last frame
  56120. * @param buttonIdx Which button index changed
  56121. * @param state New state of the button
  56122. * @param changes Which properties on the state changed since last frame
  56123. */
  56124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56125. }
  56126. }
  56127. declare module BABYLON {
  56128. /**
  56129. * Generic Controller
  56130. */
  56131. export class GenericController extends WebVRController {
  56132. /**
  56133. * Base Url for the controller model.
  56134. */
  56135. static readonly MODEL_BASE_URL: string;
  56136. /**
  56137. * File name for the controller model.
  56138. */
  56139. static readonly MODEL_FILENAME: string;
  56140. /**
  56141. * Creates a new GenericController from a gamepad
  56142. * @param vrGamepad the gamepad that the controller should be created from
  56143. */
  56144. constructor(vrGamepad: any);
  56145. /**
  56146. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56147. * @param scene scene in which to add meshes
  56148. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56149. */
  56150. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56151. /**
  56152. * Called once for each button that changed state since the last frame
  56153. * @param buttonIdx Which button index changed
  56154. * @param state New state of the button
  56155. * @param changes Which properties on the state changed since last frame
  56156. */
  56157. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56158. }
  56159. }
  56160. declare module BABYLON {
  56161. /**
  56162. * Oculus Touch Controller
  56163. */
  56164. export class OculusTouchController extends WebVRController {
  56165. /**
  56166. * Base Url for the controller model.
  56167. */
  56168. static MODEL_BASE_URL: string;
  56169. /**
  56170. * File name for the left controller model.
  56171. */
  56172. static MODEL_LEFT_FILENAME: string;
  56173. /**
  56174. * File name for the right controller model.
  56175. */
  56176. static MODEL_RIGHT_FILENAME: string;
  56177. /**
  56178. * Base Url for the Quest controller model.
  56179. */
  56180. static QUEST_MODEL_BASE_URL: string;
  56181. /**
  56182. * @hidden
  56183. * If the controllers are running on a device that needs the updated Quest controller models
  56184. */
  56185. static _IsQuest: boolean;
  56186. /**
  56187. * Fired when the secondary trigger on this controller is modified
  56188. */
  56189. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56190. /**
  56191. * Fired when the thumb rest on this controller is modified
  56192. */
  56193. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56194. /**
  56195. * Creates a new OculusTouchController from a gamepad
  56196. * @param vrGamepad the gamepad that the controller should be created from
  56197. */
  56198. constructor(vrGamepad: any);
  56199. /**
  56200. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56201. * @param scene scene in which to add meshes
  56202. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56203. */
  56204. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56205. /**
  56206. * Fired when the A button on this controller is modified
  56207. */
  56208. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56209. /**
  56210. * Fired when the B button on this controller is modified
  56211. */
  56212. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56213. /**
  56214. * Fired when the X button on this controller is modified
  56215. */
  56216. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56217. /**
  56218. * Fired when the Y button on this controller is modified
  56219. */
  56220. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56221. /**
  56222. * Called once for each button that changed state since the last frame
  56223. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56224. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56225. * 2) secondary trigger (same)
  56226. * 3) A (right) X (left), touch, pressed = value
  56227. * 4) B / Y
  56228. * 5) thumb rest
  56229. * @param buttonIdx Which button index changed
  56230. * @param state New state of the button
  56231. * @param changes Which properties on the state changed since last frame
  56232. */
  56233. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56234. }
  56235. }
  56236. declare module BABYLON {
  56237. /**
  56238. * Vive Controller
  56239. */
  56240. export class ViveController extends WebVRController {
  56241. /**
  56242. * Base Url for the controller model.
  56243. */
  56244. static MODEL_BASE_URL: string;
  56245. /**
  56246. * File name for the controller model.
  56247. */
  56248. static MODEL_FILENAME: string;
  56249. /**
  56250. * Creates a new ViveController from a gamepad
  56251. * @param vrGamepad the gamepad that the controller should be created from
  56252. */
  56253. constructor(vrGamepad: any);
  56254. /**
  56255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56256. * @param scene scene in which to add meshes
  56257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56258. */
  56259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56260. /**
  56261. * Fired when the left button on this controller is modified
  56262. */
  56263. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56264. /**
  56265. * Fired when the right button on this controller is modified
  56266. */
  56267. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56268. /**
  56269. * Fired when the menu button on this controller is modified
  56270. */
  56271. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56272. /**
  56273. * Called once for each button that changed state since the last frame
  56274. * Vive mapping:
  56275. * 0: touchpad
  56276. * 1: trigger
  56277. * 2: left AND right buttons
  56278. * 3: menu button
  56279. * @param buttonIdx Which button index changed
  56280. * @param state New state of the button
  56281. * @param changes Which properties on the state changed since last frame
  56282. */
  56283. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56284. }
  56285. }
  56286. declare module BABYLON {
  56287. /**
  56288. * Defines the WindowsMotionController object that the state of the windows motion controller
  56289. */
  56290. export class WindowsMotionController extends WebVRController {
  56291. /**
  56292. * The base url used to load the left and right controller models
  56293. */
  56294. static MODEL_BASE_URL: string;
  56295. /**
  56296. * The name of the left controller model file
  56297. */
  56298. static MODEL_LEFT_FILENAME: string;
  56299. /**
  56300. * The name of the right controller model file
  56301. */
  56302. static MODEL_RIGHT_FILENAME: string;
  56303. /**
  56304. * The controller name prefix for this controller type
  56305. */
  56306. static readonly GAMEPAD_ID_PREFIX: string;
  56307. /**
  56308. * The controller id pattern for this controller type
  56309. */
  56310. private static readonly GAMEPAD_ID_PATTERN;
  56311. private _loadedMeshInfo;
  56312. protected readonly _mapping: {
  56313. buttons: string[];
  56314. buttonMeshNames: {
  56315. trigger: string;
  56316. menu: string;
  56317. grip: string;
  56318. thumbstick: string;
  56319. trackpad: string;
  56320. };
  56321. buttonObservableNames: {
  56322. trigger: string;
  56323. menu: string;
  56324. grip: string;
  56325. thumbstick: string;
  56326. trackpad: string;
  56327. };
  56328. axisMeshNames: string[];
  56329. pointingPoseMeshName: string;
  56330. };
  56331. /**
  56332. * Fired when the trackpad on this controller is clicked
  56333. */
  56334. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56335. /**
  56336. * Fired when the trackpad on this controller is modified
  56337. */
  56338. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56339. /**
  56340. * The current x and y values of this controller's trackpad
  56341. */
  56342. trackpad: StickValues;
  56343. /**
  56344. * Creates a new WindowsMotionController from a gamepad
  56345. * @param vrGamepad the gamepad that the controller should be created from
  56346. */
  56347. constructor(vrGamepad: any);
  56348. /**
  56349. * Fired when the trigger on this controller is modified
  56350. */
  56351. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56352. /**
  56353. * Fired when the menu button on this controller is modified
  56354. */
  56355. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56356. /**
  56357. * Fired when the grip button on this controller is modified
  56358. */
  56359. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56360. /**
  56361. * Fired when the thumbstick button on this controller is modified
  56362. */
  56363. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56364. /**
  56365. * Fired when the touchpad button on this controller is modified
  56366. */
  56367. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56368. /**
  56369. * Fired when the touchpad values on this controller are modified
  56370. */
  56371. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56372. protected _updateTrackpad(): void;
  56373. /**
  56374. * Called once per frame by the engine.
  56375. */
  56376. update(): void;
  56377. /**
  56378. * Called once for each button that changed state since the last frame
  56379. * @param buttonIdx Which button index changed
  56380. * @param state New state of the button
  56381. * @param changes Which properties on the state changed since last frame
  56382. */
  56383. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56384. /**
  56385. * Moves the buttons on the controller mesh based on their current state
  56386. * @param buttonName the name of the button to move
  56387. * @param buttonValue the value of the button which determines the buttons new position
  56388. */
  56389. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56390. /**
  56391. * Moves the axis on the controller mesh based on its current state
  56392. * @param axis the index of the axis
  56393. * @param axisValue the value of the axis which determines the meshes new position
  56394. * @hidden
  56395. */
  56396. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56397. /**
  56398. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56399. * @param scene scene in which to add meshes
  56400. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56401. */
  56402. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56403. /**
  56404. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56405. * can be transformed by button presses and axes values, based on this._mapping.
  56406. *
  56407. * @param scene scene in which the meshes exist
  56408. * @param meshes list of meshes that make up the controller model to process
  56409. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56410. */
  56411. private processModel;
  56412. private createMeshInfo;
  56413. /**
  56414. * Gets the ray of the controller in the direction the controller is pointing
  56415. * @param length the length the resulting ray should be
  56416. * @returns a ray in the direction the controller is pointing
  56417. */
  56418. getForwardRay(length?: number): Ray;
  56419. /**
  56420. * Disposes of the controller
  56421. */
  56422. dispose(): void;
  56423. }
  56424. /**
  56425. * This class represents a new windows motion controller in XR.
  56426. */
  56427. export class XRWindowsMotionController extends WindowsMotionController {
  56428. /**
  56429. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56430. */
  56431. protected readonly _mapping: {
  56432. buttons: string[];
  56433. buttonMeshNames: {
  56434. trigger: string;
  56435. menu: string;
  56436. grip: string;
  56437. thumbstick: string;
  56438. trackpad: string;
  56439. };
  56440. buttonObservableNames: {
  56441. trigger: string;
  56442. menu: string;
  56443. grip: string;
  56444. thumbstick: string;
  56445. trackpad: string;
  56446. };
  56447. axisMeshNames: string[];
  56448. pointingPoseMeshName: string;
  56449. };
  56450. /**
  56451. * Construct a new XR-Based windows motion controller
  56452. *
  56453. * @param gamepadInfo the gamepad object from the browser
  56454. */
  56455. constructor(gamepadInfo: any);
  56456. /**
  56457. * holds the thumbstick values (X,Y)
  56458. */
  56459. thumbstickValues: StickValues;
  56460. /**
  56461. * Fired when the thumbstick on this controller is clicked
  56462. */
  56463. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56464. /**
  56465. * Fired when the thumbstick on this controller is modified
  56466. */
  56467. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56468. /**
  56469. * Fired when the touchpad button on this controller is modified
  56470. */
  56471. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56472. /**
  56473. * Fired when the touchpad values on this controller are modified
  56474. */
  56475. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56476. /**
  56477. * Fired when the thumbstick button on this controller is modified
  56478. * here to prevent breaking changes
  56479. */
  56480. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56481. /**
  56482. * updating the thumbstick(!) and not the trackpad.
  56483. * This is named this way due to the difference between WebVR and XR and to avoid
  56484. * changing the parent class.
  56485. */
  56486. protected _updateTrackpad(): void;
  56487. /**
  56488. * Disposes the class with joy
  56489. */
  56490. dispose(): void;
  56491. }
  56492. }
  56493. declare module BABYLON {
  56494. /**
  56495. * Class containing static functions to help procedurally build meshes
  56496. */
  56497. export class PolyhedronBuilder {
  56498. /**
  56499. * Creates a polyhedron mesh
  56500. * * 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
  56501. * * The parameter `size` (positive float, default 1) sets the polygon size
  56502. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56503. * * 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`
  56504. * * 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
  56505. * * 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)`)
  56506. * * 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
  56507. * * 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
  56508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56509. * * 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
  56510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56511. * @param name defines the name of the mesh
  56512. * @param options defines the options used to create the mesh
  56513. * @param scene defines the hosting scene
  56514. * @returns the polyhedron mesh
  56515. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56516. */
  56517. static CreatePolyhedron(name: string, options: {
  56518. type?: number;
  56519. size?: number;
  56520. sizeX?: number;
  56521. sizeY?: number;
  56522. sizeZ?: number;
  56523. custom?: any;
  56524. faceUV?: Vector4[];
  56525. faceColors?: Color4[];
  56526. flat?: boolean;
  56527. updatable?: boolean;
  56528. sideOrientation?: number;
  56529. frontUVs?: Vector4;
  56530. backUVs?: Vector4;
  56531. }, scene?: Nullable<Scene>): Mesh;
  56532. }
  56533. }
  56534. declare module BABYLON {
  56535. /**
  56536. * Gizmo that enables scaling a mesh along 3 axis
  56537. */
  56538. export class ScaleGizmo extends Gizmo {
  56539. /**
  56540. * Internal gizmo used for interactions on the x axis
  56541. */
  56542. xGizmo: AxisScaleGizmo;
  56543. /**
  56544. * Internal gizmo used for interactions on the y axis
  56545. */
  56546. yGizmo: AxisScaleGizmo;
  56547. /**
  56548. * Internal gizmo used for interactions on the z axis
  56549. */
  56550. zGizmo: AxisScaleGizmo;
  56551. /**
  56552. * Internal gizmo used to scale all axis equally
  56553. */
  56554. uniformScaleGizmo: AxisScaleGizmo;
  56555. private _meshAttached;
  56556. private _nodeAttached;
  56557. private _snapDistance;
  56558. private _uniformScalingMesh;
  56559. private _octahedron;
  56560. private _sensitivity;
  56561. /** Fires an event when any of it's sub gizmos are dragged */
  56562. onDragStartObservable: Observable<unknown>;
  56563. /** Fires an event when any of it's sub gizmos are released from dragging */
  56564. onDragEndObservable: Observable<unknown>;
  56565. get attachedMesh(): Nullable<AbstractMesh>;
  56566. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56567. get attachedNode(): Nullable<Node>;
  56568. set attachedNode(node: Nullable<Node>);
  56569. /**
  56570. * True when the mouse pointer is hovering a gizmo mesh
  56571. */
  56572. get isHovered(): boolean;
  56573. /**
  56574. * Creates a ScaleGizmo
  56575. * @param gizmoLayer The utility layer the gizmo will be added to
  56576. * @param thickness display gizmo axis thickness
  56577. */
  56578. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56579. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56580. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56581. /**
  56582. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56583. */
  56584. set snapDistance(value: number);
  56585. get snapDistance(): number;
  56586. /**
  56587. * Ratio for the scale of the gizmo (Default: 1)
  56588. */
  56589. set scaleRatio(value: number);
  56590. get scaleRatio(): number;
  56591. /**
  56592. * Sensitivity factor for dragging (Default: 1)
  56593. */
  56594. set sensitivity(value: number);
  56595. get sensitivity(): number;
  56596. /**
  56597. * Disposes of the gizmo
  56598. */
  56599. dispose(): void;
  56600. }
  56601. }
  56602. declare module BABYLON {
  56603. /**
  56604. * Single axis scale gizmo
  56605. */
  56606. export class AxisScaleGizmo extends Gizmo {
  56607. /**
  56608. * Drag behavior responsible for the gizmos dragging interactions
  56609. */
  56610. dragBehavior: PointerDragBehavior;
  56611. private _pointerObserver;
  56612. /**
  56613. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56614. */
  56615. snapDistance: number;
  56616. /**
  56617. * Event that fires each time the gizmo snaps to a new location.
  56618. * * snapDistance is the the change in distance
  56619. */
  56620. onSnapObservable: Observable<{
  56621. snapDistance: number;
  56622. }>;
  56623. /**
  56624. * If the scaling operation should be done on all axis (default: false)
  56625. */
  56626. uniformScaling: boolean;
  56627. /**
  56628. * Custom sensitivity value for the drag strength
  56629. */
  56630. sensitivity: number;
  56631. private _isEnabled;
  56632. private _parent;
  56633. private _arrow;
  56634. private _coloredMaterial;
  56635. private _hoverMaterial;
  56636. /**
  56637. * Creates an AxisScaleGizmo
  56638. * @param gizmoLayer The utility layer the gizmo will be added to
  56639. * @param dragAxis The axis which the gizmo will be able to scale on
  56640. * @param color The color of the gizmo
  56641. * @param thickness display gizmo axis thickness
  56642. */
  56643. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56644. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56645. /**
  56646. * If the gizmo is enabled
  56647. */
  56648. set isEnabled(value: boolean);
  56649. get isEnabled(): boolean;
  56650. /**
  56651. * Disposes of the gizmo
  56652. */
  56653. dispose(): void;
  56654. /**
  56655. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56656. * @param mesh The mesh to replace the default mesh of the gizmo
  56657. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56658. */
  56659. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56660. }
  56661. }
  56662. declare module BABYLON {
  56663. /**
  56664. * Bounding box gizmo
  56665. */
  56666. export class BoundingBoxGizmo extends Gizmo {
  56667. private _lineBoundingBox;
  56668. private _rotateSpheresParent;
  56669. private _scaleBoxesParent;
  56670. private _boundingDimensions;
  56671. private _renderObserver;
  56672. private _pointerObserver;
  56673. private _scaleDragSpeed;
  56674. private _tmpQuaternion;
  56675. private _tmpVector;
  56676. private _tmpRotationMatrix;
  56677. /**
  56678. * 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)
  56679. */
  56680. ignoreChildren: boolean;
  56681. /**
  56682. * 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)
  56683. */
  56684. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56685. /**
  56686. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56687. */
  56688. rotationSphereSize: number;
  56689. /**
  56690. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56691. */
  56692. scaleBoxSize: number;
  56693. /**
  56694. * 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)
  56695. */
  56696. fixedDragMeshScreenSize: boolean;
  56697. /**
  56698. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56699. */
  56700. fixedDragMeshScreenSizeDistanceFactor: number;
  56701. /**
  56702. * Fired when a rotation sphere or scale box is dragged
  56703. */
  56704. onDragStartObservable: Observable<{}>;
  56705. /**
  56706. * Fired when a scale box is dragged
  56707. */
  56708. onScaleBoxDragObservable: Observable<{}>;
  56709. /**
  56710. * Fired when a scale box drag is ended
  56711. */
  56712. onScaleBoxDragEndObservable: Observable<{}>;
  56713. /**
  56714. * Fired when a rotation sphere is dragged
  56715. */
  56716. onRotationSphereDragObservable: Observable<{}>;
  56717. /**
  56718. * Fired when a rotation sphere drag is ended
  56719. */
  56720. onRotationSphereDragEndObservable: Observable<{}>;
  56721. /**
  56722. * 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)
  56723. */
  56724. scalePivot: Nullable<Vector3>;
  56725. /**
  56726. * Mesh used as a pivot to rotate the attached node
  56727. */
  56728. private _anchorMesh;
  56729. private _existingMeshScale;
  56730. private _dragMesh;
  56731. private pointerDragBehavior;
  56732. private coloredMaterial;
  56733. private hoverColoredMaterial;
  56734. /**
  56735. * Sets the color of the bounding box gizmo
  56736. * @param color the color to set
  56737. */
  56738. setColor(color: Color3): void;
  56739. /**
  56740. * Creates an BoundingBoxGizmo
  56741. * @param gizmoLayer The utility layer the gizmo will be added to
  56742. * @param color The color of the gizmo
  56743. */
  56744. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56745. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56746. private _selectNode;
  56747. /**
  56748. * Updates the bounding box information for the Gizmo
  56749. */
  56750. updateBoundingBox(): void;
  56751. private _updateRotationSpheres;
  56752. private _updateScaleBoxes;
  56753. /**
  56754. * Enables rotation on the specified axis and disables rotation on the others
  56755. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56756. */
  56757. setEnabledRotationAxis(axis: string): void;
  56758. /**
  56759. * Enables/disables scaling
  56760. * @param enable if scaling should be enabled
  56761. * @param homogeneousScaling defines if scaling should only be homogeneous
  56762. */
  56763. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56764. private _updateDummy;
  56765. /**
  56766. * Enables a pointer drag behavior on the bounding box of the gizmo
  56767. */
  56768. enableDragBehavior(): void;
  56769. /**
  56770. * Disposes of the gizmo
  56771. */
  56772. dispose(): void;
  56773. /**
  56774. * 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)
  56775. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56776. * @returns the bounding box mesh with the passed in mesh as a child
  56777. */
  56778. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56779. /**
  56780. * CustomMeshes are not supported by this gizmo
  56781. * @param mesh The mesh to replace the default mesh of the gizmo
  56782. */
  56783. setCustomMesh(mesh: Mesh): void;
  56784. }
  56785. }
  56786. declare module BABYLON {
  56787. /**
  56788. * Single plane rotation gizmo
  56789. */
  56790. export class PlaneRotationGizmo extends Gizmo {
  56791. /**
  56792. * Drag behavior responsible for the gizmos dragging interactions
  56793. */
  56794. dragBehavior: PointerDragBehavior;
  56795. private _pointerObserver;
  56796. /**
  56797. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56798. */
  56799. snapDistance: number;
  56800. /**
  56801. * Event that fires each time the gizmo snaps to a new location.
  56802. * * snapDistance is the the change in distance
  56803. */
  56804. onSnapObservable: Observable<{
  56805. snapDistance: number;
  56806. }>;
  56807. private _isEnabled;
  56808. private _parent;
  56809. /**
  56810. * Creates a PlaneRotationGizmo
  56811. * @param gizmoLayer The utility layer the gizmo will be added to
  56812. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56813. * @param color The color of the gizmo
  56814. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56815. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56816. * @param thickness display gizmo axis thickness
  56817. */
  56818. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56819. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56820. /**
  56821. * If the gizmo is enabled
  56822. */
  56823. set isEnabled(value: boolean);
  56824. get isEnabled(): boolean;
  56825. /**
  56826. * Disposes of the gizmo
  56827. */
  56828. dispose(): void;
  56829. }
  56830. }
  56831. declare module BABYLON {
  56832. /**
  56833. * Gizmo that enables rotating a mesh along 3 axis
  56834. */
  56835. export class RotationGizmo extends Gizmo {
  56836. /**
  56837. * Internal gizmo used for interactions on the x axis
  56838. */
  56839. xGizmo: PlaneRotationGizmo;
  56840. /**
  56841. * Internal gizmo used for interactions on the y axis
  56842. */
  56843. yGizmo: PlaneRotationGizmo;
  56844. /**
  56845. * Internal gizmo used for interactions on the z axis
  56846. */
  56847. zGizmo: PlaneRotationGizmo;
  56848. /** Fires an event when any of it's sub gizmos are dragged */
  56849. onDragStartObservable: Observable<unknown>;
  56850. /** Fires an event when any of it's sub gizmos are released from dragging */
  56851. onDragEndObservable: Observable<unknown>;
  56852. private _meshAttached;
  56853. private _nodeAttached;
  56854. get attachedMesh(): Nullable<AbstractMesh>;
  56855. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56856. get attachedNode(): Nullable<Node>;
  56857. set attachedNode(node: Nullable<Node>);
  56858. protected _checkBillboardTransform(): void;
  56859. /**
  56860. * True when the mouse pointer is hovering a gizmo mesh
  56861. */
  56862. get isHovered(): boolean;
  56863. /**
  56864. * Creates a RotationGizmo
  56865. * @param gizmoLayer The utility layer the gizmo will be added to
  56866. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56867. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56868. * @param thickness display gizmo axis thickness
  56869. */
  56870. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56871. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56872. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56873. /**
  56874. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56875. */
  56876. set snapDistance(value: number);
  56877. get snapDistance(): number;
  56878. /**
  56879. * Ratio for the scale of the gizmo (Default: 1)
  56880. */
  56881. set scaleRatio(value: number);
  56882. get scaleRatio(): number;
  56883. /**
  56884. * Disposes of the gizmo
  56885. */
  56886. dispose(): void;
  56887. /**
  56888. * CustomMeshes are not supported by this gizmo
  56889. * @param mesh The mesh to replace the default mesh of the gizmo
  56890. */
  56891. setCustomMesh(mesh: Mesh): void;
  56892. }
  56893. }
  56894. declare module BABYLON {
  56895. /**
  56896. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56897. */
  56898. export class GizmoManager implements IDisposable {
  56899. private scene;
  56900. /**
  56901. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56902. */
  56903. gizmos: {
  56904. positionGizmo: Nullable<PositionGizmo>;
  56905. rotationGizmo: Nullable<RotationGizmo>;
  56906. scaleGizmo: Nullable<ScaleGizmo>;
  56907. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56908. };
  56909. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56910. clearGizmoOnEmptyPointerEvent: boolean;
  56911. /** Fires an event when the manager is attached to a mesh */
  56912. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56913. /** Fires an event when the manager is attached to a node */
  56914. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56915. private _gizmosEnabled;
  56916. private _pointerObserver;
  56917. private _attachedMesh;
  56918. private _attachedNode;
  56919. private _boundingBoxColor;
  56920. private _defaultUtilityLayer;
  56921. private _defaultKeepDepthUtilityLayer;
  56922. private _thickness;
  56923. /**
  56924. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56925. */
  56926. boundingBoxDragBehavior: SixDofDragBehavior;
  56927. /**
  56928. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56929. */
  56930. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56931. /**
  56932. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56933. */
  56934. attachableNodes: Nullable<Array<Node>>;
  56935. /**
  56936. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56937. */
  56938. usePointerToAttachGizmos: boolean;
  56939. /**
  56940. * Utility layer that the bounding box gizmo belongs to
  56941. */
  56942. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56943. /**
  56944. * Utility layer that all gizmos besides bounding box belong to
  56945. */
  56946. get utilityLayer(): UtilityLayerRenderer;
  56947. /**
  56948. * True when the mouse pointer is hovering a gizmo mesh
  56949. */
  56950. get isHovered(): boolean;
  56951. /**
  56952. * Instatiates a gizmo manager
  56953. * @param scene the scene to overlay the gizmos on top of
  56954. * @param thickness display gizmo axis thickness
  56955. */
  56956. constructor(scene: Scene, thickness?: number);
  56957. /**
  56958. * Attaches a set of gizmos to the specified mesh
  56959. * @param mesh The mesh the gizmo's should be attached to
  56960. */
  56961. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56962. /**
  56963. * Attaches a set of gizmos to the specified node
  56964. * @param node The node the gizmo's should be attached to
  56965. */
  56966. attachToNode(node: Nullable<Node>): void;
  56967. /**
  56968. * If the position gizmo is enabled
  56969. */
  56970. set positionGizmoEnabled(value: boolean);
  56971. get positionGizmoEnabled(): boolean;
  56972. /**
  56973. * If the rotation gizmo is enabled
  56974. */
  56975. set rotationGizmoEnabled(value: boolean);
  56976. get rotationGizmoEnabled(): boolean;
  56977. /**
  56978. * If the scale gizmo is enabled
  56979. */
  56980. set scaleGizmoEnabled(value: boolean);
  56981. get scaleGizmoEnabled(): boolean;
  56982. /**
  56983. * If the boundingBox gizmo is enabled
  56984. */
  56985. set boundingBoxGizmoEnabled(value: boolean);
  56986. get boundingBoxGizmoEnabled(): boolean;
  56987. /**
  56988. * Disposes of the gizmo manager
  56989. */
  56990. dispose(): void;
  56991. }
  56992. }
  56993. declare module BABYLON {
  56994. /**
  56995. * A directional light is defined by a direction (what a surprise!).
  56996. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56997. * 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.
  56998. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56999. */
  57000. export class DirectionalLight extends ShadowLight {
  57001. private _shadowFrustumSize;
  57002. /**
  57003. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57004. */
  57005. get shadowFrustumSize(): number;
  57006. /**
  57007. * Specifies a fix frustum size for the shadow generation.
  57008. */
  57009. set shadowFrustumSize(value: number);
  57010. private _shadowOrthoScale;
  57011. /**
  57012. * Gets the shadow projection scale against the optimal computed one.
  57013. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57014. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57015. */
  57016. get shadowOrthoScale(): number;
  57017. /**
  57018. * Sets the shadow projection scale against the optimal computed one.
  57019. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57020. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57021. */
  57022. set shadowOrthoScale(value: number);
  57023. /**
  57024. * Automatically compute the projection matrix to best fit (including all the casters)
  57025. * on each frame.
  57026. */
  57027. autoUpdateExtends: boolean;
  57028. /**
  57029. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57030. * on each frame. autoUpdateExtends must be set to true for this to work
  57031. */
  57032. autoCalcShadowZBounds: boolean;
  57033. private _orthoLeft;
  57034. private _orthoRight;
  57035. private _orthoTop;
  57036. private _orthoBottom;
  57037. /**
  57038. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57039. * The directional light is emitted from everywhere in the given direction.
  57040. * It can cast shadows.
  57041. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57042. * @param name The friendly name of the light
  57043. * @param direction The direction of the light
  57044. * @param scene The scene the light belongs to
  57045. */
  57046. constructor(name: string, direction: Vector3, scene: Scene);
  57047. /**
  57048. * Returns the string "DirectionalLight".
  57049. * @return The class name
  57050. */
  57051. getClassName(): string;
  57052. /**
  57053. * Returns the integer 1.
  57054. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57055. */
  57056. getTypeID(): number;
  57057. /**
  57058. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57059. * Returns the DirectionalLight Shadow projection matrix.
  57060. */
  57061. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57062. /**
  57063. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57064. * Returns the DirectionalLight Shadow projection matrix.
  57065. */
  57066. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57067. /**
  57068. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57069. * Returns the DirectionalLight Shadow projection matrix.
  57070. */
  57071. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57072. protected _buildUniformLayout(): void;
  57073. /**
  57074. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57075. * @param effect The effect to update
  57076. * @param lightIndex The index of the light in the effect to update
  57077. * @returns The directional light
  57078. */
  57079. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57080. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57081. /**
  57082. * Gets the minZ used for shadow according to both the scene and the light.
  57083. *
  57084. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57085. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57086. * @param activeCamera The camera we are returning the min for
  57087. * @returns the depth min z
  57088. */
  57089. getDepthMinZ(activeCamera: Camera): number;
  57090. /**
  57091. * Gets the maxZ used for shadow according to both the scene and the light.
  57092. *
  57093. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57094. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57095. * @param activeCamera The camera we are returning the max for
  57096. * @returns the depth max z
  57097. */
  57098. getDepthMaxZ(activeCamera: Camera): number;
  57099. /**
  57100. * Prepares the list of defines specific to the light type.
  57101. * @param defines the list of defines
  57102. * @param lightIndex defines the index of the light for the effect
  57103. */
  57104. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57105. }
  57106. }
  57107. declare module BABYLON {
  57108. /**
  57109. * Class containing static functions to help procedurally build meshes
  57110. */
  57111. export class HemisphereBuilder {
  57112. /**
  57113. * Creates a hemisphere mesh
  57114. * @param name defines the name of the mesh
  57115. * @param options defines the options used to create the mesh
  57116. * @param scene defines the hosting scene
  57117. * @returns the hemisphere mesh
  57118. */
  57119. static CreateHemisphere(name: string, options: {
  57120. segments?: number;
  57121. diameter?: number;
  57122. sideOrientation?: number;
  57123. }, scene: any): Mesh;
  57124. }
  57125. }
  57126. declare module BABYLON {
  57127. /**
  57128. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57129. * These values define a cone of light starting from the position, emitting toward the direction.
  57130. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57131. * and the exponent defines the speed of the decay of the light with distance (reach).
  57132. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57133. */
  57134. export class SpotLight extends ShadowLight {
  57135. private _angle;
  57136. private _innerAngle;
  57137. private _cosHalfAngle;
  57138. private _lightAngleScale;
  57139. private _lightAngleOffset;
  57140. /**
  57141. * Gets the cone angle of the spot light in Radians.
  57142. */
  57143. get angle(): number;
  57144. /**
  57145. * Sets the cone angle of the spot light in Radians.
  57146. */
  57147. set angle(value: number);
  57148. /**
  57149. * Only used in gltf falloff mode, this defines the angle where
  57150. * the directional falloff will start before cutting at angle which could be seen
  57151. * as outer angle.
  57152. */
  57153. get innerAngle(): number;
  57154. /**
  57155. * Only used in gltf falloff mode, this defines the angle where
  57156. * the directional falloff will start before cutting at angle which could be seen
  57157. * as outer angle.
  57158. */
  57159. set innerAngle(value: number);
  57160. private _shadowAngleScale;
  57161. /**
  57162. * Allows scaling the angle of the light for shadow generation only.
  57163. */
  57164. get shadowAngleScale(): number;
  57165. /**
  57166. * Allows scaling the angle of the light for shadow generation only.
  57167. */
  57168. set shadowAngleScale(value: number);
  57169. /**
  57170. * The light decay speed with the distance from the emission spot.
  57171. */
  57172. exponent: number;
  57173. private _projectionTextureMatrix;
  57174. /**
  57175. * Allows reading the projecton texture
  57176. */
  57177. get projectionTextureMatrix(): Matrix;
  57178. protected _projectionTextureLightNear: number;
  57179. /**
  57180. * Gets the near clip of the Spotlight for texture projection.
  57181. */
  57182. get projectionTextureLightNear(): number;
  57183. /**
  57184. * Sets the near clip of the Spotlight for texture projection.
  57185. */
  57186. set projectionTextureLightNear(value: number);
  57187. protected _projectionTextureLightFar: number;
  57188. /**
  57189. * Gets the far clip of the Spotlight for texture projection.
  57190. */
  57191. get projectionTextureLightFar(): number;
  57192. /**
  57193. * Sets the far clip of the Spotlight for texture projection.
  57194. */
  57195. set projectionTextureLightFar(value: number);
  57196. protected _projectionTextureUpDirection: Vector3;
  57197. /**
  57198. * Gets the Up vector of the Spotlight for texture projection.
  57199. */
  57200. get projectionTextureUpDirection(): Vector3;
  57201. /**
  57202. * Sets the Up vector of the Spotlight for texture projection.
  57203. */
  57204. set projectionTextureUpDirection(value: Vector3);
  57205. private _projectionTexture;
  57206. /**
  57207. * Gets the projection texture of the light.
  57208. */
  57209. get projectionTexture(): Nullable<BaseTexture>;
  57210. /**
  57211. * Sets the projection texture of the light.
  57212. */
  57213. set projectionTexture(value: Nullable<BaseTexture>);
  57214. private _projectionTextureViewLightDirty;
  57215. private _projectionTextureProjectionLightDirty;
  57216. private _projectionTextureDirty;
  57217. private _projectionTextureViewTargetVector;
  57218. private _projectionTextureViewLightMatrix;
  57219. private _projectionTextureProjectionLightMatrix;
  57220. private _projectionTextureScalingMatrix;
  57221. /**
  57222. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57223. * It can cast shadows.
  57224. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57225. * @param name The light friendly name
  57226. * @param position The position of the spot light in the scene
  57227. * @param direction The direction of the light in the scene
  57228. * @param angle The cone angle of the light in Radians
  57229. * @param exponent The light decay speed with the distance from the emission spot
  57230. * @param scene The scene the lights belongs to
  57231. */
  57232. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57233. /**
  57234. * Returns the string "SpotLight".
  57235. * @returns the class name
  57236. */
  57237. getClassName(): string;
  57238. /**
  57239. * Returns the integer 2.
  57240. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57241. */
  57242. getTypeID(): number;
  57243. /**
  57244. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57245. */
  57246. protected _setDirection(value: Vector3): void;
  57247. /**
  57248. * Overrides the position setter to recompute the projection texture view light Matrix.
  57249. */
  57250. protected _setPosition(value: Vector3): void;
  57251. /**
  57252. * 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.
  57253. * Returns the SpotLight.
  57254. */
  57255. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57256. protected _computeProjectionTextureViewLightMatrix(): void;
  57257. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57258. /**
  57259. * Main function for light texture projection matrix computing.
  57260. */
  57261. protected _computeProjectionTextureMatrix(): void;
  57262. protected _buildUniformLayout(): void;
  57263. private _computeAngleValues;
  57264. /**
  57265. * Sets the passed Effect "effect" with the Light textures.
  57266. * @param effect The effect to update
  57267. * @param lightIndex The index of the light in the effect to update
  57268. * @returns The light
  57269. */
  57270. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57271. /**
  57272. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57273. * @param effect The effect to update
  57274. * @param lightIndex The index of the light in the effect to update
  57275. * @returns The spot light
  57276. */
  57277. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57278. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57279. /**
  57280. * Disposes the light and the associated resources.
  57281. */
  57282. dispose(): void;
  57283. /**
  57284. * Prepares the list of defines specific to the light type.
  57285. * @param defines the list of defines
  57286. * @param lightIndex defines the index of the light for the effect
  57287. */
  57288. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57289. }
  57290. }
  57291. declare module BABYLON {
  57292. /**
  57293. * Gizmo that enables viewing a light
  57294. */
  57295. export class LightGizmo extends Gizmo {
  57296. private _lightMesh;
  57297. private _material;
  57298. private _cachedPosition;
  57299. private _cachedForward;
  57300. private _attachedMeshParent;
  57301. private _pointerObserver;
  57302. /**
  57303. * Event that fires each time the gizmo is clicked
  57304. */
  57305. onClickedObservable: Observable<Light>;
  57306. /**
  57307. * Creates a LightGizmo
  57308. * @param gizmoLayer The utility layer the gizmo will be added to
  57309. */
  57310. constructor(gizmoLayer?: UtilityLayerRenderer);
  57311. private _light;
  57312. /**
  57313. * The light that the gizmo is attached to
  57314. */
  57315. set light(light: Nullable<Light>);
  57316. get light(): Nullable<Light>;
  57317. /**
  57318. * Gets the material used to render the light gizmo
  57319. */
  57320. get material(): StandardMaterial;
  57321. /**
  57322. * @hidden
  57323. * Updates the gizmo to match the attached mesh's position/rotation
  57324. */
  57325. protected _update(): void;
  57326. private static _Scale;
  57327. /**
  57328. * Creates the lines for a light mesh
  57329. */
  57330. private static _CreateLightLines;
  57331. /**
  57332. * Disposes of the light gizmo
  57333. */
  57334. dispose(): void;
  57335. private static _CreateHemisphericLightMesh;
  57336. private static _CreatePointLightMesh;
  57337. private static _CreateSpotLightMesh;
  57338. private static _CreateDirectionalLightMesh;
  57339. }
  57340. }
  57341. declare module BABYLON {
  57342. /**
  57343. * Gizmo that enables viewing a camera
  57344. */
  57345. export class CameraGizmo extends Gizmo {
  57346. private _cameraMesh;
  57347. private _cameraLinesMesh;
  57348. private _material;
  57349. private _pointerObserver;
  57350. /**
  57351. * Event that fires each time the gizmo is clicked
  57352. */
  57353. onClickedObservable: Observable<Camera>;
  57354. /**
  57355. * Creates a CameraGizmo
  57356. * @param gizmoLayer The utility layer the gizmo will be added to
  57357. */
  57358. constructor(gizmoLayer?: UtilityLayerRenderer);
  57359. private _camera;
  57360. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57361. get displayFrustum(): boolean;
  57362. set displayFrustum(value: boolean);
  57363. /**
  57364. * The camera that the gizmo is attached to
  57365. */
  57366. set camera(camera: Nullable<Camera>);
  57367. get camera(): Nullable<Camera>;
  57368. /**
  57369. * Gets the material used to render the camera gizmo
  57370. */
  57371. get material(): StandardMaterial;
  57372. /**
  57373. * @hidden
  57374. * Updates the gizmo to match the attached mesh's position/rotation
  57375. */
  57376. protected _update(): void;
  57377. private static _Scale;
  57378. private _invProjection;
  57379. /**
  57380. * Disposes of the camera gizmo
  57381. */
  57382. dispose(): void;
  57383. private static _CreateCameraMesh;
  57384. private static _CreateCameraFrustum;
  57385. }
  57386. }
  57387. declare module BABYLON {
  57388. /** @hidden */
  57389. export var backgroundFragmentDeclaration: {
  57390. name: string;
  57391. shader: string;
  57392. };
  57393. }
  57394. declare module BABYLON {
  57395. /** @hidden */
  57396. export var backgroundUboDeclaration: {
  57397. name: string;
  57398. shader: string;
  57399. };
  57400. }
  57401. declare module BABYLON {
  57402. /** @hidden */
  57403. export var backgroundPixelShader: {
  57404. name: string;
  57405. shader: string;
  57406. };
  57407. }
  57408. declare module BABYLON {
  57409. /** @hidden */
  57410. export var backgroundVertexDeclaration: {
  57411. name: string;
  57412. shader: string;
  57413. };
  57414. }
  57415. declare module BABYLON {
  57416. /** @hidden */
  57417. export var backgroundVertexShader: {
  57418. name: string;
  57419. shader: string;
  57420. };
  57421. }
  57422. declare module BABYLON {
  57423. /**
  57424. * Background material used to create an efficient environement around your scene.
  57425. */
  57426. export class BackgroundMaterial extends PushMaterial {
  57427. /**
  57428. * Standard reflectance value at parallel view angle.
  57429. */
  57430. static StandardReflectance0: number;
  57431. /**
  57432. * Standard reflectance value at grazing angle.
  57433. */
  57434. static StandardReflectance90: number;
  57435. protected _primaryColor: Color3;
  57436. /**
  57437. * Key light Color (multiply against the environement texture)
  57438. */
  57439. primaryColor: Color3;
  57440. protected __perceptualColor: Nullable<Color3>;
  57441. /**
  57442. * Experimental Internal Use Only.
  57443. *
  57444. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57445. * This acts as a helper to set the primary color to a more "human friendly" value.
  57446. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57447. * output color as close as possible from the chosen value.
  57448. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57449. * part of lighting setup.)
  57450. */
  57451. get _perceptualColor(): Nullable<Color3>;
  57452. set _perceptualColor(value: Nullable<Color3>);
  57453. protected _primaryColorShadowLevel: float;
  57454. /**
  57455. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57456. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57457. */
  57458. get primaryColorShadowLevel(): float;
  57459. set primaryColorShadowLevel(value: float);
  57460. protected _primaryColorHighlightLevel: float;
  57461. /**
  57462. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57463. * The primary color is used at the level chosen to define what the white area would look.
  57464. */
  57465. get primaryColorHighlightLevel(): float;
  57466. set primaryColorHighlightLevel(value: float);
  57467. protected _reflectionTexture: Nullable<BaseTexture>;
  57468. /**
  57469. * Reflection Texture used in the material.
  57470. * Should be author in a specific way for the best result (refer to the documentation).
  57471. */
  57472. reflectionTexture: Nullable<BaseTexture>;
  57473. protected _reflectionBlur: float;
  57474. /**
  57475. * Reflection Texture level of blur.
  57476. *
  57477. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57478. * texture twice.
  57479. */
  57480. reflectionBlur: float;
  57481. protected _diffuseTexture: Nullable<BaseTexture>;
  57482. /**
  57483. * Diffuse Texture used in the material.
  57484. * Should be author in a specific way for the best result (refer to the documentation).
  57485. */
  57486. diffuseTexture: Nullable<BaseTexture>;
  57487. protected _shadowLights: Nullable<IShadowLight[]>;
  57488. /**
  57489. * Specify the list of lights casting shadow on the material.
  57490. * All scene shadow lights will be included if null.
  57491. */
  57492. shadowLights: Nullable<IShadowLight[]>;
  57493. protected _shadowLevel: float;
  57494. /**
  57495. * Helps adjusting the shadow to a softer level if required.
  57496. * 0 means black shadows and 1 means no shadows.
  57497. */
  57498. shadowLevel: float;
  57499. protected _sceneCenter: Vector3;
  57500. /**
  57501. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57502. * It is usually zero but might be interesting to modify according to your setup.
  57503. */
  57504. sceneCenter: Vector3;
  57505. protected _opacityFresnel: boolean;
  57506. /**
  57507. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57508. * This helps ensuring a nice transition when the camera goes under the ground.
  57509. */
  57510. opacityFresnel: boolean;
  57511. protected _reflectionFresnel: boolean;
  57512. /**
  57513. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57514. * This helps adding a mirror texture on the ground.
  57515. */
  57516. reflectionFresnel: boolean;
  57517. protected _reflectionFalloffDistance: number;
  57518. /**
  57519. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57520. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57521. */
  57522. reflectionFalloffDistance: number;
  57523. protected _reflectionAmount: number;
  57524. /**
  57525. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57526. */
  57527. reflectionAmount: number;
  57528. protected _reflectionReflectance0: number;
  57529. /**
  57530. * This specifies the weight of the reflection at grazing angle.
  57531. */
  57532. reflectionReflectance0: number;
  57533. protected _reflectionReflectance90: number;
  57534. /**
  57535. * This specifies the weight of the reflection at a perpendicular point of view.
  57536. */
  57537. reflectionReflectance90: number;
  57538. /**
  57539. * Sets the reflection reflectance fresnel values according to the default standard
  57540. * empirically know to work well :-)
  57541. */
  57542. set reflectionStandardFresnelWeight(value: number);
  57543. protected _useRGBColor: boolean;
  57544. /**
  57545. * Helps to directly use the maps channels instead of their level.
  57546. */
  57547. useRGBColor: boolean;
  57548. protected _enableNoise: boolean;
  57549. /**
  57550. * This helps reducing the banding effect that could occur on the background.
  57551. */
  57552. enableNoise: boolean;
  57553. /**
  57554. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57555. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57556. * Recommended to be keep at 1.0 except for special cases.
  57557. */
  57558. get fovMultiplier(): number;
  57559. set fovMultiplier(value: number);
  57560. private _fovMultiplier;
  57561. /**
  57562. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57563. */
  57564. useEquirectangularFOV: boolean;
  57565. private _maxSimultaneousLights;
  57566. /**
  57567. * Number of Simultaneous lights allowed on the material.
  57568. */
  57569. maxSimultaneousLights: int;
  57570. private _shadowOnly;
  57571. /**
  57572. * Make the material only render shadows
  57573. */
  57574. shadowOnly: boolean;
  57575. /**
  57576. * Default configuration related to image processing available in the Background Material.
  57577. */
  57578. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57579. /**
  57580. * Keep track of the image processing observer to allow dispose and replace.
  57581. */
  57582. private _imageProcessingObserver;
  57583. /**
  57584. * Attaches a new image processing configuration to the PBR Material.
  57585. * @param configuration (if null the scene configuration will be use)
  57586. */
  57587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57588. /**
  57589. * Gets the image processing configuration used either in this material.
  57590. */
  57591. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57592. /**
  57593. * Sets the Default image processing configuration used either in the this material.
  57594. *
  57595. * If sets to null, the scene one is in use.
  57596. */
  57597. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57598. /**
  57599. * Gets wether the color curves effect is enabled.
  57600. */
  57601. get cameraColorCurvesEnabled(): boolean;
  57602. /**
  57603. * Sets wether the color curves effect is enabled.
  57604. */
  57605. set cameraColorCurvesEnabled(value: boolean);
  57606. /**
  57607. * Gets wether the color grading effect is enabled.
  57608. */
  57609. get cameraColorGradingEnabled(): boolean;
  57610. /**
  57611. * Gets wether the color grading effect is enabled.
  57612. */
  57613. set cameraColorGradingEnabled(value: boolean);
  57614. /**
  57615. * Gets wether tonemapping is enabled or not.
  57616. */
  57617. get cameraToneMappingEnabled(): boolean;
  57618. /**
  57619. * Sets wether tonemapping is enabled or not
  57620. */
  57621. set cameraToneMappingEnabled(value: boolean);
  57622. /**
  57623. * The camera exposure used on this material.
  57624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57625. * This corresponds to a photographic exposure.
  57626. */
  57627. get cameraExposure(): float;
  57628. /**
  57629. * The camera exposure used on this material.
  57630. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57631. * This corresponds to a photographic exposure.
  57632. */
  57633. set cameraExposure(value: float);
  57634. /**
  57635. * Gets The camera contrast used on this material.
  57636. */
  57637. get cameraContrast(): float;
  57638. /**
  57639. * Sets The camera contrast used on this material.
  57640. */
  57641. set cameraContrast(value: float);
  57642. /**
  57643. * Gets the Color Grading 2D Lookup Texture.
  57644. */
  57645. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57646. /**
  57647. * Sets the Color Grading 2D Lookup Texture.
  57648. */
  57649. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57650. /**
  57651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57653. * 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;
  57654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57655. */
  57656. get cameraColorCurves(): Nullable<ColorCurves>;
  57657. /**
  57658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57660. * 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;
  57661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57662. */
  57663. set cameraColorCurves(value: Nullable<ColorCurves>);
  57664. /**
  57665. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57666. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57667. */
  57668. switchToBGR: boolean;
  57669. private _renderTargets;
  57670. private _reflectionControls;
  57671. private _white;
  57672. private _primaryShadowColor;
  57673. private _primaryHighlightColor;
  57674. /**
  57675. * Instantiates a Background Material in the given scene
  57676. * @param name The friendly name of the material
  57677. * @param scene The scene to add the material to
  57678. */
  57679. constructor(name: string, scene: Scene);
  57680. /**
  57681. * Gets a boolean indicating that current material needs to register RTT
  57682. */
  57683. get hasRenderTargetTextures(): boolean;
  57684. /**
  57685. * The entire material has been created in order to prevent overdraw.
  57686. * @returns false
  57687. */
  57688. needAlphaTesting(): boolean;
  57689. /**
  57690. * The entire material has been created in order to prevent overdraw.
  57691. * @returns true if blending is enable
  57692. */
  57693. needAlphaBlending(): boolean;
  57694. /**
  57695. * Checks wether the material is ready to be rendered for a given mesh.
  57696. * @param mesh The mesh to render
  57697. * @param subMesh The submesh to check against
  57698. * @param useInstances Specify wether or not the material is used with instances
  57699. * @returns true if all the dependencies are ready (Textures, Effects...)
  57700. */
  57701. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57702. /**
  57703. * Compute the primary color according to the chosen perceptual color.
  57704. */
  57705. private _computePrimaryColorFromPerceptualColor;
  57706. /**
  57707. * Compute the highlights and shadow colors according to their chosen levels.
  57708. */
  57709. private _computePrimaryColors;
  57710. /**
  57711. * Build the uniform buffer used in the material.
  57712. */
  57713. buildUniformLayout(): void;
  57714. /**
  57715. * Unbind the material.
  57716. */
  57717. unbind(): void;
  57718. /**
  57719. * Bind only the world matrix to the material.
  57720. * @param world The world matrix to bind.
  57721. */
  57722. bindOnlyWorldMatrix(world: Matrix): void;
  57723. /**
  57724. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57725. * @param world The world matrix to bind.
  57726. * @param subMesh The submesh to bind for.
  57727. */
  57728. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57729. /**
  57730. * Checks to see if a texture is used in the material.
  57731. * @param texture - Base texture to use.
  57732. * @returns - Boolean specifying if a texture is used in the material.
  57733. */
  57734. hasTexture(texture: BaseTexture): boolean;
  57735. /**
  57736. * Dispose the material.
  57737. * @param forceDisposeEffect Force disposal of the associated effect.
  57738. * @param forceDisposeTextures Force disposal of the associated textures.
  57739. */
  57740. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57741. /**
  57742. * Clones the material.
  57743. * @param name The cloned name.
  57744. * @returns The cloned material.
  57745. */
  57746. clone(name: string): BackgroundMaterial;
  57747. /**
  57748. * Serializes the current material to its JSON representation.
  57749. * @returns The JSON representation.
  57750. */
  57751. serialize(): any;
  57752. /**
  57753. * Gets the class name of the material
  57754. * @returns "BackgroundMaterial"
  57755. */
  57756. getClassName(): string;
  57757. /**
  57758. * Parse a JSON input to create back a background material.
  57759. * @param source The JSON data to parse
  57760. * @param scene The scene to create the parsed material in
  57761. * @param rootUrl The root url of the assets the material depends upon
  57762. * @returns the instantiated BackgroundMaterial.
  57763. */
  57764. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57765. }
  57766. }
  57767. declare module BABYLON {
  57768. /**
  57769. * Represents the different options available during the creation of
  57770. * a Environment helper.
  57771. *
  57772. * This can control the default ground, skybox and image processing setup of your scene.
  57773. */
  57774. export interface IEnvironmentHelperOptions {
  57775. /**
  57776. * Specifies whether or not to create a ground.
  57777. * True by default.
  57778. */
  57779. createGround: boolean;
  57780. /**
  57781. * Specifies the ground size.
  57782. * 15 by default.
  57783. */
  57784. groundSize: number;
  57785. /**
  57786. * The texture used on the ground for the main color.
  57787. * Comes from the BabylonJS CDN by default.
  57788. *
  57789. * Remarks: Can be either a texture or a url.
  57790. */
  57791. groundTexture: string | BaseTexture;
  57792. /**
  57793. * The color mixed in the ground texture by default.
  57794. * BabylonJS clearColor by default.
  57795. */
  57796. groundColor: Color3;
  57797. /**
  57798. * Specifies the ground opacity.
  57799. * 1 by default.
  57800. */
  57801. groundOpacity: number;
  57802. /**
  57803. * Enables the ground to receive shadows.
  57804. * True by default.
  57805. */
  57806. enableGroundShadow: boolean;
  57807. /**
  57808. * Helps preventing the shadow to be fully black on the ground.
  57809. * 0.5 by default.
  57810. */
  57811. groundShadowLevel: number;
  57812. /**
  57813. * Creates a mirror texture attach to the ground.
  57814. * false by default.
  57815. */
  57816. enableGroundMirror: boolean;
  57817. /**
  57818. * Specifies the ground mirror size ratio.
  57819. * 0.3 by default as the default kernel is 64.
  57820. */
  57821. groundMirrorSizeRatio: number;
  57822. /**
  57823. * Specifies the ground mirror blur kernel size.
  57824. * 64 by default.
  57825. */
  57826. groundMirrorBlurKernel: number;
  57827. /**
  57828. * Specifies the ground mirror visibility amount.
  57829. * 1 by default
  57830. */
  57831. groundMirrorAmount: number;
  57832. /**
  57833. * Specifies the ground mirror reflectance weight.
  57834. * This uses the standard weight of the background material to setup the fresnel effect
  57835. * of the mirror.
  57836. * 1 by default.
  57837. */
  57838. groundMirrorFresnelWeight: number;
  57839. /**
  57840. * Specifies the ground mirror Falloff distance.
  57841. * This can helps reducing the size of the reflection.
  57842. * 0 by Default.
  57843. */
  57844. groundMirrorFallOffDistance: number;
  57845. /**
  57846. * Specifies the ground mirror texture type.
  57847. * Unsigned Int by Default.
  57848. */
  57849. groundMirrorTextureType: number;
  57850. /**
  57851. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57852. * the shown objects.
  57853. */
  57854. groundYBias: number;
  57855. /**
  57856. * Specifies whether or not to create a skybox.
  57857. * True by default.
  57858. */
  57859. createSkybox: boolean;
  57860. /**
  57861. * Specifies the skybox size.
  57862. * 20 by default.
  57863. */
  57864. skyboxSize: number;
  57865. /**
  57866. * The texture used on the skybox for the main color.
  57867. * Comes from the BabylonJS CDN by default.
  57868. *
  57869. * Remarks: Can be either a texture or a url.
  57870. */
  57871. skyboxTexture: string | BaseTexture;
  57872. /**
  57873. * The color mixed in the skybox texture by default.
  57874. * BabylonJS clearColor by default.
  57875. */
  57876. skyboxColor: Color3;
  57877. /**
  57878. * The background rotation around the Y axis of the scene.
  57879. * This helps aligning the key lights of your scene with the background.
  57880. * 0 by default.
  57881. */
  57882. backgroundYRotation: number;
  57883. /**
  57884. * Compute automatically the size of the elements to best fit with the scene.
  57885. */
  57886. sizeAuto: boolean;
  57887. /**
  57888. * Default position of the rootMesh if autoSize is not true.
  57889. */
  57890. rootPosition: Vector3;
  57891. /**
  57892. * Sets up the image processing in the scene.
  57893. * true by default.
  57894. */
  57895. setupImageProcessing: boolean;
  57896. /**
  57897. * The texture used as your environment texture in the scene.
  57898. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57899. *
  57900. * Remarks: Can be either a texture or a url.
  57901. */
  57902. environmentTexture: string | BaseTexture;
  57903. /**
  57904. * The value of the exposure to apply to the scene.
  57905. * 0.6 by default if setupImageProcessing is true.
  57906. */
  57907. cameraExposure: number;
  57908. /**
  57909. * The value of the contrast to apply to the scene.
  57910. * 1.6 by default if setupImageProcessing is true.
  57911. */
  57912. cameraContrast: number;
  57913. /**
  57914. * Specifies whether or not tonemapping should be enabled in the scene.
  57915. * true by default if setupImageProcessing is true.
  57916. */
  57917. toneMappingEnabled: boolean;
  57918. }
  57919. /**
  57920. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57921. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57922. * It also helps with the default setup of your imageProcessing configuration.
  57923. */
  57924. export class EnvironmentHelper {
  57925. /**
  57926. * Default ground texture URL.
  57927. */
  57928. private static _groundTextureCDNUrl;
  57929. /**
  57930. * Default skybox texture URL.
  57931. */
  57932. private static _skyboxTextureCDNUrl;
  57933. /**
  57934. * Default environment texture URL.
  57935. */
  57936. private static _environmentTextureCDNUrl;
  57937. /**
  57938. * Creates the default options for the helper.
  57939. */
  57940. private static _getDefaultOptions;
  57941. private _rootMesh;
  57942. /**
  57943. * Gets the root mesh created by the helper.
  57944. */
  57945. get rootMesh(): Mesh;
  57946. private _skybox;
  57947. /**
  57948. * Gets the skybox created by the helper.
  57949. */
  57950. get skybox(): Nullable<Mesh>;
  57951. private _skyboxTexture;
  57952. /**
  57953. * Gets the skybox texture created by the helper.
  57954. */
  57955. get skyboxTexture(): Nullable<BaseTexture>;
  57956. private _skyboxMaterial;
  57957. /**
  57958. * Gets the skybox material created by the helper.
  57959. */
  57960. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57961. private _ground;
  57962. /**
  57963. * Gets the ground mesh created by the helper.
  57964. */
  57965. get ground(): Nullable<Mesh>;
  57966. private _groundTexture;
  57967. /**
  57968. * Gets the ground texture created by the helper.
  57969. */
  57970. get groundTexture(): Nullable<BaseTexture>;
  57971. private _groundMirror;
  57972. /**
  57973. * Gets the ground mirror created by the helper.
  57974. */
  57975. get groundMirror(): Nullable<MirrorTexture>;
  57976. /**
  57977. * Gets the ground mirror render list to helps pushing the meshes
  57978. * you wish in the ground reflection.
  57979. */
  57980. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57981. private _groundMaterial;
  57982. /**
  57983. * Gets the ground material created by the helper.
  57984. */
  57985. get groundMaterial(): Nullable<BackgroundMaterial>;
  57986. /**
  57987. * Stores the creation options.
  57988. */
  57989. private readonly _scene;
  57990. private _options;
  57991. /**
  57992. * This observable will be notified with any error during the creation of the environment,
  57993. * mainly texture creation errors.
  57994. */
  57995. onErrorObservable: Observable<{
  57996. message?: string;
  57997. exception?: any;
  57998. }>;
  57999. /**
  58000. * constructor
  58001. * @param options Defines the options we want to customize the helper
  58002. * @param scene The scene to add the material to
  58003. */
  58004. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58005. /**
  58006. * Updates the background according to the new options
  58007. * @param options
  58008. */
  58009. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58010. /**
  58011. * Sets the primary color of all the available elements.
  58012. * @param color the main color to affect to the ground and the background
  58013. */
  58014. setMainColor(color: Color3): void;
  58015. /**
  58016. * Setup the image processing according to the specified options.
  58017. */
  58018. private _setupImageProcessing;
  58019. /**
  58020. * Setup the environment texture according to the specified options.
  58021. */
  58022. private _setupEnvironmentTexture;
  58023. /**
  58024. * Setup the background according to the specified options.
  58025. */
  58026. private _setupBackground;
  58027. /**
  58028. * Get the scene sizes according to the setup.
  58029. */
  58030. private _getSceneSize;
  58031. /**
  58032. * Setup the ground according to the specified options.
  58033. */
  58034. private _setupGround;
  58035. /**
  58036. * Setup the ground material according to the specified options.
  58037. */
  58038. private _setupGroundMaterial;
  58039. /**
  58040. * Setup the ground diffuse texture according to the specified options.
  58041. */
  58042. private _setupGroundDiffuseTexture;
  58043. /**
  58044. * Setup the ground mirror texture according to the specified options.
  58045. */
  58046. private _setupGroundMirrorTexture;
  58047. /**
  58048. * Setup the ground to receive the mirror texture.
  58049. */
  58050. private _setupMirrorInGroundMaterial;
  58051. /**
  58052. * Setup the skybox according to the specified options.
  58053. */
  58054. private _setupSkybox;
  58055. /**
  58056. * Setup the skybox material according to the specified options.
  58057. */
  58058. private _setupSkyboxMaterial;
  58059. /**
  58060. * Setup the skybox reflection texture according to the specified options.
  58061. */
  58062. private _setupSkyboxReflectionTexture;
  58063. private _errorHandler;
  58064. /**
  58065. * Dispose all the elements created by the Helper.
  58066. */
  58067. dispose(): void;
  58068. }
  58069. }
  58070. declare module BABYLON {
  58071. /**
  58072. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58073. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58074. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58075. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58076. */
  58077. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58078. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58079. /**
  58080. * Define the source as a Monoscopic panoramic 360/180.
  58081. */
  58082. static readonly MODE_MONOSCOPIC: number;
  58083. /**
  58084. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58085. */
  58086. static readonly MODE_TOPBOTTOM: number;
  58087. /**
  58088. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58089. */
  58090. static readonly MODE_SIDEBYSIDE: number;
  58091. private _halfDome;
  58092. private _crossEye;
  58093. protected _useDirectMapping: boolean;
  58094. /**
  58095. * The texture being displayed on the sphere
  58096. */
  58097. protected _texture: T;
  58098. /**
  58099. * Gets the texture being displayed on the sphere
  58100. */
  58101. get texture(): T;
  58102. /**
  58103. * Sets the texture being displayed on the sphere
  58104. */
  58105. set texture(newTexture: T);
  58106. /**
  58107. * The skybox material
  58108. */
  58109. protected _material: BackgroundMaterial;
  58110. /**
  58111. * The surface used for the dome
  58112. */
  58113. protected _mesh: Mesh;
  58114. /**
  58115. * Gets the mesh used for the dome.
  58116. */
  58117. get mesh(): Mesh;
  58118. /**
  58119. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58120. */
  58121. private _halfDomeMask;
  58122. /**
  58123. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58124. * Also see the options.resolution property.
  58125. */
  58126. get fovMultiplier(): number;
  58127. set fovMultiplier(value: number);
  58128. protected _textureMode: number;
  58129. /**
  58130. * Gets or set the current texture mode for the texture. It can be:
  58131. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58132. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58133. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58134. */
  58135. get textureMode(): number;
  58136. /**
  58137. * Sets the current texture mode for the texture. It can be:
  58138. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58139. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58140. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58141. */
  58142. set textureMode(value: number);
  58143. /**
  58144. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58145. */
  58146. get halfDome(): boolean;
  58147. /**
  58148. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58149. */
  58150. set halfDome(enabled: boolean);
  58151. /**
  58152. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58153. */
  58154. set crossEye(enabled: boolean);
  58155. /**
  58156. * Is it a cross-eye texture?
  58157. */
  58158. get crossEye(): boolean;
  58159. /**
  58160. * The background material of this dome.
  58161. */
  58162. get material(): BackgroundMaterial;
  58163. /**
  58164. * Oberserver used in Stereoscopic VR Mode.
  58165. */
  58166. private _onBeforeCameraRenderObserver;
  58167. /**
  58168. * Observable raised when an error occured while loading the 360 image
  58169. */
  58170. onLoadErrorObservable: Observable<string>;
  58171. /**
  58172. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58173. * @param name Element's name, child elements will append suffixes for their own names.
  58174. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58175. * @param options An object containing optional or exposed sub element properties
  58176. */
  58177. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58178. resolution?: number;
  58179. clickToPlay?: boolean;
  58180. autoPlay?: boolean;
  58181. loop?: boolean;
  58182. size?: number;
  58183. poster?: string;
  58184. faceForward?: boolean;
  58185. useDirectMapping?: boolean;
  58186. halfDomeMode?: boolean;
  58187. crossEyeMode?: boolean;
  58188. generateMipMaps?: boolean;
  58189. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58190. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58191. protected _changeTextureMode(value: number): void;
  58192. /**
  58193. * Releases resources associated with this node.
  58194. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58195. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58196. */
  58197. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58198. }
  58199. }
  58200. declare module BABYLON {
  58201. /**
  58202. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58203. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58204. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58205. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58206. */
  58207. export class PhotoDome extends TextureDome<Texture> {
  58208. /**
  58209. * Define the image as a Monoscopic panoramic 360 image.
  58210. */
  58211. static readonly MODE_MONOSCOPIC: number;
  58212. /**
  58213. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58214. */
  58215. static readonly MODE_TOPBOTTOM: number;
  58216. /**
  58217. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58218. */
  58219. static readonly MODE_SIDEBYSIDE: number;
  58220. /**
  58221. * Gets or sets the texture being displayed on the sphere
  58222. */
  58223. get photoTexture(): Texture;
  58224. /**
  58225. * sets the texture being displayed on the sphere
  58226. */
  58227. set photoTexture(value: Texture);
  58228. /**
  58229. * Gets the current video mode for the video. It can be:
  58230. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58231. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58232. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58233. */
  58234. get imageMode(): number;
  58235. /**
  58236. * Sets the current video mode for the video. It can be:
  58237. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58238. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58239. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58240. */
  58241. set imageMode(value: number);
  58242. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58243. }
  58244. }
  58245. declare module BABYLON {
  58246. /**
  58247. * Direct draw surface info
  58248. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58249. */
  58250. export interface DDSInfo {
  58251. /**
  58252. * Width of the texture
  58253. */
  58254. width: number;
  58255. /**
  58256. * Width of the texture
  58257. */
  58258. height: number;
  58259. /**
  58260. * Number of Mipmaps for the texture
  58261. * @see https://en.wikipedia.org/wiki/Mipmap
  58262. */
  58263. mipmapCount: number;
  58264. /**
  58265. * If the textures format is a known fourCC format
  58266. * @see https://www.fourcc.org/
  58267. */
  58268. isFourCC: boolean;
  58269. /**
  58270. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58271. */
  58272. isRGB: boolean;
  58273. /**
  58274. * If the texture is a lumincance format
  58275. */
  58276. isLuminance: boolean;
  58277. /**
  58278. * If this is a cube texture
  58279. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58280. */
  58281. isCube: boolean;
  58282. /**
  58283. * If the texture is a compressed format eg. FOURCC_DXT1
  58284. */
  58285. isCompressed: boolean;
  58286. /**
  58287. * The dxgiFormat of the texture
  58288. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58289. */
  58290. dxgiFormat: number;
  58291. /**
  58292. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58293. */
  58294. textureType: number;
  58295. /**
  58296. * Sphericle polynomial created for the dds texture
  58297. */
  58298. sphericalPolynomial?: SphericalPolynomial;
  58299. }
  58300. /**
  58301. * Class used to provide DDS decompression tools
  58302. */
  58303. export class DDSTools {
  58304. /**
  58305. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58306. */
  58307. static StoreLODInAlphaChannel: boolean;
  58308. /**
  58309. * Gets DDS information from an array buffer
  58310. * @param data defines the array buffer view to read data from
  58311. * @returns the DDS information
  58312. */
  58313. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58314. private static _FloatView;
  58315. private static _Int32View;
  58316. private static _ToHalfFloat;
  58317. private static _FromHalfFloat;
  58318. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58319. private static _GetHalfFloatRGBAArrayBuffer;
  58320. private static _GetFloatRGBAArrayBuffer;
  58321. private static _GetFloatAsUIntRGBAArrayBuffer;
  58322. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58323. private static _GetRGBAArrayBuffer;
  58324. private static _ExtractLongWordOrder;
  58325. private static _GetRGBArrayBuffer;
  58326. private static _GetLuminanceArrayBuffer;
  58327. /**
  58328. * Uploads DDS Levels to a Babylon Texture
  58329. * @hidden
  58330. */
  58331. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58332. }
  58333. interface ThinEngine {
  58334. /**
  58335. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58336. * @param rootUrl defines the url where the file to load is located
  58337. * @param scene defines the current scene
  58338. * @param lodScale defines scale to apply to the mip map selection
  58339. * @param lodOffset defines offset to apply to the mip map selection
  58340. * @param onLoad defines an optional callback raised when the texture is loaded
  58341. * @param onError defines an optional callback raised if there is an issue to load the texture
  58342. * @param format defines the format of the data
  58343. * @param forcedExtension defines the extension to use to pick the right loader
  58344. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58345. * @returns the cube texture as an InternalTexture
  58346. */
  58347. 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;
  58348. }
  58349. }
  58350. declare module BABYLON {
  58351. /**
  58352. * Implementation of the DDS Texture Loader.
  58353. * @hidden
  58354. */
  58355. export class _DDSTextureLoader implements IInternalTextureLoader {
  58356. /**
  58357. * Defines wether the loader supports cascade loading the different faces.
  58358. */
  58359. readonly supportCascades: boolean;
  58360. /**
  58361. * This returns if the loader support the current file information.
  58362. * @param extension defines the file extension of the file being loaded
  58363. * @returns true if the loader can load the specified file
  58364. */
  58365. canLoad(extension: string): boolean;
  58366. /**
  58367. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58368. * @param data contains the texture data
  58369. * @param texture defines the BabylonJS internal texture
  58370. * @param createPolynomials will be true if polynomials have been requested
  58371. * @param onLoad defines the callback to trigger once the texture is ready
  58372. * @param onError defines the callback to trigger in case of error
  58373. */
  58374. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58375. /**
  58376. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58377. * @param data contains the texture data
  58378. * @param texture defines the BabylonJS internal texture
  58379. * @param callback defines the method to call once ready to upload
  58380. */
  58381. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58382. }
  58383. }
  58384. declare module BABYLON {
  58385. /**
  58386. * Implementation of the ENV Texture Loader.
  58387. * @hidden
  58388. */
  58389. export class _ENVTextureLoader implements IInternalTextureLoader {
  58390. /**
  58391. * Defines wether the loader supports cascade loading the different faces.
  58392. */
  58393. readonly supportCascades: boolean;
  58394. /**
  58395. * This returns if the loader support the current file information.
  58396. * @param extension defines the file extension of the file being loaded
  58397. * @returns true if the loader can load the specified file
  58398. */
  58399. canLoad(extension: string): boolean;
  58400. /**
  58401. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58402. * @param data contains the texture data
  58403. * @param texture defines the BabylonJS internal texture
  58404. * @param createPolynomials will be true if polynomials have been requested
  58405. * @param onLoad defines the callback to trigger once the texture is ready
  58406. * @param onError defines the callback to trigger in case of error
  58407. */
  58408. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58409. /**
  58410. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58411. * @param data contains the texture data
  58412. * @param texture defines the BabylonJS internal texture
  58413. * @param callback defines the method to call once ready to upload
  58414. */
  58415. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58416. }
  58417. }
  58418. declare module BABYLON {
  58419. /**
  58420. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58421. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58422. */
  58423. export class KhronosTextureContainer {
  58424. /** contents of the KTX container file */
  58425. data: ArrayBufferView;
  58426. private static HEADER_LEN;
  58427. private static COMPRESSED_2D;
  58428. private static COMPRESSED_3D;
  58429. private static TEX_2D;
  58430. private static TEX_3D;
  58431. /**
  58432. * Gets the openGL type
  58433. */
  58434. glType: number;
  58435. /**
  58436. * Gets the openGL type size
  58437. */
  58438. glTypeSize: number;
  58439. /**
  58440. * Gets the openGL format
  58441. */
  58442. glFormat: number;
  58443. /**
  58444. * Gets the openGL internal format
  58445. */
  58446. glInternalFormat: number;
  58447. /**
  58448. * Gets the base internal format
  58449. */
  58450. glBaseInternalFormat: number;
  58451. /**
  58452. * Gets image width in pixel
  58453. */
  58454. pixelWidth: number;
  58455. /**
  58456. * Gets image height in pixel
  58457. */
  58458. pixelHeight: number;
  58459. /**
  58460. * Gets image depth in pixels
  58461. */
  58462. pixelDepth: number;
  58463. /**
  58464. * Gets the number of array elements
  58465. */
  58466. numberOfArrayElements: number;
  58467. /**
  58468. * Gets the number of faces
  58469. */
  58470. numberOfFaces: number;
  58471. /**
  58472. * Gets the number of mipmap levels
  58473. */
  58474. numberOfMipmapLevels: number;
  58475. /**
  58476. * Gets the bytes of key value data
  58477. */
  58478. bytesOfKeyValueData: number;
  58479. /**
  58480. * Gets the load type
  58481. */
  58482. loadType: number;
  58483. /**
  58484. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58485. */
  58486. isInvalid: boolean;
  58487. /**
  58488. * Creates a new KhronosTextureContainer
  58489. * @param data contents of the KTX container file
  58490. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58491. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58492. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58493. */
  58494. constructor(
  58495. /** contents of the KTX container file */
  58496. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58497. /**
  58498. * Uploads KTX content to a Babylon Texture.
  58499. * It is assumed that the texture has already been created & is currently bound
  58500. * @hidden
  58501. */
  58502. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58503. private _upload2DCompressedLevels;
  58504. /**
  58505. * Checks if the given data starts with a KTX file identifier.
  58506. * @param data the data to check
  58507. * @returns true if the data is a KTX file or false otherwise
  58508. */
  58509. static IsValid(data: ArrayBufferView): boolean;
  58510. }
  58511. }
  58512. declare module BABYLON {
  58513. /**
  58514. * Helper class to push actions to a pool of workers.
  58515. */
  58516. export class WorkerPool implements IDisposable {
  58517. private _workerInfos;
  58518. private _pendingActions;
  58519. /**
  58520. * Constructor
  58521. * @param workers Array of workers to use for actions
  58522. */
  58523. constructor(workers: Array<Worker>);
  58524. /**
  58525. * Terminates all workers and clears any pending actions.
  58526. */
  58527. dispose(): void;
  58528. /**
  58529. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58530. * pended until a worker has completed its action.
  58531. * @param action The action to perform. Call onComplete when the action is complete.
  58532. */
  58533. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58534. private _execute;
  58535. }
  58536. }
  58537. declare module BABYLON {
  58538. /**
  58539. * Class for loading KTX2 files
  58540. */
  58541. export class KhronosTextureContainer2 {
  58542. private static _WorkerPoolPromise?;
  58543. private static _Initialized;
  58544. private static _Ktx2Decoder;
  58545. /**
  58546. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58547. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58548. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58549. * Urls you can change:
  58550. * URLConfig.jsDecoderModule
  58551. * URLConfig.wasmUASTCToASTC
  58552. * URLConfig.wasmUASTCToBC7
  58553. * URLConfig.jsMSCTranscoder
  58554. * URLConfig.wasmMSCTranscoder
  58555. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58556. */
  58557. static URLConfig: {
  58558. jsDecoderModule: string;
  58559. wasmUASTCToASTC: null;
  58560. wasmUASTCToBC7: null;
  58561. jsMSCTranscoder: null;
  58562. wasmMSCTranscoder: null;
  58563. };
  58564. /**
  58565. * Default number of workers used to handle data decoding
  58566. */
  58567. static DefaultNumWorkers: number;
  58568. private static GetDefaultNumWorkers;
  58569. private _engine;
  58570. private static _CreateWorkerPool;
  58571. /**
  58572. * Constructor
  58573. * @param engine The engine to use
  58574. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58575. */
  58576. constructor(engine: ThinEngine, numWorkers?: number);
  58577. /** @hidden */
  58578. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58579. /**
  58580. * Stop all async operations and release resources.
  58581. */
  58582. dispose(): void;
  58583. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58584. /**
  58585. * Checks if the given data starts with a KTX2 file identifier.
  58586. * @param data the data to check
  58587. * @returns true if the data is a KTX2 file or false otherwise
  58588. */
  58589. static IsValid(data: ArrayBufferView): boolean;
  58590. }
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * Implementation of the KTX Texture Loader.
  58595. * @hidden
  58596. */
  58597. export class _KTXTextureLoader implements IInternalTextureLoader {
  58598. /**
  58599. * Defines wether the loader supports cascade loading the different faces.
  58600. */
  58601. readonly supportCascades: boolean;
  58602. /**
  58603. * This returns if the loader support the current file information.
  58604. * @param extension defines the file extension of the file being loaded
  58605. * @param mimeType defines the optional mime type of the file being loaded
  58606. * @returns true if the loader can load the specified file
  58607. */
  58608. canLoad(extension: string, mimeType?: string): boolean;
  58609. /**
  58610. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58611. * @param data contains the texture data
  58612. * @param texture defines the BabylonJS internal texture
  58613. * @param createPolynomials will be true if polynomials have been requested
  58614. * @param onLoad defines the callback to trigger once the texture is ready
  58615. * @param onError defines the callback to trigger in case of error
  58616. */
  58617. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58618. /**
  58619. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58620. * @param data contains the texture data
  58621. * @param texture defines the BabylonJS internal texture
  58622. * @param callback defines the method to call once ready to upload
  58623. */
  58624. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58625. }
  58626. }
  58627. declare module BABYLON {
  58628. /** @hidden */
  58629. export var _forceSceneHelpersToBundle: boolean;
  58630. interface Scene {
  58631. /**
  58632. * Creates a default light for the scene.
  58633. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58634. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58635. */
  58636. createDefaultLight(replace?: boolean): void;
  58637. /**
  58638. * Creates a default camera for the scene.
  58639. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58640. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58641. * @param replace has default false, when true replaces the active camera in the scene
  58642. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58643. */
  58644. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58645. /**
  58646. * Creates a default camera and a default light.
  58647. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58648. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58649. * @param replace has the default false, when true replaces the active camera/light in the scene
  58650. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58651. */
  58652. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58653. /**
  58654. * Creates a new sky box
  58655. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58656. * @param environmentTexture defines the texture to use as environment texture
  58657. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58658. * @param scale defines the overall scale of the skybox
  58659. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58660. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58661. * @returns a new mesh holding the sky box
  58662. */
  58663. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58664. /**
  58665. * Creates a new environment
  58666. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58667. * @param options defines the options you can use to configure the environment
  58668. * @returns the new EnvironmentHelper
  58669. */
  58670. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58671. /**
  58672. * Creates a new VREXperienceHelper
  58673. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58674. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58675. * @returns a new VREXperienceHelper
  58676. */
  58677. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58678. /**
  58679. * Creates a new WebXRDefaultExperience
  58680. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58681. * @param options experience options
  58682. * @returns a promise for a new WebXRDefaultExperience
  58683. */
  58684. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58685. }
  58686. }
  58687. declare module BABYLON {
  58688. /**
  58689. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58690. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58691. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58692. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58693. */
  58694. export class VideoDome extends TextureDome<VideoTexture> {
  58695. /**
  58696. * Define the video source as a Monoscopic panoramic 360 video.
  58697. */
  58698. static readonly MODE_MONOSCOPIC: number;
  58699. /**
  58700. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58701. */
  58702. static readonly MODE_TOPBOTTOM: number;
  58703. /**
  58704. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58705. */
  58706. static readonly MODE_SIDEBYSIDE: number;
  58707. /**
  58708. * Get the video texture associated with this video dome
  58709. */
  58710. get videoTexture(): VideoTexture;
  58711. /**
  58712. * Get the video mode of this dome
  58713. */
  58714. get videoMode(): number;
  58715. /**
  58716. * Set the video mode of this dome.
  58717. * @see textureMode
  58718. */
  58719. set videoMode(value: number);
  58720. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58721. }
  58722. }
  58723. declare module BABYLON {
  58724. /**
  58725. * This class can be used to get instrumentation data from a Babylon engine
  58726. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58727. */
  58728. export class EngineInstrumentation implements IDisposable {
  58729. /**
  58730. * Define the instrumented engine.
  58731. */
  58732. engine: Engine;
  58733. private _captureGPUFrameTime;
  58734. private _gpuFrameTimeToken;
  58735. private _gpuFrameTime;
  58736. private _captureShaderCompilationTime;
  58737. private _shaderCompilationTime;
  58738. private _onBeginFrameObserver;
  58739. private _onEndFrameObserver;
  58740. private _onBeforeShaderCompilationObserver;
  58741. private _onAfterShaderCompilationObserver;
  58742. /**
  58743. * Gets the perf counter used for GPU frame time
  58744. */
  58745. get gpuFrameTimeCounter(): PerfCounter;
  58746. /**
  58747. * Gets the GPU frame time capture status
  58748. */
  58749. get captureGPUFrameTime(): boolean;
  58750. /**
  58751. * Enable or disable the GPU frame time capture
  58752. */
  58753. set captureGPUFrameTime(value: boolean);
  58754. /**
  58755. * Gets the perf counter used for shader compilation time
  58756. */
  58757. get shaderCompilationTimeCounter(): PerfCounter;
  58758. /**
  58759. * Gets the shader compilation time capture status
  58760. */
  58761. get captureShaderCompilationTime(): boolean;
  58762. /**
  58763. * Enable or disable the shader compilation time capture
  58764. */
  58765. set captureShaderCompilationTime(value: boolean);
  58766. /**
  58767. * Instantiates a new engine instrumentation.
  58768. * This class can be used to get instrumentation data from a Babylon engine
  58769. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58770. * @param engine Defines the engine to instrument
  58771. */
  58772. constructor(
  58773. /**
  58774. * Define the instrumented engine.
  58775. */
  58776. engine: Engine);
  58777. /**
  58778. * Dispose and release associated resources.
  58779. */
  58780. dispose(): void;
  58781. }
  58782. }
  58783. declare module BABYLON {
  58784. /**
  58785. * This class can be used to get instrumentation data from a Babylon engine
  58786. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58787. */
  58788. export class SceneInstrumentation implements IDisposable {
  58789. /**
  58790. * Defines the scene to instrument
  58791. */
  58792. scene: Scene;
  58793. private _captureActiveMeshesEvaluationTime;
  58794. private _activeMeshesEvaluationTime;
  58795. private _captureRenderTargetsRenderTime;
  58796. private _renderTargetsRenderTime;
  58797. private _captureFrameTime;
  58798. private _frameTime;
  58799. private _captureRenderTime;
  58800. private _renderTime;
  58801. private _captureInterFrameTime;
  58802. private _interFrameTime;
  58803. private _captureParticlesRenderTime;
  58804. private _particlesRenderTime;
  58805. private _captureSpritesRenderTime;
  58806. private _spritesRenderTime;
  58807. private _capturePhysicsTime;
  58808. private _physicsTime;
  58809. private _captureAnimationsTime;
  58810. private _animationsTime;
  58811. private _captureCameraRenderTime;
  58812. private _cameraRenderTime;
  58813. private _onBeforeActiveMeshesEvaluationObserver;
  58814. private _onAfterActiveMeshesEvaluationObserver;
  58815. private _onBeforeRenderTargetsRenderObserver;
  58816. private _onAfterRenderTargetsRenderObserver;
  58817. private _onAfterRenderObserver;
  58818. private _onBeforeDrawPhaseObserver;
  58819. private _onAfterDrawPhaseObserver;
  58820. private _onBeforeAnimationsObserver;
  58821. private _onBeforeParticlesRenderingObserver;
  58822. private _onAfterParticlesRenderingObserver;
  58823. private _onBeforeSpritesRenderingObserver;
  58824. private _onAfterSpritesRenderingObserver;
  58825. private _onBeforePhysicsObserver;
  58826. private _onAfterPhysicsObserver;
  58827. private _onAfterAnimationsObserver;
  58828. private _onBeforeCameraRenderObserver;
  58829. private _onAfterCameraRenderObserver;
  58830. /**
  58831. * Gets the perf counter used for active meshes evaluation time
  58832. */
  58833. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58834. /**
  58835. * Gets the active meshes evaluation time capture status
  58836. */
  58837. get captureActiveMeshesEvaluationTime(): boolean;
  58838. /**
  58839. * Enable or disable the active meshes evaluation time capture
  58840. */
  58841. set captureActiveMeshesEvaluationTime(value: boolean);
  58842. /**
  58843. * Gets the perf counter used for render targets render time
  58844. */
  58845. get renderTargetsRenderTimeCounter(): PerfCounter;
  58846. /**
  58847. * Gets the render targets render time capture status
  58848. */
  58849. get captureRenderTargetsRenderTime(): boolean;
  58850. /**
  58851. * Enable or disable the render targets render time capture
  58852. */
  58853. set captureRenderTargetsRenderTime(value: boolean);
  58854. /**
  58855. * Gets the perf counter used for particles render time
  58856. */
  58857. get particlesRenderTimeCounter(): PerfCounter;
  58858. /**
  58859. * Gets the particles render time capture status
  58860. */
  58861. get captureParticlesRenderTime(): boolean;
  58862. /**
  58863. * Enable or disable the particles render time capture
  58864. */
  58865. set captureParticlesRenderTime(value: boolean);
  58866. /**
  58867. * Gets the perf counter used for sprites render time
  58868. */
  58869. get spritesRenderTimeCounter(): PerfCounter;
  58870. /**
  58871. * Gets the sprites render time capture status
  58872. */
  58873. get captureSpritesRenderTime(): boolean;
  58874. /**
  58875. * Enable or disable the sprites render time capture
  58876. */
  58877. set captureSpritesRenderTime(value: boolean);
  58878. /**
  58879. * Gets the perf counter used for physics time
  58880. */
  58881. get physicsTimeCounter(): PerfCounter;
  58882. /**
  58883. * Gets the physics time capture status
  58884. */
  58885. get capturePhysicsTime(): boolean;
  58886. /**
  58887. * Enable or disable the physics time capture
  58888. */
  58889. set capturePhysicsTime(value: boolean);
  58890. /**
  58891. * Gets the perf counter used for animations time
  58892. */
  58893. get animationsTimeCounter(): PerfCounter;
  58894. /**
  58895. * Gets the animations time capture status
  58896. */
  58897. get captureAnimationsTime(): boolean;
  58898. /**
  58899. * Enable or disable the animations time capture
  58900. */
  58901. set captureAnimationsTime(value: boolean);
  58902. /**
  58903. * Gets the perf counter used for frame time capture
  58904. */
  58905. get frameTimeCounter(): PerfCounter;
  58906. /**
  58907. * Gets the frame time capture status
  58908. */
  58909. get captureFrameTime(): boolean;
  58910. /**
  58911. * Enable or disable the frame time capture
  58912. */
  58913. set captureFrameTime(value: boolean);
  58914. /**
  58915. * Gets the perf counter used for inter-frames time capture
  58916. */
  58917. get interFrameTimeCounter(): PerfCounter;
  58918. /**
  58919. * Gets the inter-frames time capture status
  58920. */
  58921. get captureInterFrameTime(): boolean;
  58922. /**
  58923. * Enable or disable the inter-frames time capture
  58924. */
  58925. set captureInterFrameTime(value: boolean);
  58926. /**
  58927. * Gets the perf counter used for render time capture
  58928. */
  58929. get renderTimeCounter(): PerfCounter;
  58930. /**
  58931. * Gets the render time capture status
  58932. */
  58933. get captureRenderTime(): boolean;
  58934. /**
  58935. * Enable or disable the render time capture
  58936. */
  58937. set captureRenderTime(value: boolean);
  58938. /**
  58939. * Gets the perf counter used for camera render time capture
  58940. */
  58941. get cameraRenderTimeCounter(): PerfCounter;
  58942. /**
  58943. * Gets the camera render time capture status
  58944. */
  58945. get captureCameraRenderTime(): boolean;
  58946. /**
  58947. * Enable or disable the camera render time capture
  58948. */
  58949. set captureCameraRenderTime(value: boolean);
  58950. /**
  58951. * Gets the perf counter used for draw calls
  58952. */
  58953. get drawCallsCounter(): PerfCounter;
  58954. /**
  58955. * Instantiates a new scene instrumentation.
  58956. * This class can be used to get instrumentation data from a Babylon engine
  58957. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58958. * @param scene Defines the scene to instrument
  58959. */
  58960. constructor(
  58961. /**
  58962. * Defines the scene to instrument
  58963. */
  58964. scene: Scene);
  58965. /**
  58966. * Dispose and release associated resources.
  58967. */
  58968. dispose(): void;
  58969. }
  58970. }
  58971. declare module BABYLON {
  58972. /** @hidden */
  58973. export var glowMapGenerationPixelShader: {
  58974. name: string;
  58975. shader: string;
  58976. };
  58977. }
  58978. declare module BABYLON {
  58979. /** @hidden */
  58980. export var glowMapGenerationVertexShader: {
  58981. name: string;
  58982. shader: string;
  58983. };
  58984. }
  58985. declare module BABYLON {
  58986. /**
  58987. * Effect layer options. This helps customizing the behaviour
  58988. * of the effect layer.
  58989. */
  58990. export interface IEffectLayerOptions {
  58991. /**
  58992. * Multiplication factor apply to the canvas size to compute the render target size
  58993. * used to generated the objects (the smaller the faster).
  58994. */
  58995. mainTextureRatio: number;
  58996. /**
  58997. * Enforces a fixed size texture to ensure effect stability across devices.
  58998. */
  58999. mainTextureFixedSize?: number;
  59000. /**
  59001. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59002. */
  59003. alphaBlendingMode: number;
  59004. /**
  59005. * The camera attached to the layer.
  59006. */
  59007. camera: Nullable<Camera>;
  59008. /**
  59009. * The rendering group to draw the layer in.
  59010. */
  59011. renderingGroupId: number;
  59012. }
  59013. /**
  59014. * The effect layer Helps adding post process effect blended with the main pass.
  59015. *
  59016. * This can be for instance use to generate glow or higlight effects on the scene.
  59017. *
  59018. * The effect layer class can not be used directly and is intented to inherited from to be
  59019. * customized per effects.
  59020. */
  59021. export abstract class EffectLayer {
  59022. private _vertexBuffers;
  59023. private _indexBuffer;
  59024. private _cachedDefines;
  59025. private _effectLayerMapGenerationEffect;
  59026. private _effectLayerOptions;
  59027. private _mergeEffect;
  59028. protected _scene: Scene;
  59029. protected _engine: Engine;
  59030. protected _maxSize: number;
  59031. protected _mainTextureDesiredSize: ISize;
  59032. protected _mainTexture: RenderTargetTexture;
  59033. protected _shouldRender: boolean;
  59034. protected _postProcesses: PostProcess[];
  59035. protected _textures: BaseTexture[];
  59036. protected _emissiveTextureAndColor: {
  59037. texture: Nullable<BaseTexture>;
  59038. color: Color4;
  59039. };
  59040. /**
  59041. * The name of the layer
  59042. */
  59043. name: string;
  59044. /**
  59045. * The clear color of the texture used to generate the glow map.
  59046. */
  59047. neutralColor: Color4;
  59048. /**
  59049. * Specifies whether the highlight layer is enabled or not.
  59050. */
  59051. isEnabled: boolean;
  59052. /**
  59053. * Gets the camera attached to the layer.
  59054. */
  59055. get camera(): Nullable<Camera>;
  59056. /**
  59057. * Gets the rendering group id the layer should render in.
  59058. */
  59059. get renderingGroupId(): number;
  59060. set renderingGroupId(renderingGroupId: number);
  59061. /**
  59062. * An event triggered when the effect layer has been disposed.
  59063. */
  59064. onDisposeObservable: Observable<EffectLayer>;
  59065. /**
  59066. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59067. */
  59068. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59069. /**
  59070. * An event triggered when the generated texture is being merged in the scene.
  59071. */
  59072. onBeforeComposeObservable: Observable<EffectLayer>;
  59073. /**
  59074. * An event triggered when the mesh is rendered into the effect render target.
  59075. */
  59076. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59077. /**
  59078. * An event triggered after the mesh has been rendered into the effect render target.
  59079. */
  59080. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59081. /**
  59082. * An event triggered when the generated texture has been merged in the scene.
  59083. */
  59084. onAfterComposeObservable: Observable<EffectLayer>;
  59085. /**
  59086. * An event triggered when the efffect layer changes its size.
  59087. */
  59088. onSizeChangedObservable: Observable<EffectLayer>;
  59089. /** @hidden */
  59090. static _SceneComponentInitialization: (scene: Scene) => void;
  59091. /**
  59092. * Instantiates a new effect Layer and references it in the scene.
  59093. * @param name The name of the layer
  59094. * @param scene The scene to use the layer in
  59095. */
  59096. constructor(
  59097. /** The Friendly of the effect in the scene */
  59098. name: string, scene: Scene);
  59099. /**
  59100. * Get the effect name of the layer.
  59101. * @return The effect name
  59102. */
  59103. abstract getEffectName(): string;
  59104. /**
  59105. * Checks for the readiness of the element composing the layer.
  59106. * @param subMesh the mesh to check for
  59107. * @param useInstances specify whether or not to use instances to render the mesh
  59108. * @return true if ready otherwise, false
  59109. */
  59110. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59111. /**
  59112. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59113. * @returns true if the effect requires stencil during the main canvas render pass.
  59114. */
  59115. abstract needStencil(): boolean;
  59116. /**
  59117. * Create the merge effect. This is the shader use to blit the information back
  59118. * to the main canvas at the end of the scene rendering.
  59119. * @returns The effect containing the shader used to merge the effect on the main canvas
  59120. */
  59121. protected abstract _createMergeEffect(): Effect;
  59122. /**
  59123. * Creates the render target textures and post processes used in the effect layer.
  59124. */
  59125. protected abstract _createTextureAndPostProcesses(): void;
  59126. /**
  59127. * Implementation specific of rendering the generating effect on the main canvas.
  59128. * @param effect The effect used to render through
  59129. */
  59130. protected abstract _internalRender(effect: Effect): void;
  59131. /**
  59132. * Sets the required values for both the emissive texture and and the main color.
  59133. */
  59134. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59135. /**
  59136. * Free any resources and references associated to a mesh.
  59137. * Internal use
  59138. * @param mesh The mesh to free.
  59139. */
  59140. abstract _disposeMesh(mesh: Mesh): void;
  59141. /**
  59142. * Serializes this layer (Glow or Highlight for example)
  59143. * @returns a serialized layer object
  59144. */
  59145. abstract serialize?(): any;
  59146. /**
  59147. * Initializes the effect layer with the required options.
  59148. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59149. */
  59150. protected _init(options: Partial<IEffectLayerOptions>): void;
  59151. /**
  59152. * Generates the index buffer of the full screen quad blending to the main canvas.
  59153. */
  59154. private _generateIndexBuffer;
  59155. /**
  59156. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59157. */
  59158. private _generateVertexBuffer;
  59159. /**
  59160. * Sets the main texture desired size which is the closest power of two
  59161. * of the engine canvas size.
  59162. */
  59163. private _setMainTextureSize;
  59164. /**
  59165. * Creates the main texture for the effect layer.
  59166. */
  59167. protected _createMainTexture(): void;
  59168. /**
  59169. * Adds specific effects defines.
  59170. * @param defines The defines to add specifics to.
  59171. */
  59172. protected _addCustomEffectDefines(defines: string[]): void;
  59173. /**
  59174. * Checks for the readiness of the element composing the layer.
  59175. * @param subMesh the mesh to check for
  59176. * @param useInstances specify whether or not to use instances to render the mesh
  59177. * @param emissiveTexture the associated emissive texture used to generate the glow
  59178. * @return true if ready otherwise, false
  59179. */
  59180. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59181. /**
  59182. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59183. */
  59184. render(): void;
  59185. /**
  59186. * Determine if a given mesh will be used in the current effect.
  59187. * @param mesh mesh to test
  59188. * @returns true if the mesh will be used
  59189. */
  59190. hasMesh(mesh: AbstractMesh): boolean;
  59191. /**
  59192. * Returns true if the layer contains information to display, otherwise false.
  59193. * @returns true if the glow layer should be rendered
  59194. */
  59195. shouldRender(): boolean;
  59196. /**
  59197. * Returns true if the mesh should render, otherwise false.
  59198. * @param mesh The mesh to render
  59199. * @returns true if it should render otherwise false
  59200. */
  59201. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59202. /**
  59203. * Returns true if the mesh can be rendered, otherwise false.
  59204. * @param mesh The mesh to render
  59205. * @param material The material used on the mesh
  59206. * @returns true if it can be rendered otherwise false
  59207. */
  59208. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59209. /**
  59210. * Returns true if the mesh should render, otherwise false.
  59211. * @param mesh The mesh to render
  59212. * @returns true if it should render otherwise false
  59213. */
  59214. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59215. /**
  59216. * Renders the submesh passed in parameter to the generation map.
  59217. */
  59218. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59219. /**
  59220. * Defines whether the current material of the mesh should be use to render the effect.
  59221. * @param mesh defines the current mesh to render
  59222. */
  59223. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59224. /**
  59225. * Rebuild the required buffers.
  59226. * @hidden Internal use only.
  59227. */
  59228. _rebuild(): void;
  59229. /**
  59230. * Dispose only the render target textures and post process.
  59231. */
  59232. private _disposeTextureAndPostProcesses;
  59233. /**
  59234. * Dispose the highlight layer and free resources.
  59235. */
  59236. dispose(): void;
  59237. /**
  59238. * Gets the class name of the effect layer
  59239. * @returns the string with the class name of the effect layer
  59240. */
  59241. getClassName(): string;
  59242. /**
  59243. * Creates an effect layer from parsed effect layer data
  59244. * @param parsedEffectLayer defines effect layer data
  59245. * @param scene defines the current scene
  59246. * @param rootUrl defines the root URL containing the effect layer information
  59247. * @returns a parsed effect Layer
  59248. */
  59249. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59250. }
  59251. }
  59252. declare module BABYLON {
  59253. interface AbstractScene {
  59254. /**
  59255. * The list of effect layers (highlights/glow) added to the scene
  59256. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59257. * @see https://doc.babylonjs.com/how_to/glow_layer
  59258. */
  59259. effectLayers: Array<EffectLayer>;
  59260. /**
  59261. * Removes the given effect layer from this scene.
  59262. * @param toRemove defines the effect layer to remove
  59263. * @returns the index of the removed effect layer
  59264. */
  59265. removeEffectLayer(toRemove: EffectLayer): number;
  59266. /**
  59267. * Adds the given effect layer to this scene
  59268. * @param newEffectLayer defines the effect layer to add
  59269. */
  59270. addEffectLayer(newEffectLayer: EffectLayer): void;
  59271. }
  59272. /**
  59273. * Defines the layer scene component responsible to manage any effect layers
  59274. * in a given scene.
  59275. */
  59276. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59277. /**
  59278. * The component name helpfull to identify the component in the list of scene components.
  59279. */
  59280. readonly name: string;
  59281. /**
  59282. * The scene the component belongs to.
  59283. */
  59284. scene: Scene;
  59285. private _engine;
  59286. private _renderEffects;
  59287. private _needStencil;
  59288. private _previousStencilState;
  59289. /**
  59290. * Creates a new instance of the component for the given scene
  59291. * @param scene Defines the scene to register the component in
  59292. */
  59293. constructor(scene: Scene);
  59294. /**
  59295. * Registers the component in a given scene
  59296. */
  59297. register(): void;
  59298. /**
  59299. * Rebuilds the elements related to this component in case of
  59300. * context lost for instance.
  59301. */
  59302. rebuild(): void;
  59303. /**
  59304. * Serializes the component data to the specified json object
  59305. * @param serializationObject The object to serialize to
  59306. */
  59307. serialize(serializationObject: any): void;
  59308. /**
  59309. * Adds all the elements from the container to the scene
  59310. * @param container the container holding the elements
  59311. */
  59312. addFromContainer(container: AbstractScene): void;
  59313. /**
  59314. * Removes all the elements in the container from the scene
  59315. * @param container contains the elements to remove
  59316. * @param dispose if the removed element should be disposed (default: false)
  59317. */
  59318. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59319. /**
  59320. * Disposes the component and the associated ressources.
  59321. */
  59322. dispose(): void;
  59323. private _isReadyForMesh;
  59324. private _renderMainTexture;
  59325. private _setStencil;
  59326. private _setStencilBack;
  59327. private _draw;
  59328. private _drawCamera;
  59329. private _drawRenderingGroup;
  59330. }
  59331. }
  59332. declare module BABYLON {
  59333. /** @hidden */
  59334. export var glowMapMergePixelShader: {
  59335. name: string;
  59336. shader: string;
  59337. };
  59338. }
  59339. declare module BABYLON {
  59340. /** @hidden */
  59341. export var glowMapMergeVertexShader: {
  59342. name: string;
  59343. shader: string;
  59344. };
  59345. }
  59346. declare module BABYLON {
  59347. interface AbstractScene {
  59348. /**
  59349. * Return a the first highlight layer of the scene with a given name.
  59350. * @param name The name of the highlight layer to look for.
  59351. * @return The highlight layer if found otherwise null.
  59352. */
  59353. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59354. }
  59355. /**
  59356. * Glow layer options. This helps customizing the behaviour
  59357. * of the glow layer.
  59358. */
  59359. export interface IGlowLayerOptions {
  59360. /**
  59361. * Multiplication factor apply to the canvas size to compute the render target size
  59362. * used to generated the glowing objects (the smaller the faster).
  59363. */
  59364. mainTextureRatio: number;
  59365. /**
  59366. * Enforces a fixed size texture to ensure resize independant blur.
  59367. */
  59368. mainTextureFixedSize?: number;
  59369. /**
  59370. * How big is the kernel of the blur texture.
  59371. */
  59372. blurKernelSize: number;
  59373. /**
  59374. * The camera attached to the layer.
  59375. */
  59376. camera: Nullable<Camera>;
  59377. /**
  59378. * Enable MSAA by chosing the number of samples.
  59379. */
  59380. mainTextureSamples?: number;
  59381. /**
  59382. * The rendering group to draw the layer in.
  59383. */
  59384. renderingGroupId: number;
  59385. }
  59386. /**
  59387. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59388. *
  59389. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59390. *
  59391. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59392. */
  59393. export class GlowLayer extends EffectLayer {
  59394. /**
  59395. * Effect Name of the layer.
  59396. */
  59397. static readonly EffectName: string;
  59398. /**
  59399. * The default blur kernel size used for the glow.
  59400. */
  59401. static DefaultBlurKernelSize: number;
  59402. /**
  59403. * The default texture size ratio used for the glow.
  59404. */
  59405. static DefaultTextureRatio: number;
  59406. /**
  59407. * Sets the kernel size of the blur.
  59408. */
  59409. set blurKernelSize(value: number);
  59410. /**
  59411. * Gets the kernel size of the blur.
  59412. */
  59413. get blurKernelSize(): number;
  59414. /**
  59415. * Sets the glow intensity.
  59416. */
  59417. set intensity(value: number);
  59418. /**
  59419. * Gets the glow intensity.
  59420. */
  59421. get intensity(): number;
  59422. private _options;
  59423. private _intensity;
  59424. private _horizontalBlurPostprocess1;
  59425. private _verticalBlurPostprocess1;
  59426. private _horizontalBlurPostprocess2;
  59427. private _verticalBlurPostprocess2;
  59428. private _blurTexture1;
  59429. private _blurTexture2;
  59430. private _postProcesses1;
  59431. private _postProcesses2;
  59432. private _includedOnlyMeshes;
  59433. private _excludedMeshes;
  59434. private _meshesUsingTheirOwnMaterials;
  59435. /**
  59436. * Callback used to let the user override the color selection on a per mesh basis
  59437. */
  59438. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59439. /**
  59440. * Callback used to let the user override the texture selection on a per mesh basis
  59441. */
  59442. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59443. /**
  59444. * Instantiates a new glow Layer and references it to the scene.
  59445. * @param name The name of the layer
  59446. * @param scene The scene to use the layer in
  59447. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59448. */
  59449. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59450. /**
  59451. * Get the effect name of the layer.
  59452. * @return The effect name
  59453. */
  59454. getEffectName(): string;
  59455. /**
  59456. * Create the merge effect. This is the shader use to blit the information back
  59457. * to the main canvas at the end of the scene rendering.
  59458. */
  59459. protected _createMergeEffect(): Effect;
  59460. /**
  59461. * Creates the render target textures and post processes used in the glow layer.
  59462. */
  59463. protected _createTextureAndPostProcesses(): void;
  59464. /**
  59465. * Checks for the readiness of the element composing the layer.
  59466. * @param subMesh the mesh to check for
  59467. * @param useInstances specify wether or not to use instances to render the mesh
  59468. * @param emissiveTexture the associated emissive texture used to generate the glow
  59469. * @return true if ready otherwise, false
  59470. */
  59471. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59472. /**
  59473. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59474. */
  59475. needStencil(): boolean;
  59476. /**
  59477. * Returns true if the mesh can be rendered, otherwise false.
  59478. * @param mesh The mesh to render
  59479. * @param material The material used on the mesh
  59480. * @returns true if it can be rendered otherwise false
  59481. */
  59482. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59483. /**
  59484. * Implementation specific of rendering the generating effect on the main canvas.
  59485. * @param effect The effect used to render through
  59486. */
  59487. protected _internalRender(effect: Effect): void;
  59488. /**
  59489. * Sets the required values for both the emissive texture and and the main color.
  59490. */
  59491. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59492. /**
  59493. * Returns true if the mesh should render, otherwise false.
  59494. * @param mesh The mesh to render
  59495. * @returns true if it should render otherwise false
  59496. */
  59497. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59498. /**
  59499. * Adds specific effects defines.
  59500. * @param defines The defines to add specifics to.
  59501. */
  59502. protected _addCustomEffectDefines(defines: string[]): void;
  59503. /**
  59504. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59505. * @param mesh The mesh to exclude from the glow layer
  59506. */
  59507. addExcludedMesh(mesh: Mesh): void;
  59508. /**
  59509. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59510. * @param mesh The mesh to remove
  59511. */
  59512. removeExcludedMesh(mesh: Mesh): void;
  59513. /**
  59514. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59515. * @param mesh The mesh to include in the glow layer
  59516. */
  59517. addIncludedOnlyMesh(mesh: Mesh): void;
  59518. /**
  59519. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59520. * @param mesh The mesh to remove
  59521. */
  59522. removeIncludedOnlyMesh(mesh: Mesh): void;
  59523. /**
  59524. * Determine if a given mesh will be used in the glow layer
  59525. * @param mesh The mesh to test
  59526. * @returns true if the mesh will be highlighted by the current glow layer
  59527. */
  59528. hasMesh(mesh: AbstractMesh): boolean;
  59529. /**
  59530. * Defines whether the current material of the mesh should be use to render the effect.
  59531. * @param mesh defines the current mesh to render
  59532. */
  59533. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59534. /**
  59535. * Add a mesh to be rendered through its own material and not with emissive only.
  59536. * @param mesh The mesh for which we need to use its material
  59537. */
  59538. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59539. /**
  59540. * Remove a mesh from being rendered through its own material and not with emissive only.
  59541. * @param mesh The mesh for which we need to not use its material
  59542. */
  59543. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59544. /**
  59545. * Free any resources and references associated to a mesh.
  59546. * Internal use
  59547. * @param mesh The mesh to free.
  59548. * @hidden
  59549. */
  59550. _disposeMesh(mesh: Mesh): void;
  59551. /**
  59552. * Gets the class name of the effect layer
  59553. * @returns the string with the class name of the effect layer
  59554. */
  59555. getClassName(): string;
  59556. /**
  59557. * Serializes this glow layer
  59558. * @returns a serialized glow layer object
  59559. */
  59560. serialize(): any;
  59561. /**
  59562. * Creates a Glow Layer from parsed glow layer data
  59563. * @param parsedGlowLayer defines glow layer data
  59564. * @param scene defines the current scene
  59565. * @param rootUrl defines the root URL containing the glow layer information
  59566. * @returns a parsed Glow Layer
  59567. */
  59568. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59569. }
  59570. }
  59571. declare module BABYLON {
  59572. /** @hidden */
  59573. export var glowBlurPostProcessPixelShader: {
  59574. name: string;
  59575. shader: string;
  59576. };
  59577. }
  59578. declare module BABYLON {
  59579. interface AbstractScene {
  59580. /**
  59581. * Return a the first highlight layer of the scene with a given name.
  59582. * @param name The name of the highlight layer to look for.
  59583. * @return The highlight layer if found otherwise null.
  59584. */
  59585. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59586. }
  59587. /**
  59588. * Highlight layer options. This helps customizing the behaviour
  59589. * of the highlight layer.
  59590. */
  59591. export interface IHighlightLayerOptions {
  59592. /**
  59593. * Multiplication factor apply to the canvas size to compute the render target size
  59594. * used to generated the glowing objects (the smaller the faster).
  59595. */
  59596. mainTextureRatio: number;
  59597. /**
  59598. * Enforces a fixed size texture to ensure resize independant blur.
  59599. */
  59600. mainTextureFixedSize?: number;
  59601. /**
  59602. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59603. * of the picture to blur (the smaller the faster).
  59604. */
  59605. blurTextureSizeRatio: number;
  59606. /**
  59607. * How big in texel of the blur texture is the vertical blur.
  59608. */
  59609. blurVerticalSize: number;
  59610. /**
  59611. * How big in texel of the blur texture is the horizontal blur.
  59612. */
  59613. blurHorizontalSize: number;
  59614. /**
  59615. * Alpha blending mode used to apply the blur. Default is combine.
  59616. */
  59617. alphaBlendingMode: number;
  59618. /**
  59619. * The camera attached to the layer.
  59620. */
  59621. camera: Nullable<Camera>;
  59622. /**
  59623. * Should we display highlight as a solid stroke?
  59624. */
  59625. isStroke?: boolean;
  59626. /**
  59627. * The rendering group to draw the layer in.
  59628. */
  59629. renderingGroupId: number;
  59630. }
  59631. /**
  59632. * The highlight layer Helps adding a glow effect around a mesh.
  59633. *
  59634. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59635. * glowy meshes to your scene.
  59636. *
  59637. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59638. */
  59639. export class HighlightLayer extends EffectLayer {
  59640. name: string;
  59641. /**
  59642. * Effect Name of the highlight layer.
  59643. */
  59644. static readonly EffectName: string;
  59645. /**
  59646. * The neutral color used during the preparation of the glow effect.
  59647. * This is black by default as the blend operation is a blend operation.
  59648. */
  59649. static NeutralColor: Color4;
  59650. /**
  59651. * Stencil value used for glowing meshes.
  59652. */
  59653. static GlowingMeshStencilReference: number;
  59654. /**
  59655. * Stencil value used for the other meshes in the scene.
  59656. */
  59657. static NormalMeshStencilReference: number;
  59658. /**
  59659. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59660. */
  59661. innerGlow: boolean;
  59662. /**
  59663. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59664. */
  59665. outerGlow: boolean;
  59666. /**
  59667. * Specifies the horizontal size of the blur.
  59668. */
  59669. set blurHorizontalSize(value: number);
  59670. /**
  59671. * Specifies the vertical size of the blur.
  59672. */
  59673. set blurVerticalSize(value: number);
  59674. /**
  59675. * Gets the horizontal size of the blur.
  59676. */
  59677. get blurHorizontalSize(): number;
  59678. /**
  59679. * Gets the vertical size of the blur.
  59680. */
  59681. get blurVerticalSize(): number;
  59682. /**
  59683. * An event triggered when the highlight layer is being blurred.
  59684. */
  59685. onBeforeBlurObservable: Observable<HighlightLayer>;
  59686. /**
  59687. * An event triggered when the highlight layer has been blurred.
  59688. */
  59689. onAfterBlurObservable: Observable<HighlightLayer>;
  59690. private _instanceGlowingMeshStencilReference;
  59691. private _options;
  59692. private _downSamplePostprocess;
  59693. private _horizontalBlurPostprocess;
  59694. private _verticalBlurPostprocess;
  59695. private _blurTexture;
  59696. private _meshes;
  59697. private _excludedMeshes;
  59698. /**
  59699. * Instantiates a new highlight Layer and references it to the scene..
  59700. * @param name The name of the layer
  59701. * @param scene The scene to use the layer in
  59702. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59703. */
  59704. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59705. /**
  59706. * Get the effect name of the layer.
  59707. * @return The effect name
  59708. */
  59709. getEffectName(): string;
  59710. /**
  59711. * Create the merge effect. This is the shader use to blit the information back
  59712. * to the main canvas at the end of the scene rendering.
  59713. */
  59714. protected _createMergeEffect(): Effect;
  59715. /**
  59716. * Creates the render target textures and post processes used in the highlight layer.
  59717. */
  59718. protected _createTextureAndPostProcesses(): void;
  59719. /**
  59720. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59721. */
  59722. needStencil(): boolean;
  59723. /**
  59724. * Checks for the readiness of the element composing the layer.
  59725. * @param subMesh the mesh to check for
  59726. * @param useInstances specify wether or not to use instances to render the mesh
  59727. * @param emissiveTexture the associated emissive texture used to generate the glow
  59728. * @return true if ready otherwise, false
  59729. */
  59730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59731. /**
  59732. * Implementation specific of rendering the generating effect on the main canvas.
  59733. * @param effect The effect used to render through
  59734. */
  59735. protected _internalRender(effect: Effect): void;
  59736. /**
  59737. * Returns true if the layer contains information to display, otherwise false.
  59738. */
  59739. shouldRender(): boolean;
  59740. /**
  59741. * Returns true if the mesh should render, otherwise false.
  59742. * @param mesh The mesh to render
  59743. * @returns true if it should render otherwise false
  59744. */
  59745. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59746. /**
  59747. * Returns true if the mesh can be rendered, otherwise false.
  59748. * @param mesh The mesh to render
  59749. * @param material The material used on the mesh
  59750. * @returns true if it can be rendered otherwise false
  59751. */
  59752. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59753. /**
  59754. * Adds specific effects defines.
  59755. * @param defines The defines to add specifics to.
  59756. */
  59757. protected _addCustomEffectDefines(defines: string[]): void;
  59758. /**
  59759. * Sets the required values for both the emissive texture and and the main color.
  59760. */
  59761. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59762. /**
  59763. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59764. * @param mesh The mesh to exclude from the highlight layer
  59765. */
  59766. addExcludedMesh(mesh: Mesh): void;
  59767. /**
  59768. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59769. * @param mesh The mesh to highlight
  59770. */
  59771. removeExcludedMesh(mesh: Mesh): void;
  59772. /**
  59773. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59774. * @param mesh mesh to test
  59775. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59776. */
  59777. hasMesh(mesh: AbstractMesh): boolean;
  59778. /**
  59779. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59780. * @param mesh The mesh to highlight
  59781. * @param color The color of the highlight
  59782. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59783. */
  59784. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59785. /**
  59786. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59787. * @param mesh The mesh to highlight
  59788. */
  59789. removeMesh(mesh: Mesh): void;
  59790. /**
  59791. * Remove all the meshes currently referenced in the highlight layer
  59792. */
  59793. removeAllMeshes(): void;
  59794. /**
  59795. * Force the stencil to the normal expected value for none glowing parts
  59796. */
  59797. private _defaultStencilReference;
  59798. /**
  59799. * Free any resources and references associated to a mesh.
  59800. * Internal use
  59801. * @param mesh The mesh to free.
  59802. * @hidden
  59803. */
  59804. _disposeMesh(mesh: Mesh): void;
  59805. /**
  59806. * Dispose the highlight layer and free resources.
  59807. */
  59808. dispose(): void;
  59809. /**
  59810. * Gets the class name of the effect layer
  59811. * @returns the string with the class name of the effect layer
  59812. */
  59813. getClassName(): string;
  59814. /**
  59815. * Serializes this Highlight layer
  59816. * @returns a serialized Highlight layer object
  59817. */
  59818. serialize(): any;
  59819. /**
  59820. * Creates a Highlight layer from parsed Highlight layer data
  59821. * @param parsedHightlightLayer defines the Highlight layer data
  59822. * @param scene defines the current scene
  59823. * @param rootUrl defines the root URL containing the Highlight layer information
  59824. * @returns a parsed Highlight layer
  59825. */
  59826. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59827. }
  59828. }
  59829. declare module BABYLON {
  59830. interface AbstractScene {
  59831. /**
  59832. * The list of layers (background and foreground) of the scene
  59833. */
  59834. layers: Array<Layer>;
  59835. }
  59836. /**
  59837. * Defines the layer scene component responsible to manage any layers
  59838. * in a given scene.
  59839. */
  59840. export class LayerSceneComponent implements ISceneComponent {
  59841. /**
  59842. * The component name helpfull to identify the component in the list of scene components.
  59843. */
  59844. readonly name: string;
  59845. /**
  59846. * The scene the component belongs to.
  59847. */
  59848. scene: Scene;
  59849. private _engine;
  59850. /**
  59851. * Creates a new instance of the component for the given scene
  59852. * @param scene Defines the scene to register the component in
  59853. */
  59854. constructor(scene: Scene);
  59855. /**
  59856. * Registers the component in a given scene
  59857. */
  59858. register(): void;
  59859. /**
  59860. * Rebuilds the elements related to this component in case of
  59861. * context lost for instance.
  59862. */
  59863. rebuild(): void;
  59864. /**
  59865. * Disposes the component and the associated ressources.
  59866. */
  59867. dispose(): void;
  59868. private _draw;
  59869. private _drawCameraPredicate;
  59870. private _drawCameraBackground;
  59871. private _drawCameraForeground;
  59872. private _drawRenderTargetPredicate;
  59873. private _drawRenderTargetBackground;
  59874. private _drawRenderTargetForeground;
  59875. /**
  59876. * Adds all the elements from the container to the scene
  59877. * @param container the container holding the elements
  59878. */
  59879. addFromContainer(container: AbstractScene): void;
  59880. /**
  59881. * Removes all the elements in the container from the scene
  59882. * @param container contains the elements to remove
  59883. * @param dispose if the removed element should be disposed (default: false)
  59884. */
  59885. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59886. }
  59887. }
  59888. declare module BABYLON {
  59889. /** @hidden */
  59890. export var layerPixelShader: {
  59891. name: string;
  59892. shader: string;
  59893. };
  59894. }
  59895. declare module BABYLON {
  59896. /** @hidden */
  59897. export var layerVertexShader: {
  59898. name: string;
  59899. shader: string;
  59900. };
  59901. }
  59902. declare module BABYLON {
  59903. /**
  59904. * This represents a full screen 2d layer.
  59905. * This can be useful to display a picture in the background of your scene for instance.
  59906. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59907. */
  59908. export class Layer {
  59909. /**
  59910. * Define the name of the layer.
  59911. */
  59912. name: string;
  59913. /**
  59914. * Define the texture the layer should display.
  59915. */
  59916. texture: Nullable<Texture>;
  59917. /**
  59918. * Is the layer in background or foreground.
  59919. */
  59920. isBackground: boolean;
  59921. /**
  59922. * Define the color of the layer (instead of texture).
  59923. */
  59924. color: Color4;
  59925. /**
  59926. * Define the scale of the layer in order to zoom in out of the texture.
  59927. */
  59928. scale: Vector2;
  59929. /**
  59930. * Define an offset for the layer in order to shift the texture.
  59931. */
  59932. offset: Vector2;
  59933. /**
  59934. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59935. */
  59936. alphaBlendingMode: number;
  59937. /**
  59938. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59939. * Alpha test will not mix with the background color in case of transparency.
  59940. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59941. */
  59942. alphaTest: boolean;
  59943. /**
  59944. * Define a mask to restrict the layer to only some of the scene cameras.
  59945. */
  59946. layerMask: number;
  59947. /**
  59948. * Define the list of render target the layer is visible into.
  59949. */
  59950. renderTargetTextures: RenderTargetTexture[];
  59951. /**
  59952. * Define if the layer is only used in renderTarget or if it also
  59953. * renders in the main frame buffer of the canvas.
  59954. */
  59955. renderOnlyInRenderTargetTextures: boolean;
  59956. private _scene;
  59957. private _vertexBuffers;
  59958. private _indexBuffer;
  59959. private _effect;
  59960. private _previousDefines;
  59961. /**
  59962. * An event triggered when the layer is disposed.
  59963. */
  59964. onDisposeObservable: Observable<Layer>;
  59965. private _onDisposeObserver;
  59966. /**
  59967. * Back compatibility with callback before the onDisposeObservable existed.
  59968. * The set callback will be triggered when the layer has been disposed.
  59969. */
  59970. set onDispose(callback: () => void);
  59971. /**
  59972. * An event triggered before rendering the scene
  59973. */
  59974. onBeforeRenderObservable: Observable<Layer>;
  59975. private _onBeforeRenderObserver;
  59976. /**
  59977. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59978. * The set callback will be triggered just before rendering the layer.
  59979. */
  59980. set onBeforeRender(callback: () => void);
  59981. /**
  59982. * An event triggered after rendering the scene
  59983. */
  59984. onAfterRenderObservable: Observable<Layer>;
  59985. private _onAfterRenderObserver;
  59986. /**
  59987. * Back compatibility with callback before the onAfterRenderObservable existed.
  59988. * The set callback will be triggered just after rendering the layer.
  59989. */
  59990. set onAfterRender(callback: () => void);
  59991. /**
  59992. * Instantiates a new layer.
  59993. * This represents a full screen 2d layer.
  59994. * This can be useful to display a picture in the background of your scene for instance.
  59995. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59996. * @param name Define the name of the layer in the scene
  59997. * @param imgUrl Define the url of the texture to display in the layer
  59998. * @param scene Define the scene the layer belongs to
  59999. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60000. * @param color Defines a color for the layer
  60001. */
  60002. constructor(
  60003. /**
  60004. * Define the name of the layer.
  60005. */
  60006. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60007. private _createIndexBuffer;
  60008. /** @hidden */
  60009. _rebuild(): void;
  60010. /**
  60011. * Renders the layer in the scene.
  60012. */
  60013. render(): void;
  60014. /**
  60015. * Disposes and releases the associated ressources.
  60016. */
  60017. dispose(): void;
  60018. }
  60019. }
  60020. declare module BABYLON {
  60021. /** @hidden */
  60022. export var lensFlarePixelShader: {
  60023. name: string;
  60024. shader: string;
  60025. };
  60026. }
  60027. declare module BABYLON {
  60028. /** @hidden */
  60029. export var lensFlareVertexShader: {
  60030. name: string;
  60031. shader: string;
  60032. };
  60033. }
  60034. declare module BABYLON {
  60035. /**
  60036. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60037. * It is usually composed of several `lensFlare`.
  60038. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60039. */
  60040. export class LensFlareSystem {
  60041. /**
  60042. * Define the name of the lens flare system
  60043. */
  60044. name: string;
  60045. /**
  60046. * List of lens flares used in this system.
  60047. */
  60048. lensFlares: LensFlare[];
  60049. /**
  60050. * Define a limit from the border the lens flare can be visible.
  60051. */
  60052. borderLimit: number;
  60053. /**
  60054. * Define a viewport border we do not want to see the lens flare in.
  60055. */
  60056. viewportBorder: number;
  60057. /**
  60058. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60059. */
  60060. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60061. /**
  60062. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60063. */
  60064. layerMask: number;
  60065. /**
  60066. * Define the id of the lens flare system in the scene.
  60067. * (equal to name by default)
  60068. */
  60069. id: string;
  60070. private _scene;
  60071. private _emitter;
  60072. private _vertexBuffers;
  60073. private _indexBuffer;
  60074. private _effect;
  60075. private _positionX;
  60076. private _positionY;
  60077. private _isEnabled;
  60078. /** @hidden */
  60079. static _SceneComponentInitialization: (scene: Scene) => void;
  60080. /**
  60081. * Instantiates a lens flare system.
  60082. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60083. * It is usually composed of several `lensFlare`.
  60084. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60085. * @param name Define the name of the lens flare system in the scene
  60086. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60087. * @param scene Define the scene the lens flare system belongs to
  60088. */
  60089. constructor(
  60090. /**
  60091. * Define the name of the lens flare system
  60092. */
  60093. name: string, emitter: any, scene: Scene);
  60094. /**
  60095. * Define if the lens flare system is enabled.
  60096. */
  60097. get isEnabled(): boolean;
  60098. set isEnabled(value: boolean);
  60099. /**
  60100. * Get the scene the effects belongs to.
  60101. * @returns the scene holding the lens flare system
  60102. */
  60103. getScene(): Scene;
  60104. /**
  60105. * Get the emitter of the lens flare system.
  60106. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60107. * @returns the emitter of the lens flare system
  60108. */
  60109. getEmitter(): any;
  60110. /**
  60111. * Set the emitter of the lens flare system.
  60112. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60113. * @param newEmitter Define the new emitter of the system
  60114. */
  60115. setEmitter(newEmitter: any): void;
  60116. /**
  60117. * Get the lens flare system emitter position.
  60118. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60119. * @returns the position
  60120. */
  60121. getEmitterPosition(): Vector3;
  60122. /**
  60123. * @hidden
  60124. */
  60125. computeEffectivePosition(globalViewport: Viewport): boolean;
  60126. /** @hidden */
  60127. _isVisible(): boolean;
  60128. /**
  60129. * @hidden
  60130. */
  60131. render(): boolean;
  60132. /**
  60133. * Dispose and release the lens flare with its associated resources.
  60134. */
  60135. dispose(): void;
  60136. /**
  60137. * Parse a lens flare system from a JSON repressentation
  60138. * @param parsedLensFlareSystem Define the JSON to parse
  60139. * @param scene Define the scene the parsed system should be instantiated in
  60140. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60141. * @returns the parsed system
  60142. */
  60143. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60144. /**
  60145. * Serialize the current Lens Flare System into a JSON representation.
  60146. * @returns the serialized JSON
  60147. */
  60148. serialize(): any;
  60149. }
  60150. }
  60151. declare module BABYLON {
  60152. /**
  60153. * This represents one of the lens effect in a `lensFlareSystem`.
  60154. * It controls one of the indiviual texture used in the effect.
  60155. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60156. */
  60157. export class LensFlare {
  60158. /**
  60159. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60160. */
  60161. size: number;
  60162. /**
  60163. * 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.
  60164. */
  60165. position: number;
  60166. /**
  60167. * Define the lens color.
  60168. */
  60169. color: Color3;
  60170. /**
  60171. * Define the lens texture.
  60172. */
  60173. texture: Nullable<Texture>;
  60174. /**
  60175. * Define the alpha mode to render this particular lens.
  60176. */
  60177. alphaMode: number;
  60178. private _system;
  60179. /**
  60180. * Creates a new Lens Flare.
  60181. * This represents one of the lens effect in a `lensFlareSystem`.
  60182. * It controls one of the indiviual texture used in the effect.
  60183. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60184. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60185. * @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.
  60186. * @param color Define the lens color
  60187. * @param imgUrl Define the lens texture url
  60188. * @param system Define the `lensFlareSystem` this flare is part of
  60189. * @returns The newly created Lens Flare
  60190. */
  60191. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60192. /**
  60193. * Instantiates a new Lens Flare.
  60194. * This represents one of the lens effect in a `lensFlareSystem`.
  60195. * It controls one of the indiviual texture used in the effect.
  60196. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60197. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60198. * @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.
  60199. * @param color Define the lens color
  60200. * @param imgUrl Define the lens texture url
  60201. * @param system Define the `lensFlareSystem` this flare is part of
  60202. */
  60203. constructor(
  60204. /**
  60205. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60206. */
  60207. size: number,
  60208. /**
  60209. * 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.
  60210. */
  60211. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60212. /**
  60213. * Dispose and release the lens flare with its associated resources.
  60214. */
  60215. dispose(): void;
  60216. }
  60217. }
  60218. declare module BABYLON {
  60219. interface AbstractScene {
  60220. /**
  60221. * The list of lens flare system added to the scene
  60222. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60223. */
  60224. lensFlareSystems: Array<LensFlareSystem>;
  60225. /**
  60226. * Removes the given lens flare system from this scene.
  60227. * @param toRemove The lens flare system to remove
  60228. * @returns The index of the removed lens flare system
  60229. */
  60230. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60231. /**
  60232. * Adds the given lens flare system to this scene
  60233. * @param newLensFlareSystem The lens flare system to add
  60234. */
  60235. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60236. /**
  60237. * Gets a lens flare system using its name
  60238. * @param name defines the name to look for
  60239. * @returns the lens flare system or null if not found
  60240. */
  60241. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60242. /**
  60243. * Gets a lens flare system using its id
  60244. * @param id defines the id to look for
  60245. * @returns the lens flare system or null if not found
  60246. */
  60247. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60248. }
  60249. /**
  60250. * Defines the lens flare scene component responsible to manage any lens flares
  60251. * in a given scene.
  60252. */
  60253. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60254. /**
  60255. * The component name helpfull to identify the component in the list of scene components.
  60256. */
  60257. readonly name: string;
  60258. /**
  60259. * The scene the component belongs to.
  60260. */
  60261. scene: Scene;
  60262. /**
  60263. * Creates a new instance of the component for the given scene
  60264. * @param scene Defines the scene to register the component in
  60265. */
  60266. constructor(scene: Scene);
  60267. /**
  60268. * Registers the component in a given scene
  60269. */
  60270. register(): void;
  60271. /**
  60272. * Rebuilds the elements related to this component in case of
  60273. * context lost for instance.
  60274. */
  60275. rebuild(): void;
  60276. /**
  60277. * Adds all the elements from the container to the scene
  60278. * @param container the container holding the elements
  60279. */
  60280. addFromContainer(container: AbstractScene): void;
  60281. /**
  60282. * Removes all the elements in the container from the scene
  60283. * @param container contains the elements to remove
  60284. * @param dispose if the removed element should be disposed (default: false)
  60285. */
  60286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60287. /**
  60288. * Serializes the component data to the specified json object
  60289. * @param serializationObject The object to serialize to
  60290. */
  60291. serialize(serializationObject: any): void;
  60292. /**
  60293. * Disposes the component and the associated ressources.
  60294. */
  60295. dispose(): void;
  60296. private _draw;
  60297. }
  60298. }
  60299. declare module BABYLON {
  60300. /** @hidden */
  60301. export var depthPixelShader: {
  60302. name: string;
  60303. shader: string;
  60304. };
  60305. }
  60306. declare module BABYLON {
  60307. /** @hidden */
  60308. export var depthVertexShader: {
  60309. name: string;
  60310. shader: string;
  60311. };
  60312. }
  60313. declare module BABYLON {
  60314. /**
  60315. * This represents a depth renderer in Babylon.
  60316. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60317. */
  60318. export class DepthRenderer {
  60319. private _scene;
  60320. private _depthMap;
  60321. private _effect;
  60322. private readonly _storeNonLinearDepth;
  60323. private readonly _clearColor;
  60324. /** Get if the depth renderer is using packed depth or not */
  60325. readonly isPacked: boolean;
  60326. private _cachedDefines;
  60327. private _camera;
  60328. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60329. enabled: boolean;
  60330. /**
  60331. * Specifiess that the depth renderer will only be used within
  60332. * the camera it is created for.
  60333. * This can help forcing its rendering during the camera processing.
  60334. */
  60335. useOnlyInActiveCamera: boolean;
  60336. /** @hidden */
  60337. static _SceneComponentInitialization: (scene: Scene) => void;
  60338. /**
  60339. * Instantiates a depth renderer
  60340. * @param scene The scene the renderer belongs to
  60341. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60342. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60343. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60344. */
  60345. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60346. /**
  60347. * Creates the depth rendering effect and checks if the effect is ready.
  60348. * @param subMesh The submesh to be used to render the depth map of
  60349. * @param useInstances If multiple world instances should be used
  60350. * @returns if the depth renderer is ready to render the depth map
  60351. */
  60352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60353. /**
  60354. * Gets the texture which the depth map will be written to.
  60355. * @returns The depth map texture
  60356. */
  60357. getDepthMap(): RenderTargetTexture;
  60358. /**
  60359. * Disposes of the depth renderer.
  60360. */
  60361. dispose(): void;
  60362. }
  60363. }
  60364. declare module BABYLON {
  60365. /** @hidden */
  60366. export var minmaxReduxPixelShader: {
  60367. name: string;
  60368. shader: string;
  60369. };
  60370. }
  60371. declare module BABYLON {
  60372. /**
  60373. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60374. * and maximum values from all values of the texture.
  60375. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60376. * The source values are read from the red channel of the texture.
  60377. */
  60378. export class MinMaxReducer {
  60379. /**
  60380. * Observable triggered when the computation has been performed
  60381. */
  60382. onAfterReductionPerformed: Observable<{
  60383. min: number;
  60384. max: number;
  60385. }>;
  60386. protected _camera: Camera;
  60387. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60388. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60389. protected _postProcessManager: PostProcessManager;
  60390. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60391. protected _forceFullscreenViewport: boolean;
  60392. /**
  60393. * Creates a min/max reducer
  60394. * @param camera The camera to use for the post processes
  60395. */
  60396. constructor(camera: Camera);
  60397. /**
  60398. * Gets the texture used to read the values from.
  60399. */
  60400. get sourceTexture(): Nullable<RenderTargetTexture>;
  60401. /**
  60402. * Sets the source texture to read the values from.
  60403. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60404. * because in such textures '1' value must not be taken into account to compute the maximum
  60405. * as this value is used to clear the texture.
  60406. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60407. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60408. * @param depthRedux Indicates if the texture is a depth texture or not
  60409. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60410. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60411. */
  60412. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60413. /**
  60414. * Defines the refresh rate of the computation.
  60415. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60416. */
  60417. get refreshRate(): number;
  60418. set refreshRate(value: number);
  60419. protected _activated: boolean;
  60420. /**
  60421. * Gets the activation status of the reducer
  60422. */
  60423. get activated(): boolean;
  60424. /**
  60425. * Activates the reduction computation.
  60426. * When activated, the observers registered in onAfterReductionPerformed are
  60427. * called after the compuation is performed
  60428. */
  60429. activate(): void;
  60430. /**
  60431. * Deactivates the reduction computation.
  60432. */
  60433. deactivate(): void;
  60434. /**
  60435. * Disposes the min/max reducer
  60436. * @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.
  60437. */
  60438. dispose(disposeAll?: boolean): void;
  60439. }
  60440. }
  60441. declare module BABYLON {
  60442. /**
  60443. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60444. */
  60445. export class DepthReducer extends MinMaxReducer {
  60446. private _depthRenderer;
  60447. private _depthRendererId;
  60448. /**
  60449. * Gets the depth renderer used for the computation.
  60450. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60451. */
  60452. get depthRenderer(): Nullable<DepthRenderer>;
  60453. /**
  60454. * Creates a depth reducer
  60455. * @param camera The camera used to render the depth texture
  60456. */
  60457. constructor(camera: Camera);
  60458. /**
  60459. * Sets the depth renderer to use to generate the depth map
  60460. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60461. * @param type The texture type of the depth map (default: 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. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60465. /** @hidden */
  60466. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60467. /**
  60468. * Activates the reduction computation.
  60469. * When activated, the observers registered in onAfterReductionPerformed are
  60470. * called after the compuation is performed
  60471. */
  60472. activate(): void;
  60473. /**
  60474. * Deactivates the reduction computation.
  60475. */
  60476. deactivate(): void;
  60477. /**
  60478. * Disposes the depth reducer
  60479. * @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.
  60480. */
  60481. dispose(disposeAll?: boolean): void;
  60482. }
  60483. }
  60484. declare module BABYLON {
  60485. /**
  60486. * A CSM implementation allowing casting shadows on large scenes.
  60487. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60488. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60489. */
  60490. export class CascadedShadowGenerator extends ShadowGenerator {
  60491. private static readonly frustumCornersNDCSpace;
  60492. /**
  60493. * Name of the CSM class
  60494. */
  60495. static CLASSNAME: string;
  60496. /**
  60497. * Defines the default number of cascades used by the CSM.
  60498. */
  60499. static readonly DEFAULT_CASCADES_COUNT: number;
  60500. /**
  60501. * Defines the minimum number of cascades used by the CSM.
  60502. */
  60503. static readonly MIN_CASCADES_COUNT: number;
  60504. /**
  60505. * Defines the maximum number of cascades used by the CSM.
  60506. */
  60507. static readonly MAX_CASCADES_COUNT: number;
  60508. protected _validateFilter(filter: number): number;
  60509. /**
  60510. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60511. */
  60512. penumbraDarkness: number;
  60513. private _numCascades;
  60514. /**
  60515. * Gets or set the number of cascades used by the CSM.
  60516. */
  60517. get numCascades(): number;
  60518. set numCascades(value: number);
  60519. /**
  60520. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60521. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60522. */
  60523. stabilizeCascades: boolean;
  60524. private _freezeShadowCastersBoundingInfo;
  60525. private _freezeShadowCastersBoundingInfoObservable;
  60526. /**
  60527. * Enables or disables the shadow casters bounding info computation.
  60528. * If your shadow casters don't move, you can disable this feature.
  60529. * If it is enabled, the bounding box computation is done every frame.
  60530. */
  60531. get freezeShadowCastersBoundingInfo(): boolean;
  60532. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60533. private _scbiMin;
  60534. private _scbiMax;
  60535. protected _computeShadowCastersBoundingInfo(): void;
  60536. protected _shadowCastersBoundingInfo: BoundingInfo;
  60537. /**
  60538. * Gets or sets the shadow casters bounding info.
  60539. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60540. * so that the system won't overwrite the bounds you provide
  60541. */
  60542. get shadowCastersBoundingInfo(): BoundingInfo;
  60543. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60544. protected _breaksAreDirty: boolean;
  60545. protected _minDistance: number;
  60546. protected _maxDistance: number;
  60547. /**
  60548. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60549. *
  60550. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60551. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60552. * @param min minimal distance for the breaks (default to 0.)
  60553. * @param max maximal distance for the breaks (default to 1.)
  60554. */
  60555. setMinMaxDistance(min: number, max: number): void;
  60556. /** Gets the minimal distance used in the cascade break computation */
  60557. get minDistance(): number;
  60558. /** Gets the maximal distance used in the cascade break computation */
  60559. get maxDistance(): number;
  60560. /**
  60561. * Gets the class name of that object
  60562. * @returns "CascadedShadowGenerator"
  60563. */
  60564. getClassName(): string;
  60565. private _cascadeMinExtents;
  60566. private _cascadeMaxExtents;
  60567. /**
  60568. * Gets a cascade minimum extents
  60569. * @param cascadeIndex index of the cascade
  60570. * @returns the minimum cascade extents
  60571. */
  60572. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60573. /**
  60574. * Gets a cascade maximum extents
  60575. * @param cascadeIndex index of the cascade
  60576. * @returns the maximum cascade extents
  60577. */
  60578. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60579. private _cascades;
  60580. private _currentLayer;
  60581. private _viewSpaceFrustumsZ;
  60582. private _viewMatrices;
  60583. private _projectionMatrices;
  60584. private _transformMatrices;
  60585. private _transformMatricesAsArray;
  60586. private _frustumLengths;
  60587. private _lightSizeUVCorrection;
  60588. private _depthCorrection;
  60589. private _frustumCornersWorldSpace;
  60590. private _frustumCenter;
  60591. private _shadowCameraPos;
  60592. private _shadowMaxZ;
  60593. /**
  60594. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60595. * It defaults to camera.maxZ
  60596. */
  60597. get shadowMaxZ(): number;
  60598. /**
  60599. * Sets the shadow max z distance.
  60600. */
  60601. set shadowMaxZ(value: number);
  60602. protected _debug: boolean;
  60603. /**
  60604. * Gets or sets the debug flag.
  60605. * When enabled, the cascades are materialized by different colors on the screen.
  60606. */
  60607. get debug(): boolean;
  60608. set debug(dbg: boolean);
  60609. private _depthClamp;
  60610. /**
  60611. * Gets or sets the depth clamping value.
  60612. *
  60613. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60614. * to account for the shadow casters far away.
  60615. *
  60616. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60617. */
  60618. get depthClamp(): boolean;
  60619. set depthClamp(value: boolean);
  60620. private _cascadeBlendPercentage;
  60621. /**
  60622. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60623. * It defaults to 0.1 (10% blending).
  60624. */
  60625. get cascadeBlendPercentage(): number;
  60626. set cascadeBlendPercentage(value: number);
  60627. private _lambda;
  60628. /**
  60629. * Gets or set the lambda parameter.
  60630. * This parameter is used to split the camera frustum and create the cascades.
  60631. * 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.
  60632. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60633. */
  60634. get lambda(): number;
  60635. set lambda(value: number);
  60636. /**
  60637. * Gets the view matrix corresponding to a given cascade
  60638. * @param cascadeNum cascade to retrieve the view matrix from
  60639. * @returns the cascade view matrix
  60640. */
  60641. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60642. /**
  60643. * Gets the projection matrix corresponding to a given cascade
  60644. * @param cascadeNum cascade to retrieve the projection matrix from
  60645. * @returns the cascade projection matrix
  60646. */
  60647. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60648. /**
  60649. * Gets the transformation matrix corresponding to a given cascade
  60650. * @param cascadeNum cascade to retrieve the transformation matrix from
  60651. * @returns the cascade transformation matrix
  60652. */
  60653. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60654. private _depthRenderer;
  60655. /**
  60656. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60657. *
  60658. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60659. *
  60660. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60661. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60662. * @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
  60663. */
  60664. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60665. private _depthReducer;
  60666. private _autoCalcDepthBounds;
  60667. /**
  60668. * Gets or sets the autoCalcDepthBounds property.
  60669. *
  60670. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60671. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60672. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60673. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60674. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60675. */
  60676. get autoCalcDepthBounds(): boolean;
  60677. set autoCalcDepthBounds(value: boolean);
  60678. /**
  60679. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60680. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60681. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60682. * for setting the refresh rate on the renderer yourself!
  60683. */
  60684. get autoCalcDepthBoundsRefreshRate(): number;
  60685. set autoCalcDepthBoundsRefreshRate(value: number);
  60686. /**
  60687. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60688. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60689. * you change the camera near/far planes!
  60690. */
  60691. splitFrustum(): void;
  60692. private _splitFrustum;
  60693. private _computeMatrices;
  60694. private _computeFrustumInWorldSpace;
  60695. private _computeCascadeFrustum;
  60696. /**
  60697. * Support test.
  60698. */
  60699. static get IsSupported(): boolean;
  60700. /** @hidden */
  60701. static _SceneComponentInitialization: (scene: Scene) => void;
  60702. /**
  60703. * Creates a Cascaded Shadow Generator object.
  60704. * A ShadowGenerator is the required tool to use the shadows.
  60705. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60706. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60707. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60708. * @param light The directional light object generating the shadows.
  60709. * @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.
  60710. */
  60711. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60712. protected _initializeGenerator(): void;
  60713. protected _createTargetRenderTexture(): void;
  60714. protected _initializeShadowMap(): void;
  60715. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60716. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60717. /**
  60718. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60719. * @param defines Defines of the material we want to update
  60720. * @param lightIndex Index of the light in the enabled light list of the material
  60721. */
  60722. prepareDefines(defines: any, lightIndex: number): void;
  60723. /**
  60724. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60725. * defined in the generator but impacting the effect).
  60726. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60727. * @param effect The effect we are binfing the information for
  60728. */
  60729. bindShadowLight(lightIndex: string, effect: Effect): void;
  60730. /**
  60731. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60732. * (eq to view projection * shadow projection matrices)
  60733. * @returns The transform matrix used to create the shadow map
  60734. */
  60735. getTransformMatrix(): Matrix;
  60736. /**
  60737. * Disposes the ShadowGenerator.
  60738. * Returns nothing.
  60739. */
  60740. dispose(): void;
  60741. /**
  60742. * Serializes the shadow generator setup to a json object.
  60743. * @returns The serialized JSON object
  60744. */
  60745. serialize(): any;
  60746. /**
  60747. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60748. * @param parsedShadowGenerator The JSON object to parse
  60749. * @param scene The scene to create the shadow map for
  60750. * @returns The parsed shadow generator
  60751. */
  60752. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60753. }
  60754. }
  60755. declare module BABYLON {
  60756. /**
  60757. * Defines the shadow generator component responsible to manage any shadow generators
  60758. * in a given scene.
  60759. */
  60760. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60761. /**
  60762. * The component name helpfull to identify the component in the list of scene components.
  60763. */
  60764. readonly name: string;
  60765. /**
  60766. * The scene the component belongs to.
  60767. */
  60768. scene: Scene;
  60769. /**
  60770. * Creates a new instance of the component for the given scene
  60771. * @param scene Defines the scene to register the component in
  60772. */
  60773. constructor(scene: Scene);
  60774. /**
  60775. * Registers the component in a given scene
  60776. */
  60777. register(): void;
  60778. /**
  60779. * Rebuilds the elements related to this component in case of
  60780. * context lost for instance.
  60781. */
  60782. rebuild(): void;
  60783. /**
  60784. * Serializes the component data to the specified json object
  60785. * @param serializationObject The object to serialize to
  60786. */
  60787. serialize(serializationObject: any): void;
  60788. /**
  60789. * Adds all the elements from the container to the scene
  60790. * @param container the container holding the elements
  60791. */
  60792. addFromContainer(container: AbstractScene): void;
  60793. /**
  60794. * Removes all the elements in the container from the scene
  60795. * @param container contains the elements to remove
  60796. * @param dispose if the removed element should be disposed (default: false)
  60797. */
  60798. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60799. /**
  60800. * Rebuilds the elements related to this component in case of
  60801. * context lost for instance.
  60802. */
  60803. dispose(): void;
  60804. private _gatherRenderTargets;
  60805. }
  60806. }
  60807. declare module BABYLON {
  60808. /**
  60809. * A point light is a light defined by an unique point in world space.
  60810. * The light is emitted in every direction from this point.
  60811. * A good example of a point light is a standard light bulb.
  60812. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60813. */
  60814. export class PointLight extends ShadowLight {
  60815. private _shadowAngle;
  60816. /**
  60817. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60818. * This specifies what angle the shadow will use to be created.
  60819. *
  60820. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60821. */
  60822. get shadowAngle(): number;
  60823. /**
  60824. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60825. * This specifies what angle the shadow will use to be created.
  60826. *
  60827. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60828. */
  60829. set shadowAngle(value: number);
  60830. /**
  60831. * Gets the direction if it has been set.
  60832. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60833. */
  60834. get direction(): Vector3;
  60835. /**
  60836. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60837. */
  60838. set direction(value: Vector3);
  60839. /**
  60840. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60841. * A PointLight emits the light in every direction.
  60842. * It can cast shadows.
  60843. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60844. * ```javascript
  60845. * var pointLight = new PointLight("pl", camera.position, scene);
  60846. * ```
  60847. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60848. * @param name The light friendly name
  60849. * @param position The position of the point light in the scene
  60850. * @param scene The scene the lights belongs to
  60851. */
  60852. constructor(name: string, position: Vector3, scene: Scene);
  60853. /**
  60854. * Returns the string "PointLight"
  60855. * @returns the class name
  60856. */
  60857. getClassName(): string;
  60858. /**
  60859. * Returns the integer 0.
  60860. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60861. */
  60862. getTypeID(): number;
  60863. /**
  60864. * Specifies wether or not the shadowmap should be a cube texture.
  60865. * @returns true if the shadowmap needs to be a cube texture.
  60866. */
  60867. needCube(): boolean;
  60868. /**
  60869. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60870. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60871. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60872. */
  60873. getShadowDirection(faceIndex?: number): Vector3;
  60874. /**
  60875. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60876. * - fov = PI / 2
  60877. * - aspect ratio : 1.0
  60878. * - z-near and far equal to the active camera minZ and maxZ.
  60879. * Returns the PointLight.
  60880. */
  60881. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60882. protected _buildUniformLayout(): void;
  60883. /**
  60884. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60885. * @param effect The effect to update
  60886. * @param lightIndex The index of the light in the effect to update
  60887. * @returns The point light
  60888. */
  60889. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60890. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60891. /**
  60892. * Prepares the list of defines specific to the light type.
  60893. * @param defines the list of defines
  60894. * @param lightIndex defines the index of the light for the effect
  60895. */
  60896. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60897. }
  60898. }
  60899. declare module BABYLON {
  60900. /**
  60901. * Header information of HDR texture files.
  60902. */
  60903. export interface HDRInfo {
  60904. /**
  60905. * The height of the texture in pixels.
  60906. */
  60907. height: number;
  60908. /**
  60909. * The width of the texture in pixels.
  60910. */
  60911. width: number;
  60912. /**
  60913. * The index of the beginning of the data in the binary file.
  60914. */
  60915. dataPosition: number;
  60916. }
  60917. /**
  60918. * This groups tools to convert HDR texture to native colors array.
  60919. */
  60920. export class HDRTools {
  60921. private static Ldexp;
  60922. private static Rgbe2float;
  60923. private static readStringLine;
  60924. /**
  60925. * Reads header information from an RGBE texture stored in a native array.
  60926. * More information on this format are available here:
  60927. * https://en.wikipedia.org/wiki/RGBE_image_format
  60928. *
  60929. * @param uint8array The binary file stored in native array.
  60930. * @return The header information.
  60931. */
  60932. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60933. /**
  60934. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60935. * This RGBE texture needs to store the information as a panorama.
  60936. *
  60937. * More information on this format are available here:
  60938. * https://en.wikipedia.org/wiki/RGBE_image_format
  60939. *
  60940. * @param buffer The binary file stored in an array buffer.
  60941. * @param size The expected size of the extracted cubemap.
  60942. * @return The Cube Map information.
  60943. */
  60944. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60945. /**
  60946. * Returns the pixels data extracted from an RGBE texture.
  60947. * This pixels will be stored left to right up to down in the R G B order in one array.
  60948. *
  60949. * More information on this format are available here:
  60950. * https://en.wikipedia.org/wiki/RGBE_image_format
  60951. *
  60952. * @param uint8array The binary file stored in an array buffer.
  60953. * @param hdrInfo The header information of the file.
  60954. * @return The pixels data in RGB right to left up to down order.
  60955. */
  60956. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60957. private static RGBE_ReadPixels_RLE;
  60958. private static RGBE_ReadPixels_NOT_RLE;
  60959. }
  60960. }
  60961. declare module BABYLON {
  60962. /**
  60963. * Effect Render Options
  60964. */
  60965. export interface IEffectRendererOptions {
  60966. /**
  60967. * Defines the vertices positions.
  60968. */
  60969. positions?: number[];
  60970. /**
  60971. * Defines the indices.
  60972. */
  60973. indices?: number[];
  60974. }
  60975. /**
  60976. * Helper class to render one or more effects.
  60977. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60978. */
  60979. export class EffectRenderer {
  60980. private engine;
  60981. private static _DefaultOptions;
  60982. private _vertexBuffers;
  60983. private _indexBuffer;
  60984. private _fullscreenViewport;
  60985. /**
  60986. * Creates an effect renderer
  60987. * @param engine the engine to use for rendering
  60988. * @param options defines the options of the effect renderer
  60989. */
  60990. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60991. /**
  60992. * Sets the current viewport in normalized coordinates 0-1
  60993. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60994. */
  60995. setViewport(viewport?: Viewport): void;
  60996. /**
  60997. * Binds the embedded attributes buffer to the effect.
  60998. * @param effect Defines the effect to bind the attributes for
  60999. */
  61000. bindBuffers(effect: Effect): void;
  61001. /**
  61002. * Sets the current effect wrapper to use during draw.
  61003. * The effect needs to be ready before calling this api.
  61004. * This also sets the default full screen position attribute.
  61005. * @param effectWrapper Defines the effect to draw with
  61006. */
  61007. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61008. /**
  61009. * Restores engine states
  61010. */
  61011. restoreStates(): void;
  61012. /**
  61013. * Draws a full screen quad.
  61014. */
  61015. draw(): void;
  61016. private isRenderTargetTexture;
  61017. /**
  61018. * renders one or more effects to a specified texture
  61019. * @param effectWrapper the effect to renderer
  61020. * @param outputTexture texture to draw to, if null it will render to the screen.
  61021. */
  61022. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61023. /**
  61024. * Disposes of the effect renderer
  61025. */
  61026. dispose(): void;
  61027. }
  61028. /**
  61029. * Options to create an EffectWrapper
  61030. */
  61031. interface EffectWrapperCreationOptions {
  61032. /**
  61033. * Engine to use to create the effect
  61034. */
  61035. engine: ThinEngine;
  61036. /**
  61037. * Fragment shader for the effect
  61038. */
  61039. fragmentShader: string;
  61040. /**
  61041. * Use the shader store instead of direct source code
  61042. */
  61043. useShaderStore?: boolean;
  61044. /**
  61045. * Vertex shader for the effect
  61046. */
  61047. vertexShader?: string;
  61048. /**
  61049. * Attributes to use in the shader
  61050. */
  61051. attributeNames?: Array<string>;
  61052. /**
  61053. * Uniforms to use in the shader
  61054. */
  61055. uniformNames?: Array<string>;
  61056. /**
  61057. * Texture sampler names to use in the shader
  61058. */
  61059. samplerNames?: Array<string>;
  61060. /**
  61061. * Defines to use in the shader
  61062. */
  61063. defines?: Array<string>;
  61064. /**
  61065. * Callback when effect is compiled
  61066. */
  61067. onCompiled?: Nullable<(effect: Effect) => void>;
  61068. /**
  61069. * The friendly name of the effect displayed in Spector.
  61070. */
  61071. name?: string;
  61072. }
  61073. /**
  61074. * Wraps an effect to be used for rendering
  61075. */
  61076. export class EffectWrapper {
  61077. /**
  61078. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61079. */
  61080. onApplyObservable: Observable<{}>;
  61081. /**
  61082. * The underlying effect
  61083. */
  61084. effect: Effect;
  61085. /**
  61086. * Creates an effect to be renderer
  61087. * @param creationOptions options to create the effect
  61088. */
  61089. constructor(creationOptions: EffectWrapperCreationOptions);
  61090. /**
  61091. * Disposes of the effect wrapper
  61092. */
  61093. dispose(): void;
  61094. }
  61095. }
  61096. declare module BABYLON {
  61097. /** @hidden */
  61098. export var hdrFilteringVertexShader: {
  61099. name: string;
  61100. shader: string;
  61101. };
  61102. }
  61103. declare module BABYLON {
  61104. /** @hidden */
  61105. export var hdrFilteringPixelShader: {
  61106. name: string;
  61107. shader: string;
  61108. };
  61109. }
  61110. declare module BABYLON {
  61111. /**
  61112. * Options for texture filtering
  61113. */
  61114. interface IHDRFilteringOptions {
  61115. /**
  61116. * Scales pixel intensity for the input HDR map.
  61117. */
  61118. hdrScale?: number;
  61119. /**
  61120. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61121. */
  61122. quality?: number;
  61123. }
  61124. /**
  61125. * Filters HDR maps to get correct renderings of PBR reflections
  61126. */
  61127. export class HDRFiltering {
  61128. private _engine;
  61129. private _effectRenderer;
  61130. private _effectWrapper;
  61131. private _lodGenerationOffset;
  61132. private _lodGenerationScale;
  61133. /**
  61134. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61135. * you care about baking speed.
  61136. */
  61137. quality: number;
  61138. /**
  61139. * Scales pixel intensity for the input HDR map.
  61140. */
  61141. hdrScale: number;
  61142. /**
  61143. * Instantiates HDR filter for reflection maps
  61144. *
  61145. * @param engine Thin engine
  61146. * @param options Options
  61147. */
  61148. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61149. private _createRenderTarget;
  61150. private _prefilterInternal;
  61151. private _createEffect;
  61152. /**
  61153. * Get a value indicating if the filter is ready to be used
  61154. * @param texture Texture to filter
  61155. * @returns true if the filter is ready
  61156. */
  61157. isReady(texture: BaseTexture): boolean;
  61158. /**
  61159. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61160. * Prefiltering will be invoked at the end of next rendering pass.
  61161. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61162. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61163. * @param texture Texture to filter
  61164. * @param onFinished Callback when filtering is done
  61165. * @return Promise called when prefiltering is done
  61166. */
  61167. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61168. }
  61169. }
  61170. declare module BABYLON {
  61171. /**
  61172. * This represents a texture coming from an HDR input.
  61173. *
  61174. * The only supported format is currently panorama picture stored in RGBE format.
  61175. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61176. */
  61177. export class HDRCubeTexture extends BaseTexture {
  61178. private static _facesMapping;
  61179. private _generateHarmonics;
  61180. private _noMipmap;
  61181. private _prefilterOnLoad;
  61182. private _textureMatrix;
  61183. private _size;
  61184. private _onLoad;
  61185. private _onError;
  61186. /**
  61187. * The texture URL.
  61188. */
  61189. url: string;
  61190. protected _isBlocking: boolean;
  61191. /**
  61192. * Sets wether or not the texture is blocking during loading.
  61193. */
  61194. set isBlocking(value: boolean);
  61195. /**
  61196. * Gets wether or not the texture is blocking during loading.
  61197. */
  61198. get isBlocking(): boolean;
  61199. protected _rotationY: number;
  61200. /**
  61201. * Sets texture matrix rotation angle around Y axis in radians.
  61202. */
  61203. set rotationY(value: number);
  61204. /**
  61205. * Gets texture matrix rotation angle around Y axis radians.
  61206. */
  61207. get rotationY(): number;
  61208. /**
  61209. * Gets or sets the center of the bounding box associated with the cube texture
  61210. * It must define where the camera used to render the texture was set
  61211. */
  61212. boundingBoxPosition: Vector3;
  61213. private _boundingBoxSize;
  61214. /**
  61215. * Gets or sets the size of the bounding box associated with the cube texture
  61216. * When defined, the cubemap will switch to local mode
  61217. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61218. * @example https://www.babylonjs-playground.com/#RNASML
  61219. */
  61220. set boundingBoxSize(value: Vector3);
  61221. get boundingBoxSize(): Vector3;
  61222. /**
  61223. * Instantiates an HDRTexture from the following parameters.
  61224. *
  61225. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61226. * @param sceneOrEngine The scene or engine the texture will be used in
  61227. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61228. * @param noMipmap Forces to not generate the mipmap if true
  61229. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61230. * @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)
  61231. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61232. */
  61233. 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>);
  61234. /**
  61235. * Get the current class name of the texture useful for serialization or dynamic coding.
  61236. * @returns "HDRCubeTexture"
  61237. */
  61238. getClassName(): string;
  61239. /**
  61240. * Occurs when the file is raw .hdr file.
  61241. */
  61242. private loadTexture;
  61243. clone(): HDRCubeTexture;
  61244. delayLoad(): void;
  61245. /**
  61246. * Get the texture reflection matrix used to rotate/transform the reflection.
  61247. * @returns the reflection matrix
  61248. */
  61249. getReflectionTextureMatrix(): Matrix;
  61250. /**
  61251. * Set the texture reflection matrix used to rotate/transform the reflection.
  61252. * @param value Define the reflection matrix to set
  61253. */
  61254. setReflectionTextureMatrix(value: Matrix): void;
  61255. /**
  61256. * Parses a JSON representation of an HDR Texture in order to create the texture
  61257. * @param parsedTexture Define the JSON representation
  61258. * @param scene Define the scene the texture should be created in
  61259. * @param rootUrl Define the root url in case we need to load relative dependencies
  61260. * @returns the newly created texture after parsing
  61261. */
  61262. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61263. serialize(): any;
  61264. }
  61265. }
  61266. declare module BABYLON {
  61267. /**
  61268. * Class used to control physics engine
  61269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61270. */
  61271. export class PhysicsEngine implements IPhysicsEngine {
  61272. private _physicsPlugin;
  61273. /**
  61274. * Global value used to control the smallest number supported by the simulation
  61275. */
  61276. static Epsilon: number;
  61277. private _impostors;
  61278. private _joints;
  61279. private _subTimeStep;
  61280. /**
  61281. * Gets the gravity vector used by the simulation
  61282. */
  61283. gravity: Vector3;
  61284. /**
  61285. * Factory used to create the default physics plugin.
  61286. * @returns The default physics plugin
  61287. */
  61288. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61289. /**
  61290. * Creates a new Physics Engine
  61291. * @param gravity defines the gravity vector used by the simulation
  61292. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61293. */
  61294. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61295. /**
  61296. * Sets the gravity vector used by the simulation
  61297. * @param gravity defines the gravity vector to use
  61298. */
  61299. setGravity(gravity: Vector3): void;
  61300. /**
  61301. * Set the time step of the physics engine.
  61302. * Default is 1/60.
  61303. * To slow it down, enter 1/600 for example.
  61304. * To speed it up, 1/30
  61305. * @param newTimeStep defines the new timestep to apply to this world.
  61306. */
  61307. setTimeStep(newTimeStep?: number): void;
  61308. /**
  61309. * Get the time step of the physics engine.
  61310. * @returns the current time step
  61311. */
  61312. getTimeStep(): number;
  61313. /**
  61314. * Set the sub time step of the physics engine.
  61315. * Default is 0 meaning there is no sub steps
  61316. * To increase physics resolution precision, set a small value (like 1 ms)
  61317. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61318. */
  61319. setSubTimeStep(subTimeStep?: number): void;
  61320. /**
  61321. * Get the sub time step of the physics engine.
  61322. * @returns the current sub time step
  61323. */
  61324. getSubTimeStep(): number;
  61325. /**
  61326. * Release all resources
  61327. */
  61328. dispose(): void;
  61329. /**
  61330. * Gets the name of the current physics plugin
  61331. * @returns the name of the plugin
  61332. */
  61333. getPhysicsPluginName(): string;
  61334. /**
  61335. * Adding a new impostor for the impostor tracking.
  61336. * This will be done by the impostor itself.
  61337. * @param impostor the impostor to add
  61338. */
  61339. addImpostor(impostor: PhysicsImpostor): void;
  61340. /**
  61341. * Remove an impostor from the engine.
  61342. * This impostor and its mesh will not longer be updated by the physics engine.
  61343. * @param impostor the impostor to remove
  61344. */
  61345. removeImpostor(impostor: PhysicsImpostor): void;
  61346. /**
  61347. * Add a joint to the physics engine
  61348. * @param mainImpostor defines the main impostor to which the joint is added.
  61349. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61350. * @param joint defines the joint that will connect both impostors.
  61351. */
  61352. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61353. /**
  61354. * Removes a joint from the simulation
  61355. * @param mainImpostor defines the impostor used with the joint
  61356. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61357. * @param joint defines the joint to remove
  61358. */
  61359. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61360. /**
  61361. * Called by the scene. No need to call it.
  61362. * @param delta defines the timespam between frames
  61363. */
  61364. _step(delta: number): void;
  61365. /**
  61366. * Gets the current plugin used to run the simulation
  61367. * @returns current plugin
  61368. */
  61369. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61370. /**
  61371. * Gets the list of physic impostors
  61372. * @returns an array of PhysicsImpostor
  61373. */
  61374. getImpostors(): Array<PhysicsImpostor>;
  61375. /**
  61376. * Gets the impostor for a physics enabled object
  61377. * @param object defines the object impersonated by the impostor
  61378. * @returns the PhysicsImpostor or null if not found
  61379. */
  61380. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61381. /**
  61382. * Gets the impostor for a physics body object
  61383. * @param body defines physics body used by the impostor
  61384. * @returns the PhysicsImpostor or null if not found
  61385. */
  61386. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61387. /**
  61388. * Does a raycast in the physics world
  61389. * @param from when should the ray start?
  61390. * @param to when should the ray end?
  61391. * @returns PhysicsRaycastResult
  61392. */
  61393. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61394. }
  61395. }
  61396. declare module BABYLON {
  61397. /** @hidden */
  61398. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61399. private _useDeltaForWorldStep;
  61400. world: any;
  61401. name: string;
  61402. private _physicsMaterials;
  61403. private _fixedTimeStep;
  61404. private _cannonRaycastResult;
  61405. private _raycastResult;
  61406. private _physicsBodysToRemoveAfterStep;
  61407. private _firstFrame;
  61408. BJSCANNON: any;
  61409. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61410. setGravity(gravity: Vector3): void;
  61411. setTimeStep(timeStep: number): void;
  61412. getTimeStep(): number;
  61413. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61414. private _removeMarkedPhysicsBodiesFromWorld;
  61415. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61416. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61417. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61418. private _processChildMeshes;
  61419. removePhysicsBody(impostor: PhysicsImpostor): void;
  61420. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61421. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61422. private _addMaterial;
  61423. private _checkWithEpsilon;
  61424. private _createShape;
  61425. private _createHeightmap;
  61426. private _minus90X;
  61427. private _plus90X;
  61428. private _tmpPosition;
  61429. private _tmpDeltaPosition;
  61430. private _tmpUnityRotation;
  61431. private _updatePhysicsBodyTransformation;
  61432. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61433. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61434. isSupported(): boolean;
  61435. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61436. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61437. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61438. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61439. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61440. getBodyMass(impostor: PhysicsImpostor): number;
  61441. getBodyFriction(impostor: PhysicsImpostor): number;
  61442. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61443. getBodyRestitution(impostor: PhysicsImpostor): number;
  61444. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61445. sleepBody(impostor: PhysicsImpostor): void;
  61446. wakeUpBody(impostor: PhysicsImpostor): void;
  61447. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61448. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61449. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61450. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61451. getRadius(impostor: PhysicsImpostor): number;
  61452. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61453. dispose(): void;
  61454. private _extendNamespace;
  61455. /**
  61456. * Does a raycast in the physics world
  61457. * @param from when should the ray start?
  61458. * @param to when should the ray end?
  61459. * @returns PhysicsRaycastResult
  61460. */
  61461. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61462. }
  61463. }
  61464. declare module BABYLON {
  61465. /** @hidden */
  61466. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61467. private _useDeltaForWorldStep;
  61468. world: any;
  61469. name: string;
  61470. BJSOIMO: any;
  61471. private _raycastResult;
  61472. private _fixedTimeStep;
  61473. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61474. setGravity(gravity: Vector3): void;
  61475. setTimeStep(timeStep: number): void;
  61476. getTimeStep(): number;
  61477. private _tmpImpostorsArray;
  61478. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61479. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61480. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61481. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61482. private _tmpPositionVector;
  61483. removePhysicsBody(impostor: PhysicsImpostor): void;
  61484. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61485. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61486. isSupported(): boolean;
  61487. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61488. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61489. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61490. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61491. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61492. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61493. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61494. getBodyMass(impostor: PhysicsImpostor): number;
  61495. getBodyFriction(impostor: PhysicsImpostor): number;
  61496. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61497. getBodyRestitution(impostor: PhysicsImpostor): number;
  61498. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61499. sleepBody(impostor: PhysicsImpostor): void;
  61500. wakeUpBody(impostor: PhysicsImpostor): void;
  61501. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61502. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61503. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61504. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61505. getRadius(impostor: PhysicsImpostor): number;
  61506. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61507. dispose(): void;
  61508. /**
  61509. * Does a raycast in the physics world
  61510. * @param from when should the ray start?
  61511. * @param to when should the ray end?
  61512. * @returns PhysicsRaycastResult
  61513. */
  61514. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61515. }
  61516. }
  61517. declare module BABYLON {
  61518. /**
  61519. * AmmoJS Physics plugin
  61520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61521. * @see https://github.com/kripken/ammo.js/
  61522. */
  61523. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61524. private _useDeltaForWorldStep;
  61525. /**
  61526. * Reference to the Ammo library
  61527. */
  61528. bjsAMMO: any;
  61529. /**
  61530. * Created ammoJS world which physics bodies are added to
  61531. */
  61532. world: any;
  61533. /**
  61534. * Name of the plugin
  61535. */
  61536. name: string;
  61537. private _timeStep;
  61538. private _fixedTimeStep;
  61539. private _maxSteps;
  61540. private _tmpQuaternion;
  61541. private _tmpAmmoTransform;
  61542. private _tmpAmmoQuaternion;
  61543. private _tmpAmmoConcreteContactResultCallback;
  61544. private _collisionConfiguration;
  61545. private _dispatcher;
  61546. private _overlappingPairCache;
  61547. private _solver;
  61548. private _softBodySolver;
  61549. private _tmpAmmoVectorA;
  61550. private _tmpAmmoVectorB;
  61551. private _tmpAmmoVectorC;
  61552. private _tmpAmmoVectorD;
  61553. private _tmpContactCallbackResult;
  61554. private _tmpAmmoVectorRCA;
  61555. private _tmpAmmoVectorRCB;
  61556. private _raycastResult;
  61557. private _tmpContactPoint;
  61558. private static readonly DISABLE_COLLISION_FLAG;
  61559. private static readonly KINEMATIC_FLAG;
  61560. private static readonly DISABLE_DEACTIVATION_FLAG;
  61561. /**
  61562. * Initializes the ammoJS plugin
  61563. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61564. * @param ammoInjection can be used to inject your own ammo reference
  61565. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61566. */
  61567. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61568. /**
  61569. * Sets the gravity of the physics world (m/(s^2))
  61570. * @param gravity Gravity to set
  61571. */
  61572. setGravity(gravity: Vector3): void;
  61573. /**
  61574. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61575. * @param timeStep timestep to use in seconds
  61576. */
  61577. setTimeStep(timeStep: number): void;
  61578. /**
  61579. * 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)
  61580. * @param fixedTimeStep fixedTimeStep to use in seconds
  61581. */
  61582. setFixedTimeStep(fixedTimeStep: number): void;
  61583. /**
  61584. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61585. * @param maxSteps the maximum number of steps by the physics engine per frame
  61586. */
  61587. setMaxSteps(maxSteps: number): void;
  61588. /**
  61589. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61590. * @returns the current timestep in seconds
  61591. */
  61592. getTimeStep(): number;
  61593. /**
  61594. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61595. */
  61596. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61597. private _isImpostorInContact;
  61598. private _isImpostorPairInContact;
  61599. private _stepSimulation;
  61600. /**
  61601. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61602. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61603. * After the step the babylon meshes are set to the position of the physics imposters
  61604. * @param delta amount of time to step forward
  61605. * @param impostors array of imposters to update before/after the step
  61606. */
  61607. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61608. /**
  61609. * Update babylon mesh to match physics world object
  61610. * @param impostor imposter to match
  61611. */
  61612. private _afterSoftStep;
  61613. /**
  61614. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61615. * @param impostor imposter to match
  61616. */
  61617. private _ropeStep;
  61618. /**
  61619. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61620. * @param impostor imposter to match
  61621. */
  61622. private _softbodyOrClothStep;
  61623. private _tmpMatrix;
  61624. /**
  61625. * Applies an impulse on the imposter
  61626. * @param impostor imposter to apply impulse to
  61627. * @param force amount of force to be applied to the imposter
  61628. * @param contactPoint the location to apply the impulse on the imposter
  61629. */
  61630. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61631. /**
  61632. * Applies a force on the imposter
  61633. * @param impostor imposter to apply force
  61634. * @param force amount of force to be applied to the imposter
  61635. * @param contactPoint the location to apply the force on the imposter
  61636. */
  61637. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61638. /**
  61639. * Creates a physics body using the plugin
  61640. * @param impostor the imposter to create the physics body on
  61641. */
  61642. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61643. /**
  61644. * Removes the physics body from the imposter and disposes of the body's memory
  61645. * @param impostor imposter to remove the physics body from
  61646. */
  61647. removePhysicsBody(impostor: PhysicsImpostor): void;
  61648. /**
  61649. * Generates a joint
  61650. * @param impostorJoint the imposter joint to create the joint with
  61651. */
  61652. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61653. /**
  61654. * Removes a joint
  61655. * @param impostorJoint the imposter joint to remove the joint from
  61656. */
  61657. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61658. private _addMeshVerts;
  61659. /**
  61660. * Initialise the soft body vertices to match its object's (mesh) vertices
  61661. * Softbody vertices (nodes) are in world space and to match this
  61662. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61663. * @param impostor to create the softbody for
  61664. */
  61665. private _softVertexData;
  61666. /**
  61667. * Create an impostor's soft body
  61668. * @param impostor to create the softbody for
  61669. */
  61670. private _createSoftbody;
  61671. /**
  61672. * Create cloth for an impostor
  61673. * @param impostor to create the softbody for
  61674. */
  61675. private _createCloth;
  61676. /**
  61677. * Create rope for an impostor
  61678. * @param impostor to create the softbody for
  61679. */
  61680. private _createRope;
  61681. /**
  61682. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61683. * @param impostor to create the custom physics shape for
  61684. */
  61685. private _createCustom;
  61686. private _addHullVerts;
  61687. private _createShape;
  61688. /**
  61689. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61690. * @param impostor imposter containing the physics body and babylon object
  61691. */
  61692. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61693. /**
  61694. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61695. * @param impostor imposter containing the physics body and babylon object
  61696. * @param newPosition new position
  61697. * @param newRotation new rotation
  61698. */
  61699. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61700. /**
  61701. * If this plugin is supported
  61702. * @returns true if its supported
  61703. */
  61704. isSupported(): boolean;
  61705. /**
  61706. * Sets the linear velocity of the physics body
  61707. * @param impostor imposter to set the velocity on
  61708. * @param velocity velocity to set
  61709. */
  61710. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61711. /**
  61712. * Sets the angular velocity of the physics body
  61713. * @param impostor imposter to set the velocity on
  61714. * @param velocity velocity to set
  61715. */
  61716. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61717. /**
  61718. * gets the linear velocity
  61719. * @param impostor imposter to get linear velocity from
  61720. * @returns linear velocity
  61721. */
  61722. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61723. /**
  61724. * gets the angular velocity
  61725. * @param impostor imposter to get angular velocity from
  61726. * @returns angular velocity
  61727. */
  61728. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61729. /**
  61730. * Sets the mass of physics body
  61731. * @param impostor imposter to set the mass on
  61732. * @param mass mass to set
  61733. */
  61734. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61735. /**
  61736. * Gets the mass of the physics body
  61737. * @param impostor imposter to get the mass from
  61738. * @returns mass
  61739. */
  61740. getBodyMass(impostor: PhysicsImpostor): number;
  61741. /**
  61742. * Gets friction of the impostor
  61743. * @param impostor impostor to get friction from
  61744. * @returns friction value
  61745. */
  61746. getBodyFriction(impostor: PhysicsImpostor): number;
  61747. /**
  61748. * Sets friction of the impostor
  61749. * @param impostor impostor to set friction on
  61750. * @param friction friction value
  61751. */
  61752. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61753. /**
  61754. * Gets restitution of the impostor
  61755. * @param impostor impostor to get restitution from
  61756. * @returns restitution value
  61757. */
  61758. getBodyRestitution(impostor: PhysicsImpostor): number;
  61759. /**
  61760. * Sets resitution of the impostor
  61761. * @param impostor impostor to set resitution on
  61762. * @param restitution resitution value
  61763. */
  61764. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61765. /**
  61766. * Gets pressure inside the impostor
  61767. * @param impostor impostor to get pressure from
  61768. * @returns pressure value
  61769. */
  61770. getBodyPressure(impostor: PhysicsImpostor): number;
  61771. /**
  61772. * Sets pressure inside a soft body impostor
  61773. * Cloth and rope must remain 0 pressure
  61774. * @param impostor impostor to set pressure on
  61775. * @param pressure pressure value
  61776. */
  61777. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61778. /**
  61779. * Gets stiffness of the impostor
  61780. * @param impostor impostor to get stiffness from
  61781. * @returns pressure value
  61782. */
  61783. getBodyStiffness(impostor: PhysicsImpostor): number;
  61784. /**
  61785. * Sets stiffness of the impostor
  61786. * @param impostor impostor to set stiffness on
  61787. * @param stiffness stiffness value from 0 to 1
  61788. */
  61789. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61790. /**
  61791. * Gets velocityIterations of the impostor
  61792. * @param impostor impostor to get velocity iterations from
  61793. * @returns velocityIterations value
  61794. */
  61795. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61796. /**
  61797. * Sets velocityIterations of the impostor
  61798. * @param impostor impostor to set velocity iterations on
  61799. * @param velocityIterations velocityIterations value
  61800. */
  61801. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61802. /**
  61803. * Gets positionIterations of the impostor
  61804. * @param impostor impostor to get position iterations from
  61805. * @returns positionIterations value
  61806. */
  61807. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61808. /**
  61809. * Sets positionIterations of the impostor
  61810. * @param impostor impostor to set position on
  61811. * @param positionIterations positionIterations value
  61812. */
  61813. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61814. /**
  61815. * Append an anchor to a cloth object
  61816. * @param impostor is the cloth impostor to add anchor to
  61817. * @param otherImpostor is the rigid impostor to anchor to
  61818. * @param width ratio across width from 0 to 1
  61819. * @param height ratio up height from 0 to 1
  61820. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61821. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61822. */
  61823. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61824. /**
  61825. * Append an hook to a rope object
  61826. * @param impostor is the rope impostor to add hook to
  61827. * @param otherImpostor is the rigid impostor to hook to
  61828. * @param length ratio along the rope from 0 to 1
  61829. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61830. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61831. */
  61832. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61833. /**
  61834. * Sleeps the physics body and stops it from being active
  61835. * @param impostor impostor to sleep
  61836. */
  61837. sleepBody(impostor: PhysicsImpostor): void;
  61838. /**
  61839. * Activates the physics body
  61840. * @param impostor impostor to activate
  61841. */
  61842. wakeUpBody(impostor: PhysicsImpostor): void;
  61843. /**
  61844. * Updates the distance parameters of the joint
  61845. * @param joint joint to update
  61846. * @param maxDistance maximum distance of the joint
  61847. * @param minDistance minimum distance of the joint
  61848. */
  61849. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61850. /**
  61851. * Sets a motor on the joint
  61852. * @param joint joint to set motor on
  61853. * @param speed speed of the motor
  61854. * @param maxForce maximum force of the motor
  61855. * @param motorIndex index of the motor
  61856. */
  61857. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61858. /**
  61859. * Sets the motors limit
  61860. * @param joint joint to set limit on
  61861. * @param upperLimit upper limit
  61862. * @param lowerLimit lower limit
  61863. */
  61864. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61865. /**
  61866. * Syncs the position and rotation of a mesh with the impostor
  61867. * @param mesh mesh to sync
  61868. * @param impostor impostor to update the mesh with
  61869. */
  61870. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61871. /**
  61872. * Gets the radius of the impostor
  61873. * @param impostor impostor to get radius from
  61874. * @returns the radius
  61875. */
  61876. getRadius(impostor: PhysicsImpostor): number;
  61877. /**
  61878. * Gets the box size of the impostor
  61879. * @param impostor impostor to get box size from
  61880. * @param result the resulting box size
  61881. */
  61882. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61883. /**
  61884. * Disposes of the impostor
  61885. */
  61886. dispose(): void;
  61887. /**
  61888. * Does a raycast in the physics world
  61889. * @param from when should the ray start?
  61890. * @param to when should the ray end?
  61891. * @returns PhysicsRaycastResult
  61892. */
  61893. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61894. }
  61895. }
  61896. declare module BABYLON {
  61897. interface AbstractScene {
  61898. /**
  61899. * The list of reflection probes added to the scene
  61900. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61901. */
  61902. reflectionProbes: Array<ReflectionProbe>;
  61903. /**
  61904. * Removes the given reflection probe from this scene.
  61905. * @param toRemove The reflection probe to remove
  61906. * @returns The index of the removed reflection probe
  61907. */
  61908. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61909. /**
  61910. * Adds the given reflection probe to this scene.
  61911. * @param newReflectionProbe The reflection probe to add
  61912. */
  61913. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61914. }
  61915. /**
  61916. * Class used to generate realtime reflection / refraction cube textures
  61917. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61918. */
  61919. export class ReflectionProbe {
  61920. /** defines the name of the probe */
  61921. name: string;
  61922. private _scene;
  61923. private _renderTargetTexture;
  61924. private _projectionMatrix;
  61925. private _viewMatrix;
  61926. private _target;
  61927. private _add;
  61928. private _attachedMesh;
  61929. private _invertYAxis;
  61930. /** Gets or sets probe position (center of the cube map) */
  61931. position: Vector3;
  61932. /**
  61933. * Creates a new reflection probe
  61934. * @param name defines the name of the probe
  61935. * @param size defines the texture resolution (for each face)
  61936. * @param scene defines the hosting scene
  61937. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61938. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61939. */
  61940. constructor(
  61941. /** defines the name of the probe */
  61942. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61943. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61944. get samples(): number;
  61945. set samples(value: number);
  61946. /** Gets or sets the refresh rate to use (on every frame by default) */
  61947. get refreshRate(): number;
  61948. set refreshRate(value: number);
  61949. /**
  61950. * Gets the hosting scene
  61951. * @returns a Scene
  61952. */
  61953. getScene(): Scene;
  61954. /** Gets the internal CubeTexture used to render to */
  61955. get cubeTexture(): RenderTargetTexture;
  61956. /** Gets the list of meshes to render */
  61957. get renderList(): Nullable<AbstractMesh[]>;
  61958. /**
  61959. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61960. * @param mesh defines the mesh to attach to
  61961. */
  61962. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61963. /**
  61964. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61965. * @param renderingGroupId The rendering group id corresponding to its index
  61966. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61967. */
  61968. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61969. /**
  61970. * Clean all associated resources
  61971. */
  61972. dispose(): void;
  61973. /**
  61974. * Converts the reflection probe information to a readable string for debug purpose.
  61975. * @param fullDetails Supports for multiple levels of logging within scene loading
  61976. * @returns the human readable reflection probe info
  61977. */
  61978. toString(fullDetails?: boolean): string;
  61979. /**
  61980. * Get the class name of the relfection probe.
  61981. * @returns "ReflectionProbe"
  61982. */
  61983. getClassName(): string;
  61984. /**
  61985. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61986. * @returns The JSON representation of the texture
  61987. */
  61988. serialize(): any;
  61989. /**
  61990. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61991. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61992. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61993. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61994. * @returns The parsed reflection probe if successful
  61995. */
  61996. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61997. }
  61998. }
  61999. declare module BABYLON {
  62000. /** @hidden */
  62001. export var _BabylonLoaderRegistered: boolean;
  62002. /**
  62003. * Helps setting up some configuration for the babylon file loader.
  62004. */
  62005. export class BabylonFileLoaderConfiguration {
  62006. /**
  62007. * The loader does not allow injecting custom physix engine into the plugins.
  62008. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62009. * So you could set this variable to your engine import to make it work.
  62010. */
  62011. static LoaderInjectedPhysicsEngine: any;
  62012. }
  62013. }
  62014. declare module BABYLON {
  62015. /**
  62016. * The Physically based simple base material of BJS.
  62017. *
  62018. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62019. * It is used as the base class for both the specGloss and metalRough conventions.
  62020. */
  62021. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62022. /**
  62023. * Number of Simultaneous lights allowed on the material.
  62024. */
  62025. maxSimultaneousLights: number;
  62026. /**
  62027. * If sets to true, disables all the lights affecting the material.
  62028. */
  62029. disableLighting: boolean;
  62030. /**
  62031. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62032. */
  62033. environmentTexture: BaseTexture;
  62034. /**
  62035. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62036. */
  62037. invertNormalMapX: boolean;
  62038. /**
  62039. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62040. */
  62041. invertNormalMapY: boolean;
  62042. /**
  62043. * Normal map used in the model.
  62044. */
  62045. normalTexture: BaseTexture;
  62046. /**
  62047. * Emissivie color used to self-illuminate the model.
  62048. */
  62049. emissiveColor: Color3;
  62050. /**
  62051. * Emissivie texture used to self-illuminate the model.
  62052. */
  62053. emissiveTexture: BaseTexture;
  62054. /**
  62055. * Occlusion Channel Strenght.
  62056. */
  62057. occlusionStrength: number;
  62058. /**
  62059. * Occlusion Texture of the material (adding extra occlusion effects).
  62060. */
  62061. occlusionTexture: BaseTexture;
  62062. /**
  62063. * Defines the alpha limits in alpha test mode.
  62064. */
  62065. alphaCutOff: number;
  62066. /**
  62067. * Gets the current double sided mode.
  62068. */
  62069. get doubleSided(): boolean;
  62070. /**
  62071. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62072. */
  62073. set doubleSided(value: boolean);
  62074. /**
  62075. * Stores the pre-calculated light information of a mesh in a texture.
  62076. */
  62077. lightmapTexture: BaseTexture;
  62078. /**
  62079. * If true, the light map contains occlusion information instead of lighting info.
  62080. */
  62081. useLightmapAsShadowmap: boolean;
  62082. /**
  62083. * Instantiates a new PBRMaterial instance.
  62084. *
  62085. * @param name The material name
  62086. * @param scene The scene the material will be use in.
  62087. */
  62088. constructor(name: string, scene: Scene);
  62089. getClassName(): string;
  62090. }
  62091. }
  62092. declare module BABYLON {
  62093. /**
  62094. * The PBR material of BJS following the metal roughness convention.
  62095. *
  62096. * This fits to the PBR convention in the GLTF definition:
  62097. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62098. */
  62099. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62100. /**
  62101. * The base color has two different interpretations depending on the value of metalness.
  62102. * When the material is a metal, the base color is the specific measured reflectance value
  62103. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62104. * of the material.
  62105. */
  62106. baseColor: Color3;
  62107. /**
  62108. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62109. * well as opacity information in the alpha channel.
  62110. */
  62111. baseTexture: BaseTexture;
  62112. /**
  62113. * Specifies the metallic scalar value of the material.
  62114. * Can also be used to scale the metalness values of the metallic texture.
  62115. */
  62116. metallic: number;
  62117. /**
  62118. * Specifies the roughness scalar value of the material.
  62119. * Can also be used to scale the roughness values of the metallic texture.
  62120. */
  62121. roughness: number;
  62122. /**
  62123. * Texture containing both the metallic value in the B channel and the
  62124. * roughness value in the G channel to keep better precision.
  62125. */
  62126. metallicRoughnessTexture: BaseTexture;
  62127. /**
  62128. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62129. *
  62130. * @param name The material name
  62131. * @param scene The scene the material will be use in.
  62132. */
  62133. constructor(name: string, scene: Scene);
  62134. /**
  62135. * Return the currrent class name of the material.
  62136. */
  62137. getClassName(): string;
  62138. /**
  62139. * Makes a duplicate of the current material.
  62140. * @param name - name to use for the new material.
  62141. */
  62142. clone(name: string): PBRMetallicRoughnessMaterial;
  62143. /**
  62144. * Serialize the material to a parsable JSON object.
  62145. */
  62146. serialize(): any;
  62147. /**
  62148. * Parses a JSON object correponding to the serialize function.
  62149. */
  62150. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62151. }
  62152. }
  62153. declare module BABYLON {
  62154. /**
  62155. * The PBR material of BJS following the specular glossiness convention.
  62156. *
  62157. * This fits to the PBR convention in the GLTF definition:
  62158. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62159. */
  62160. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62161. /**
  62162. * Specifies the diffuse color of the material.
  62163. */
  62164. diffuseColor: Color3;
  62165. /**
  62166. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62167. * channel.
  62168. */
  62169. diffuseTexture: BaseTexture;
  62170. /**
  62171. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62172. */
  62173. specularColor: Color3;
  62174. /**
  62175. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62176. */
  62177. glossiness: number;
  62178. /**
  62179. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62180. */
  62181. specularGlossinessTexture: BaseTexture;
  62182. /**
  62183. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62184. *
  62185. * @param name The material name
  62186. * @param scene The scene the material will be use in.
  62187. */
  62188. constructor(name: string, scene: Scene);
  62189. /**
  62190. * Return the currrent class name of the material.
  62191. */
  62192. getClassName(): string;
  62193. /**
  62194. * Makes a duplicate of the current material.
  62195. * @param name - name to use for the new material.
  62196. */
  62197. clone(name: string): PBRSpecularGlossinessMaterial;
  62198. /**
  62199. * Serialize the material to a parsable JSON object.
  62200. */
  62201. serialize(): any;
  62202. /**
  62203. * Parses a JSON object correponding to the serialize function.
  62204. */
  62205. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62206. }
  62207. }
  62208. declare module BABYLON {
  62209. /**
  62210. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62211. * It can help converting any input color in a desired output one. This can then be used to create effects
  62212. * from sepia, black and white to sixties or futuristic rendering...
  62213. *
  62214. * The only supported format is currently 3dl.
  62215. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62216. */
  62217. export class ColorGradingTexture extends BaseTexture {
  62218. /**
  62219. * The texture URL.
  62220. */
  62221. url: string;
  62222. /**
  62223. * Empty line regex stored for GC.
  62224. */
  62225. private static _noneEmptyLineRegex;
  62226. private _textureMatrix;
  62227. private _onLoad;
  62228. /**
  62229. * Instantiates a ColorGradingTexture from the following parameters.
  62230. *
  62231. * @param url The location of the color gradind data (currently only supporting 3dl)
  62232. * @param sceneOrEngine The scene or engine the texture will be used in
  62233. * @param onLoad defines a callback triggered when the texture has been loaded
  62234. */
  62235. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62236. /**
  62237. * Fires the onload event from the constructor if requested.
  62238. */
  62239. private _triggerOnLoad;
  62240. /**
  62241. * Returns the texture matrix used in most of the material.
  62242. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62243. */
  62244. getTextureMatrix(): Matrix;
  62245. /**
  62246. * Occurs when the file being loaded is a .3dl LUT file.
  62247. */
  62248. private load3dlTexture;
  62249. /**
  62250. * Starts the loading process of the texture.
  62251. */
  62252. private loadTexture;
  62253. /**
  62254. * Clones the color gradind texture.
  62255. */
  62256. clone(): ColorGradingTexture;
  62257. /**
  62258. * Called during delayed load for textures.
  62259. */
  62260. delayLoad(): void;
  62261. /**
  62262. * Parses a color grading texture serialized by Babylon.
  62263. * @param parsedTexture The texture information being parsedTexture
  62264. * @param scene The scene to load the texture in
  62265. * @param rootUrl The root url of the data assets to load
  62266. * @return A color gradind texture
  62267. */
  62268. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62269. /**
  62270. * Serializes the LUT texture to json format.
  62271. */
  62272. serialize(): any;
  62273. }
  62274. }
  62275. declare module BABYLON {
  62276. /**
  62277. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62278. */
  62279. export class EquiRectangularCubeTexture extends BaseTexture {
  62280. /** The six faces of the cube. */
  62281. private static _FacesMapping;
  62282. private _noMipmap;
  62283. private _onLoad;
  62284. private _onError;
  62285. /** The size of the cubemap. */
  62286. private _size;
  62287. /** The buffer of the image. */
  62288. private _buffer;
  62289. /** The width of the input image. */
  62290. private _width;
  62291. /** The height of the input image. */
  62292. private _height;
  62293. /** The URL to the image. */
  62294. url: string;
  62295. /**
  62296. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62297. * @param url The location of the image
  62298. * @param scene The scene the texture will be used in
  62299. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62300. * @param noMipmap Forces to not generate the mipmap if true
  62301. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62302. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62303. * @param onLoad — defines a callback called when texture is loaded
  62304. * @param onError — defines a callback called if there is an error
  62305. */
  62306. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62307. /**
  62308. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62309. */
  62310. private loadImage;
  62311. /**
  62312. * Convert the image buffer into a cubemap and create a CubeTexture.
  62313. */
  62314. private loadTexture;
  62315. /**
  62316. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62317. * @param buffer The ArrayBuffer that should be converted.
  62318. * @returns The buffer as Float32Array.
  62319. */
  62320. private getFloat32ArrayFromArrayBuffer;
  62321. /**
  62322. * Get the current class name of the texture useful for serialization or dynamic coding.
  62323. * @returns "EquiRectangularCubeTexture"
  62324. */
  62325. getClassName(): string;
  62326. /**
  62327. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62328. * @returns A clone of the current EquiRectangularCubeTexture.
  62329. */
  62330. clone(): EquiRectangularCubeTexture;
  62331. }
  62332. }
  62333. declare module BABYLON {
  62334. /**
  62335. * Defines the options related to the creation of an HtmlElementTexture
  62336. */
  62337. export interface IHtmlElementTextureOptions {
  62338. /**
  62339. * Defines wether mip maps should be created or not.
  62340. */
  62341. generateMipMaps?: boolean;
  62342. /**
  62343. * Defines the sampling mode of the texture.
  62344. */
  62345. samplingMode?: number;
  62346. /**
  62347. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62348. */
  62349. engine: Nullable<ThinEngine>;
  62350. /**
  62351. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62352. */
  62353. scene: Nullable<Scene>;
  62354. }
  62355. /**
  62356. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62357. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62358. * is automatically managed.
  62359. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62360. * in your application.
  62361. *
  62362. * As the update is not automatic, you need to call them manually.
  62363. */
  62364. export class HtmlElementTexture extends BaseTexture {
  62365. /**
  62366. * The texture URL.
  62367. */
  62368. element: HTMLVideoElement | HTMLCanvasElement;
  62369. private static readonly DefaultOptions;
  62370. private _textureMatrix;
  62371. private _isVideo;
  62372. private _generateMipMaps;
  62373. private _samplingMode;
  62374. /**
  62375. * Instantiates a HtmlElementTexture from the following parameters.
  62376. *
  62377. * @param name Defines the name of the texture
  62378. * @param element Defines the video or canvas the texture is filled with
  62379. * @param options Defines the other none mandatory texture creation options
  62380. */
  62381. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62382. private _createInternalTexture;
  62383. /**
  62384. * Returns the texture matrix used in most of the material.
  62385. */
  62386. getTextureMatrix(): Matrix;
  62387. /**
  62388. * Updates the content of the texture.
  62389. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62390. */
  62391. update(invertY?: Nullable<boolean>): void;
  62392. }
  62393. }
  62394. declare module BABYLON {
  62395. /**
  62396. * Based on jsTGALoader - Javascript loader for TGA file
  62397. * By Vincent Thibault
  62398. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62399. */
  62400. export class TGATools {
  62401. private static _TYPE_INDEXED;
  62402. private static _TYPE_RGB;
  62403. private static _TYPE_GREY;
  62404. private static _TYPE_RLE_INDEXED;
  62405. private static _TYPE_RLE_RGB;
  62406. private static _TYPE_RLE_GREY;
  62407. private static _ORIGIN_MASK;
  62408. private static _ORIGIN_SHIFT;
  62409. private static _ORIGIN_BL;
  62410. private static _ORIGIN_BR;
  62411. private static _ORIGIN_UL;
  62412. private static _ORIGIN_UR;
  62413. /**
  62414. * Gets the header of a TGA file
  62415. * @param data defines the TGA data
  62416. * @returns the header
  62417. */
  62418. static GetTGAHeader(data: Uint8Array): any;
  62419. /**
  62420. * Uploads TGA content to a Babylon Texture
  62421. * @hidden
  62422. */
  62423. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62424. /** @hidden */
  62425. 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;
  62426. /** @hidden */
  62427. 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;
  62428. /** @hidden */
  62429. 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;
  62430. /** @hidden */
  62431. 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;
  62432. /** @hidden */
  62433. 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;
  62434. /** @hidden */
  62435. 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;
  62436. }
  62437. }
  62438. declare module BABYLON {
  62439. /**
  62440. * Implementation of the TGA Texture Loader.
  62441. * @hidden
  62442. */
  62443. export class _TGATextureLoader implements IInternalTextureLoader {
  62444. /**
  62445. * Defines wether the loader supports cascade loading the different faces.
  62446. */
  62447. readonly supportCascades: boolean;
  62448. /**
  62449. * This returns if the loader support the current file information.
  62450. * @param extension defines the file extension of the file being loaded
  62451. * @returns true if the loader can load the specified file
  62452. */
  62453. canLoad(extension: string): boolean;
  62454. /**
  62455. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62456. * @param data contains the texture data
  62457. * @param texture defines the BabylonJS internal texture
  62458. * @param createPolynomials will be true if polynomials have been requested
  62459. * @param onLoad defines the callback to trigger once the texture is ready
  62460. * @param onError defines the callback to trigger in case of error
  62461. */
  62462. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62463. /**
  62464. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62465. * @param data contains the texture data
  62466. * @param texture defines the BabylonJS internal texture
  62467. * @param callback defines the method to call once ready to upload
  62468. */
  62469. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62470. }
  62471. }
  62472. declare module BABYLON {
  62473. /**
  62474. * Info about the .basis files
  62475. */
  62476. class BasisFileInfo {
  62477. /**
  62478. * If the file has alpha
  62479. */
  62480. hasAlpha: boolean;
  62481. /**
  62482. * Info about each image of the basis file
  62483. */
  62484. images: Array<{
  62485. levels: Array<{
  62486. width: number;
  62487. height: number;
  62488. transcodedPixels: ArrayBufferView;
  62489. }>;
  62490. }>;
  62491. }
  62492. /**
  62493. * Result of transcoding a basis file
  62494. */
  62495. class TranscodeResult {
  62496. /**
  62497. * Info about the .basis file
  62498. */
  62499. fileInfo: BasisFileInfo;
  62500. /**
  62501. * Format to use when loading the file
  62502. */
  62503. format: number;
  62504. }
  62505. /**
  62506. * Configuration options for the Basis transcoder
  62507. */
  62508. export class BasisTranscodeConfiguration {
  62509. /**
  62510. * Supported compression formats used to determine the supported output format of the transcoder
  62511. */
  62512. supportedCompressionFormats?: {
  62513. /**
  62514. * etc1 compression format
  62515. */
  62516. etc1?: boolean;
  62517. /**
  62518. * s3tc compression format
  62519. */
  62520. s3tc?: boolean;
  62521. /**
  62522. * pvrtc compression format
  62523. */
  62524. pvrtc?: boolean;
  62525. /**
  62526. * etc2 compression format
  62527. */
  62528. etc2?: boolean;
  62529. };
  62530. /**
  62531. * If mipmap levels should be loaded for transcoded images (Default: true)
  62532. */
  62533. loadMipmapLevels?: boolean;
  62534. /**
  62535. * Index of a single image to load (Default: all images)
  62536. */
  62537. loadSingleImage?: number;
  62538. }
  62539. /**
  62540. * Used to load .Basis files
  62541. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62542. */
  62543. export class BasisTools {
  62544. private static _IgnoreSupportedFormats;
  62545. /**
  62546. * URL to use when loading the basis transcoder
  62547. */
  62548. static JSModuleURL: string;
  62549. /**
  62550. * URL to use when loading the wasm module for the transcoder
  62551. */
  62552. static WasmModuleURL: string;
  62553. /**
  62554. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62555. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62556. * @returns internal format corresponding to the Basis format
  62557. */
  62558. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62559. private static _WorkerPromise;
  62560. private static _Worker;
  62561. private static _actionId;
  62562. private static _CreateWorkerAsync;
  62563. /**
  62564. * Transcodes a loaded image file to compressed pixel data
  62565. * @param data image data to transcode
  62566. * @param config configuration options for the transcoding
  62567. * @returns a promise resulting in the transcoded image
  62568. */
  62569. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62570. /**
  62571. * Loads a texture from the transcode result
  62572. * @param texture texture load to
  62573. * @param transcodeResult the result of transcoding the basis file to load from
  62574. */
  62575. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62576. }
  62577. }
  62578. declare module BABYLON {
  62579. /**
  62580. * Loader for .basis file format
  62581. */
  62582. export class _BasisTextureLoader implements IInternalTextureLoader {
  62583. /**
  62584. * Defines whether the loader supports cascade loading the different faces.
  62585. */
  62586. readonly supportCascades: boolean;
  62587. /**
  62588. * This returns if the loader support the current file information.
  62589. * @param extension defines the file extension of the file being loaded
  62590. * @returns true if the loader can load the specified file
  62591. */
  62592. canLoad(extension: string): boolean;
  62593. /**
  62594. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62595. * @param data contains the texture data
  62596. * @param texture defines the BabylonJS internal texture
  62597. * @param createPolynomials will be true if polynomials have been requested
  62598. * @param onLoad defines the callback to trigger once the texture is ready
  62599. * @param onError defines the callback to trigger in case of error
  62600. */
  62601. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62602. /**
  62603. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62604. * @param data contains the texture data
  62605. * @param texture defines the BabylonJS internal texture
  62606. * @param callback defines the method to call once ready to upload
  62607. */
  62608. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62609. }
  62610. }
  62611. declare module BABYLON {
  62612. /**
  62613. * Defines the basic options interface of a TexturePacker Frame
  62614. */
  62615. export interface ITexturePackerFrame {
  62616. /**
  62617. * The frame ID
  62618. */
  62619. id: number;
  62620. /**
  62621. * The frames Scale
  62622. */
  62623. scale: Vector2;
  62624. /**
  62625. * The Frames offset
  62626. */
  62627. offset: Vector2;
  62628. }
  62629. /**
  62630. * This is a support class for frame Data on texture packer sets.
  62631. */
  62632. export class TexturePackerFrame implements ITexturePackerFrame {
  62633. /**
  62634. * The frame ID
  62635. */
  62636. id: number;
  62637. /**
  62638. * The frames Scale
  62639. */
  62640. scale: Vector2;
  62641. /**
  62642. * The Frames offset
  62643. */
  62644. offset: Vector2;
  62645. /**
  62646. * Initializes a texture package frame.
  62647. * @param id The numerical frame identifier
  62648. * @param scale Scalar Vector2 for UV frame
  62649. * @param offset Vector2 for the frame position in UV units.
  62650. * @returns TexturePackerFrame
  62651. */
  62652. constructor(id: number, scale: Vector2, offset: Vector2);
  62653. }
  62654. }
  62655. declare module BABYLON {
  62656. /**
  62657. * Defines the basic options interface of a TexturePacker
  62658. */
  62659. export interface ITexturePackerOptions {
  62660. /**
  62661. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62662. */
  62663. map?: string[];
  62664. /**
  62665. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62666. */
  62667. uvsIn?: string;
  62668. /**
  62669. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62670. */
  62671. uvsOut?: string;
  62672. /**
  62673. * number representing the layout style. Defaults to LAYOUT_STRIP
  62674. */
  62675. layout?: number;
  62676. /**
  62677. * number of columns if using custom column count layout(2). This defaults to 4.
  62678. */
  62679. colnum?: number;
  62680. /**
  62681. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62682. */
  62683. updateInputMeshes?: boolean;
  62684. /**
  62685. * boolean flag to dispose all the source textures. Defaults to true.
  62686. */
  62687. disposeSources?: boolean;
  62688. /**
  62689. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62690. */
  62691. fillBlanks?: boolean;
  62692. /**
  62693. * string value representing the context fill style color. Defaults to 'black'.
  62694. */
  62695. customFillColor?: string;
  62696. /**
  62697. * Width and Height Value of each Frame in the TexturePacker Sets
  62698. */
  62699. frameSize?: number;
  62700. /**
  62701. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62702. */
  62703. paddingRatio?: number;
  62704. /**
  62705. * Number that declares the fill method for the padding gutter.
  62706. */
  62707. paddingMode?: number;
  62708. /**
  62709. * If in SUBUV_COLOR padding mode what color to use.
  62710. */
  62711. paddingColor?: Color3 | Color4;
  62712. }
  62713. /**
  62714. * Defines the basic interface of a TexturePacker JSON File
  62715. */
  62716. export interface ITexturePackerJSON {
  62717. /**
  62718. * The frame ID
  62719. */
  62720. name: string;
  62721. /**
  62722. * The base64 channel data
  62723. */
  62724. sets: any;
  62725. /**
  62726. * The options of the Packer
  62727. */
  62728. options: ITexturePackerOptions;
  62729. /**
  62730. * The frame data of the Packer
  62731. */
  62732. frames: Array<number>;
  62733. }
  62734. /**
  62735. * This is a support class that generates a series of packed texture sets.
  62736. * @see https://doc.babylonjs.com/babylon101/materials
  62737. */
  62738. export class TexturePacker {
  62739. /** Packer Layout Constant 0 */
  62740. static readonly LAYOUT_STRIP: number;
  62741. /** Packer Layout Constant 1 */
  62742. static readonly LAYOUT_POWER2: number;
  62743. /** Packer Layout Constant 2 */
  62744. static readonly LAYOUT_COLNUM: number;
  62745. /** Packer Layout Constant 0 */
  62746. static readonly SUBUV_WRAP: number;
  62747. /** Packer Layout Constant 1 */
  62748. static readonly SUBUV_EXTEND: number;
  62749. /** Packer Layout Constant 2 */
  62750. static readonly SUBUV_COLOR: number;
  62751. /** The Name of the Texture Package */
  62752. name: string;
  62753. /** The scene scope of the TexturePacker */
  62754. scene: Scene;
  62755. /** The Meshes to target */
  62756. meshes: AbstractMesh[];
  62757. /** Arguments passed with the Constructor */
  62758. options: ITexturePackerOptions;
  62759. /** The promise that is started upon initialization */
  62760. promise: Nullable<Promise<TexturePacker | string>>;
  62761. /** The Container object for the channel sets that are generated */
  62762. sets: object;
  62763. /** The Container array for the frames that are generated */
  62764. frames: TexturePackerFrame[];
  62765. /** The expected number of textures the system is parsing. */
  62766. private _expecting;
  62767. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62768. private _paddingValue;
  62769. /**
  62770. * Initializes a texture package series from an array of meshes or a single mesh.
  62771. * @param name The name of the package
  62772. * @param meshes The target meshes to compose the package from
  62773. * @param options The arguments that texture packer should follow while building.
  62774. * @param scene The scene which the textures are scoped to.
  62775. * @returns TexturePacker
  62776. */
  62777. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62778. /**
  62779. * Starts the package process
  62780. * @param resolve The promises resolution function
  62781. * @returns TexturePacker
  62782. */
  62783. private _createFrames;
  62784. /**
  62785. * Calculates the Size of the Channel Sets
  62786. * @returns Vector2
  62787. */
  62788. private _calculateSize;
  62789. /**
  62790. * Calculates the UV data for the frames.
  62791. * @param baseSize the base frameSize
  62792. * @param padding the base frame padding
  62793. * @param dtSize size of the Dynamic Texture for that channel
  62794. * @param dtUnits is 1/dtSize
  62795. * @param update flag to update the input meshes
  62796. */
  62797. private _calculateMeshUVFrames;
  62798. /**
  62799. * Calculates the frames Offset.
  62800. * @param index of the frame
  62801. * @returns Vector2
  62802. */
  62803. private _getFrameOffset;
  62804. /**
  62805. * Updates a Mesh to the frame data
  62806. * @param mesh that is the target
  62807. * @param frameID or the frame index
  62808. */
  62809. private _updateMeshUV;
  62810. /**
  62811. * Updates a Meshes materials to use the texture packer channels
  62812. * @param m is the mesh to target
  62813. * @param force all channels on the packer to be set.
  62814. */
  62815. private _updateTextureReferences;
  62816. /**
  62817. * Public method to set a Mesh to a frame
  62818. * @param m that is the target
  62819. * @param frameID or the frame index
  62820. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62821. */
  62822. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62823. /**
  62824. * Starts the async promise to compile the texture packer.
  62825. * @returns Promise<void>
  62826. */
  62827. processAsync(): Promise<void>;
  62828. /**
  62829. * Disposes all textures associated with this packer
  62830. */
  62831. dispose(): void;
  62832. /**
  62833. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62834. * @param imageType is the image type to use.
  62835. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62836. */
  62837. download(imageType?: string, quality?: number): void;
  62838. /**
  62839. * Public method to load a texturePacker JSON file.
  62840. * @param data of the JSON file in string format.
  62841. */
  62842. updateFromJSON(data: string): void;
  62843. }
  62844. }
  62845. declare module BABYLON {
  62846. /**
  62847. * 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.
  62848. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62849. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62850. */
  62851. export class CustomProceduralTexture extends ProceduralTexture {
  62852. private _animate;
  62853. private _time;
  62854. private _config;
  62855. private _texturePath;
  62856. /**
  62857. * Instantiates a new Custom Procedural Texture.
  62858. * 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.
  62859. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62860. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62861. * @param name Define the name of the texture
  62862. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62863. * @param size Define the size of the texture to create
  62864. * @param scene Define the scene the texture belongs to
  62865. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62866. * @param generateMipMaps Define if the texture should creates mip maps or not
  62867. */
  62868. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62869. private _loadJson;
  62870. /**
  62871. * Is the texture ready to be used ? (rendered at least once)
  62872. * @returns true if ready, otherwise, false.
  62873. */
  62874. isReady(): boolean;
  62875. /**
  62876. * Render the texture to its associated render target.
  62877. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62878. */
  62879. render(useCameraPostProcess?: boolean): void;
  62880. /**
  62881. * Update the list of dependant textures samplers in the shader.
  62882. */
  62883. updateTextures(): void;
  62884. /**
  62885. * Update the uniform values of the procedural texture in the shader.
  62886. */
  62887. updateShaderUniforms(): void;
  62888. /**
  62889. * Define if the texture animates or not.
  62890. */
  62891. get animate(): boolean;
  62892. set animate(value: boolean);
  62893. }
  62894. }
  62895. declare module BABYLON {
  62896. /** @hidden */
  62897. export var noisePixelShader: {
  62898. name: string;
  62899. shader: string;
  62900. };
  62901. }
  62902. declare module BABYLON {
  62903. /**
  62904. * Class used to generate noise procedural textures
  62905. */
  62906. export class NoiseProceduralTexture extends ProceduralTexture {
  62907. /** Gets or sets the start time (default is 0) */
  62908. time: number;
  62909. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62910. brightness: number;
  62911. /** Defines the number of octaves to process */
  62912. octaves: number;
  62913. /** Defines the level of persistence (0.8 by default) */
  62914. persistence: number;
  62915. /** Gets or sets animation speed factor (default is 1) */
  62916. animationSpeedFactor: number;
  62917. /**
  62918. * Creates a new NoiseProceduralTexture
  62919. * @param name defines the name fo the texture
  62920. * @param size defines the size of the texture (default is 256)
  62921. * @param scene defines the hosting scene
  62922. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62923. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62924. */
  62925. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62926. private _updateShaderUniforms;
  62927. protected _getDefines(): string;
  62928. /** Generate the current state of the procedural texture */
  62929. render(useCameraPostProcess?: boolean): void;
  62930. /**
  62931. * Serializes this noise procedural texture
  62932. * @returns a serialized noise procedural texture object
  62933. */
  62934. serialize(): any;
  62935. /**
  62936. * Clone the texture.
  62937. * @returns the cloned texture
  62938. */
  62939. clone(): NoiseProceduralTexture;
  62940. /**
  62941. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62942. * @param parsedTexture defines parsed texture data
  62943. * @param scene defines the current scene
  62944. * @param rootUrl defines the root URL containing noise procedural texture information
  62945. * @returns a parsed NoiseProceduralTexture
  62946. */
  62947. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62948. }
  62949. }
  62950. declare module BABYLON {
  62951. /**
  62952. * Raw cube texture where the raw buffers are passed in
  62953. */
  62954. export class RawCubeTexture extends CubeTexture {
  62955. /**
  62956. * Creates a cube texture where the raw buffers are passed in.
  62957. * @param scene defines the scene the texture is attached to
  62958. * @param data defines the array of data to use to create each face
  62959. * @param size defines the size of the textures
  62960. * @param format defines the format of the data
  62961. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62962. * @param generateMipMaps defines if the engine should generate the mip levels
  62963. * @param invertY defines if data must be stored with Y axis inverted
  62964. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62965. * @param compression defines the compression used (null by default)
  62966. */
  62967. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62968. /**
  62969. * Updates the raw cube texture.
  62970. * @param data defines the data to store
  62971. * @param format defines the data format
  62972. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62973. * @param invertY defines if data must be stored with Y axis inverted
  62974. * @param compression defines the compression used (null by default)
  62975. * @param level defines which level of the texture to update
  62976. */
  62977. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62978. /**
  62979. * Updates a raw cube texture with RGBD encoded data.
  62980. * @param data defines the array of data [mipmap][face] to use to create each face
  62981. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62982. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62983. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62984. * @returns a promsie that resolves when the operation is complete
  62985. */
  62986. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62987. /**
  62988. * Clones the raw cube texture.
  62989. * @return a new cube texture
  62990. */
  62991. clone(): CubeTexture;
  62992. /** @hidden */
  62993. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62994. }
  62995. }
  62996. declare module BABYLON {
  62997. /**
  62998. * Class used to store 2D array textures containing user data
  62999. */
  63000. export class RawTexture2DArray extends Texture {
  63001. /** Gets or sets the texture format to use */
  63002. format: number;
  63003. /**
  63004. * Create a new RawTexture2DArray
  63005. * @param data defines the data of the texture
  63006. * @param width defines the width of the texture
  63007. * @param height defines the height of the texture
  63008. * @param depth defines the number of layers of the texture
  63009. * @param format defines the texture format to use
  63010. * @param scene defines the hosting scene
  63011. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63012. * @param invertY defines if texture must be stored with Y axis inverted
  63013. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63014. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63015. */
  63016. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63017. /** Gets or sets the texture format to use */
  63018. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63019. /**
  63020. * Update the texture with new data
  63021. * @param data defines the data to store in the texture
  63022. */
  63023. update(data: ArrayBufferView): void;
  63024. }
  63025. }
  63026. declare module BABYLON {
  63027. /**
  63028. * Class used to store 3D textures containing user data
  63029. */
  63030. export class RawTexture3D extends Texture {
  63031. /** Gets or sets the texture format to use */
  63032. format: number;
  63033. /**
  63034. * Create a new RawTexture3D
  63035. * @param data defines the data of the texture
  63036. * @param width defines the width of the texture
  63037. * @param height defines the height of the texture
  63038. * @param depth defines the depth of the texture
  63039. * @param format defines the texture format to use
  63040. * @param scene defines the hosting scene
  63041. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63042. * @param invertY defines if texture must be stored with Y axis inverted
  63043. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63044. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63045. */
  63046. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63047. /** Gets or sets the texture format to use */
  63048. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63049. /**
  63050. * Update the texture with new data
  63051. * @param data defines the data to store in the texture
  63052. */
  63053. update(data: ArrayBufferView): void;
  63054. }
  63055. }
  63056. declare module BABYLON {
  63057. /**
  63058. * Creates a refraction texture used by refraction channel of the standard material.
  63059. * It is like a mirror but to see through a material.
  63060. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63061. */
  63062. export class RefractionTexture extends RenderTargetTexture {
  63063. /**
  63064. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63065. * 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.
  63066. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63067. */
  63068. refractionPlane: Plane;
  63069. /**
  63070. * Define how deep under the surface we should see.
  63071. */
  63072. depth: number;
  63073. /**
  63074. * Creates a refraction texture used by refraction channel of the standard material.
  63075. * It is like a mirror but to see through a material.
  63076. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63077. * @param name Define the texture name
  63078. * @param size Define the size of the underlying texture
  63079. * @param scene Define the scene the refraction belongs to
  63080. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63081. */
  63082. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63083. /**
  63084. * Clone the refraction texture.
  63085. * @returns the cloned texture
  63086. */
  63087. clone(): RefractionTexture;
  63088. /**
  63089. * Serialize the texture to a JSON representation you could use in Parse later on
  63090. * @returns the serialized JSON representation
  63091. */
  63092. serialize(): any;
  63093. }
  63094. }
  63095. declare module BABYLON {
  63096. /**
  63097. * Block used to add support for vertex skinning (bones)
  63098. */
  63099. export class BonesBlock extends NodeMaterialBlock {
  63100. /**
  63101. * Creates a new BonesBlock
  63102. * @param name defines the block name
  63103. */
  63104. constructor(name: string);
  63105. /**
  63106. * Initialize the block and prepare the context for build
  63107. * @param state defines the state that will be used for the build
  63108. */
  63109. initialize(state: NodeMaterialBuildState): void;
  63110. /**
  63111. * Gets the current class name
  63112. * @returns the class name
  63113. */
  63114. getClassName(): string;
  63115. /**
  63116. * Gets the matrix indices input component
  63117. */
  63118. get matricesIndices(): NodeMaterialConnectionPoint;
  63119. /**
  63120. * Gets the matrix weights input component
  63121. */
  63122. get matricesWeights(): NodeMaterialConnectionPoint;
  63123. /**
  63124. * Gets the extra matrix indices input component
  63125. */
  63126. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63127. /**
  63128. * Gets the extra matrix weights input component
  63129. */
  63130. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63131. /**
  63132. * Gets the world input component
  63133. */
  63134. get world(): NodeMaterialConnectionPoint;
  63135. /**
  63136. * Gets the output component
  63137. */
  63138. get output(): NodeMaterialConnectionPoint;
  63139. autoConfigure(material: NodeMaterial): void;
  63140. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63141. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63142. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63143. protected _buildBlock(state: NodeMaterialBuildState): this;
  63144. }
  63145. }
  63146. declare module BABYLON {
  63147. /**
  63148. * Block used to add support for instances
  63149. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63150. */
  63151. export class InstancesBlock extends NodeMaterialBlock {
  63152. /**
  63153. * Creates a new InstancesBlock
  63154. * @param name defines the block name
  63155. */
  63156. constructor(name: string);
  63157. /**
  63158. * Gets the current class name
  63159. * @returns the class name
  63160. */
  63161. getClassName(): string;
  63162. /**
  63163. * Gets the first world row input component
  63164. */
  63165. get world0(): NodeMaterialConnectionPoint;
  63166. /**
  63167. * Gets the second world row input component
  63168. */
  63169. get world1(): NodeMaterialConnectionPoint;
  63170. /**
  63171. * Gets the third world row input component
  63172. */
  63173. get world2(): NodeMaterialConnectionPoint;
  63174. /**
  63175. * Gets the forth world row input component
  63176. */
  63177. get world3(): NodeMaterialConnectionPoint;
  63178. /**
  63179. * Gets the world input component
  63180. */
  63181. get world(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the output component
  63184. */
  63185. get output(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the isntanceID component
  63188. */
  63189. get instanceID(): NodeMaterialConnectionPoint;
  63190. autoConfigure(material: NodeMaterial): void;
  63191. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63192. protected _buildBlock(state: NodeMaterialBuildState): this;
  63193. }
  63194. }
  63195. declare module BABYLON {
  63196. /**
  63197. * Block used to add morph targets support to vertex shader
  63198. */
  63199. export class MorphTargetsBlock extends NodeMaterialBlock {
  63200. private _repeatableContentAnchor;
  63201. /**
  63202. * Create a new MorphTargetsBlock
  63203. * @param name defines the block name
  63204. */
  63205. constructor(name: string);
  63206. /**
  63207. * Gets the current class name
  63208. * @returns the class name
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Gets the position input component
  63213. */
  63214. get position(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the normal input component
  63217. */
  63218. get normal(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the tangent input component
  63221. */
  63222. get tangent(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the tangent input component
  63225. */
  63226. get uv(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the position output component
  63229. */
  63230. get positionOutput(): NodeMaterialConnectionPoint;
  63231. /**
  63232. * Gets the normal output component
  63233. */
  63234. get normalOutput(): NodeMaterialConnectionPoint;
  63235. /**
  63236. * Gets the tangent output component
  63237. */
  63238. get tangentOutput(): NodeMaterialConnectionPoint;
  63239. /**
  63240. * Gets the tangent output component
  63241. */
  63242. get uvOutput(): NodeMaterialConnectionPoint;
  63243. initialize(state: NodeMaterialBuildState): void;
  63244. autoConfigure(material: NodeMaterial): void;
  63245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63247. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63248. protected _buildBlock(state: NodeMaterialBuildState): this;
  63249. }
  63250. }
  63251. declare module BABYLON {
  63252. /**
  63253. * Block used to get data information from a light
  63254. */
  63255. export class LightInformationBlock extends NodeMaterialBlock {
  63256. private _lightDataUniformName;
  63257. private _lightColorUniformName;
  63258. private _lightTypeDefineName;
  63259. /**
  63260. * Gets or sets the light associated with this block
  63261. */
  63262. light: Nullable<Light>;
  63263. /**
  63264. * Creates a new LightInformationBlock
  63265. * @param name defines the block name
  63266. */
  63267. constructor(name: string);
  63268. /**
  63269. * Gets the current class name
  63270. * @returns the class name
  63271. */
  63272. getClassName(): string;
  63273. /**
  63274. * Gets the world position input component
  63275. */
  63276. get worldPosition(): NodeMaterialConnectionPoint;
  63277. /**
  63278. * Gets the direction output component
  63279. */
  63280. get direction(): NodeMaterialConnectionPoint;
  63281. /**
  63282. * Gets the direction output component
  63283. */
  63284. get color(): NodeMaterialConnectionPoint;
  63285. /**
  63286. * Gets the direction output component
  63287. */
  63288. get intensity(): NodeMaterialConnectionPoint;
  63289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63291. protected _buildBlock(state: NodeMaterialBuildState): this;
  63292. serialize(): any;
  63293. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63294. }
  63295. }
  63296. declare module BABYLON {
  63297. /**
  63298. * Block used to add image processing support to fragment shader
  63299. */
  63300. export class ImageProcessingBlock extends NodeMaterialBlock {
  63301. /**
  63302. * Create a new ImageProcessingBlock
  63303. * @param name defines the block name
  63304. */
  63305. constructor(name: string);
  63306. /**
  63307. * Gets the current class name
  63308. * @returns the class name
  63309. */
  63310. getClassName(): string;
  63311. /**
  63312. * Gets the color input component
  63313. */
  63314. get color(): NodeMaterialConnectionPoint;
  63315. /**
  63316. * Gets the output component
  63317. */
  63318. get output(): NodeMaterialConnectionPoint;
  63319. /**
  63320. * Initialize the block and prepare the context for build
  63321. * @param state defines the state that will be used for the build
  63322. */
  63323. initialize(state: NodeMaterialBuildState): void;
  63324. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63327. protected _buildBlock(state: NodeMaterialBuildState): this;
  63328. }
  63329. }
  63330. declare module BABYLON {
  63331. /**
  63332. * Block used to pertub normals based on a normal map
  63333. */
  63334. export class PerturbNormalBlock extends NodeMaterialBlock {
  63335. private _tangentSpaceParameterName;
  63336. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63337. invertX: boolean;
  63338. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63339. invertY: boolean;
  63340. /**
  63341. * Create a new PerturbNormalBlock
  63342. * @param name defines the block name
  63343. */
  63344. constructor(name: string);
  63345. /**
  63346. * Gets the current class name
  63347. * @returns the class name
  63348. */
  63349. getClassName(): string;
  63350. /**
  63351. * Gets the world position input component
  63352. */
  63353. get worldPosition(): NodeMaterialConnectionPoint;
  63354. /**
  63355. * Gets the world normal input component
  63356. */
  63357. get worldNormal(): NodeMaterialConnectionPoint;
  63358. /**
  63359. * Gets the world tangent input component
  63360. */
  63361. get worldTangent(): NodeMaterialConnectionPoint;
  63362. /**
  63363. * Gets the uv input component
  63364. */
  63365. get uv(): NodeMaterialConnectionPoint;
  63366. /**
  63367. * Gets the normal map color input component
  63368. */
  63369. get normalMapColor(): NodeMaterialConnectionPoint;
  63370. /**
  63371. * Gets the strength input component
  63372. */
  63373. get strength(): NodeMaterialConnectionPoint;
  63374. /**
  63375. * Gets the output component
  63376. */
  63377. get output(): NodeMaterialConnectionPoint;
  63378. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63379. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63380. autoConfigure(material: NodeMaterial): void;
  63381. protected _buildBlock(state: NodeMaterialBuildState): this;
  63382. protected _dumpPropertiesCode(): string;
  63383. serialize(): any;
  63384. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63385. }
  63386. }
  63387. declare module BABYLON {
  63388. /**
  63389. * Block used to discard a pixel if a value is smaller than a cutoff
  63390. */
  63391. export class DiscardBlock extends NodeMaterialBlock {
  63392. /**
  63393. * Create a new DiscardBlock
  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 color input component
  63404. */
  63405. get value(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the cutoff input component
  63408. */
  63409. get cutoff(): NodeMaterialConnectionPoint;
  63410. protected _buildBlock(state: NodeMaterialBuildState): this;
  63411. }
  63412. }
  63413. declare module BABYLON {
  63414. /**
  63415. * Block used to test if the fragment shader is front facing
  63416. */
  63417. export class FrontFacingBlock extends NodeMaterialBlock {
  63418. /**
  63419. * Creates a new FrontFacingBlock
  63420. * @param name defines the block name
  63421. */
  63422. constructor(name: string);
  63423. /**
  63424. * Gets the current class name
  63425. * @returns the class name
  63426. */
  63427. getClassName(): string;
  63428. /**
  63429. * Gets the output component
  63430. */
  63431. get output(): NodeMaterialConnectionPoint;
  63432. protected _buildBlock(state: NodeMaterialBuildState): this;
  63433. }
  63434. }
  63435. declare module BABYLON {
  63436. /**
  63437. * Block used to get the derivative value on x and y of a given input
  63438. */
  63439. export class DerivativeBlock extends NodeMaterialBlock {
  63440. /**
  63441. * Create a new DerivativeBlock
  63442. * @param name defines the block name
  63443. */
  63444. constructor(name: string);
  63445. /**
  63446. * Gets the current class name
  63447. * @returns the class name
  63448. */
  63449. getClassName(): string;
  63450. /**
  63451. * Gets the input component
  63452. */
  63453. get input(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the derivative output on x
  63456. */
  63457. get dx(): NodeMaterialConnectionPoint;
  63458. /**
  63459. * Gets the derivative output on y
  63460. */
  63461. get dy(): NodeMaterialConnectionPoint;
  63462. protected _buildBlock(state: NodeMaterialBuildState): this;
  63463. }
  63464. }
  63465. declare module BABYLON {
  63466. /**
  63467. * Block used to make gl_FragCoord available
  63468. */
  63469. export class FragCoordBlock extends NodeMaterialBlock {
  63470. /**
  63471. * Creates a new FragCoordBlock
  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 xy component
  63482. */
  63483. get xy(): NodeMaterialConnectionPoint;
  63484. /**
  63485. * Gets the xyz component
  63486. */
  63487. get xyz(): NodeMaterialConnectionPoint;
  63488. /**
  63489. * Gets the xyzw component
  63490. */
  63491. get xyzw(): NodeMaterialConnectionPoint;
  63492. /**
  63493. * Gets the x component
  63494. */
  63495. get x(): NodeMaterialConnectionPoint;
  63496. /**
  63497. * Gets the y component
  63498. */
  63499. get y(): NodeMaterialConnectionPoint;
  63500. /**
  63501. * Gets the z component
  63502. */
  63503. get z(): NodeMaterialConnectionPoint;
  63504. /**
  63505. * Gets the w component
  63506. */
  63507. get output(): NodeMaterialConnectionPoint;
  63508. protected writeOutputs(state: NodeMaterialBuildState): string;
  63509. protected _buildBlock(state: NodeMaterialBuildState): this;
  63510. }
  63511. }
  63512. declare module BABYLON {
  63513. /**
  63514. * Block used to get the screen sizes
  63515. */
  63516. export class ScreenSizeBlock extends NodeMaterialBlock {
  63517. private _varName;
  63518. private _scene;
  63519. /**
  63520. * Creates a new ScreenSizeBlock
  63521. * @param name defines the block name
  63522. */
  63523. constructor(name: string);
  63524. /**
  63525. * Gets the current class name
  63526. * @returns the class name
  63527. */
  63528. getClassName(): string;
  63529. /**
  63530. * Gets the xy component
  63531. */
  63532. get xy(): NodeMaterialConnectionPoint;
  63533. /**
  63534. * Gets the x component
  63535. */
  63536. get x(): NodeMaterialConnectionPoint;
  63537. /**
  63538. * Gets the y component
  63539. */
  63540. get y(): NodeMaterialConnectionPoint;
  63541. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63542. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63543. protected _buildBlock(state: NodeMaterialBuildState): this;
  63544. }
  63545. }
  63546. declare module BABYLON {
  63547. /**
  63548. * Block used to add support for scene fog
  63549. */
  63550. export class FogBlock extends NodeMaterialBlock {
  63551. private _fogDistanceName;
  63552. private _fogParameters;
  63553. /**
  63554. * Create a new FogBlock
  63555. * @param name defines the block name
  63556. */
  63557. constructor(name: string);
  63558. /**
  63559. * Gets the current class name
  63560. * @returns the class name
  63561. */
  63562. getClassName(): string;
  63563. /**
  63564. * Gets the world position input component
  63565. */
  63566. get worldPosition(): NodeMaterialConnectionPoint;
  63567. /**
  63568. * Gets the view input component
  63569. */
  63570. get view(): NodeMaterialConnectionPoint;
  63571. /**
  63572. * Gets the color input component
  63573. */
  63574. get input(): NodeMaterialConnectionPoint;
  63575. /**
  63576. * Gets the fog color input component
  63577. */
  63578. get fogColor(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the output component
  63581. */
  63582. get output(): NodeMaterialConnectionPoint;
  63583. autoConfigure(material: NodeMaterial): void;
  63584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63585. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63586. protected _buildBlock(state: NodeMaterialBuildState): this;
  63587. }
  63588. }
  63589. declare module BABYLON {
  63590. /**
  63591. * Block used to add light in the fragment shader
  63592. */
  63593. export class LightBlock extends NodeMaterialBlock {
  63594. private _lightId;
  63595. /**
  63596. * Gets or sets the light associated with this block
  63597. */
  63598. light: Nullable<Light>;
  63599. /**
  63600. * Create a new LightBlock
  63601. * @param name defines the block name
  63602. */
  63603. constructor(name: string);
  63604. /**
  63605. * Gets the current class name
  63606. * @returns the class name
  63607. */
  63608. getClassName(): string;
  63609. /**
  63610. * Gets the world position input component
  63611. */
  63612. get worldPosition(): NodeMaterialConnectionPoint;
  63613. /**
  63614. * Gets the world normal input component
  63615. */
  63616. get worldNormal(): NodeMaterialConnectionPoint;
  63617. /**
  63618. * Gets the camera (or eye) position component
  63619. */
  63620. get cameraPosition(): NodeMaterialConnectionPoint;
  63621. /**
  63622. * Gets the glossiness component
  63623. */
  63624. get glossiness(): NodeMaterialConnectionPoint;
  63625. /**
  63626. * Gets the glossinness power component
  63627. */
  63628. get glossPower(): NodeMaterialConnectionPoint;
  63629. /**
  63630. * Gets the diffuse color component
  63631. */
  63632. get diffuseColor(): NodeMaterialConnectionPoint;
  63633. /**
  63634. * Gets the specular color component
  63635. */
  63636. get specularColor(): NodeMaterialConnectionPoint;
  63637. /**
  63638. * Gets the diffuse output component
  63639. */
  63640. get diffuseOutput(): NodeMaterialConnectionPoint;
  63641. /**
  63642. * Gets the specular output component
  63643. */
  63644. get specularOutput(): NodeMaterialConnectionPoint;
  63645. /**
  63646. * Gets the shadow output component
  63647. */
  63648. get shadow(): NodeMaterialConnectionPoint;
  63649. autoConfigure(material: NodeMaterial): void;
  63650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63651. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63653. private _injectVertexCode;
  63654. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63655. serialize(): any;
  63656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63657. }
  63658. }
  63659. declare module BABYLON {
  63660. /**
  63661. * Block used to read a reflection texture from a sampler
  63662. */
  63663. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63664. /**
  63665. * Create a new ReflectionTextureBlock
  63666. * @param name defines the block name
  63667. */
  63668. constructor(name: string);
  63669. /**
  63670. * Gets the current class name
  63671. * @returns the class name
  63672. */
  63673. getClassName(): string;
  63674. /**
  63675. * Gets the world position input component
  63676. */
  63677. get position(): NodeMaterialConnectionPoint;
  63678. /**
  63679. * Gets the world position input component
  63680. */
  63681. get worldPosition(): NodeMaterialConnectionPoint;
  63682. /**
  63683. * Gets the world normal input component
  63684. */
  63685. get worldNormal(): NodeMaterialConnectionPoint;
  63686. /**
  63687. * Gets the world input component
  63688. */
  63689. get world(): NodeMaterialConnectionPoint;
  63690. /**
  63691. * Gets the camera (or eye) position component
  63692. */
  63693. get cameraPosition(): NodeMaterialConnectionPoint;
  63694. /**
  63695. * Gets the view input component
  63696. */
  63697. get view(): NodeMaterialConnectionPoint;
  63698. /**
  63699. * Gets the rgb output component
  63700. */
  63701. get rgb(): NodeMaterialConnectionPoint;
  63702. /**
  63703. * Gets the rgba output component
  63704. */
  63705. get rgba(): NodeMaterialConnectionPoint;
  63706. /**
  63707. * Gets the r output component
  63708. */
  63709. get r(): NodeMaterialConnectionPoint;
  63710. /**
  63711. * Gets the g output component
  63712. */
  63713. get g(): NodeMaterialConnectionPoint;
  63714. /**
  63715. * Gets the b output component
  63716. */
  63717. get b(): NodeMaterialConnectionPoint;
  63718. /**
  63719. * Gets the a output component
  63720. */
  63721. get a(): NodeMaterialConnectionPoint;
  63722. autoConfigure(material: NodeMaterial): void;
  63723. protected _buildBlock(state: NodeMaterialBuildState): this;
  63724. }
  63725. }
  63726. declare module BABYLON {
  63727. /**
  63728. * Block used to add 2 vectors
  63729. */
  63730. export class AddBlock extends NodeMaterialBlock {
  63731. /**
  63732. * Creates a new AddBlock
  63733. * @param name defines the block name
  63734. */
  63735. constructor(name: string);
  63736. /**
  63737. * Gets the current class name
  63738. * @returns the class name
  63739. */
  63740. getClassName(): string;
  63741. /**
  63742. * Gets the left operand input component
  63743. */
  63744. get left(): NodeMaterialConnectionPoint;
  63745. /**
  63746. * Gets the right operand input component
  63747. */
  63748. get right(): NodeMaterialConnectionPoint;
  63749. /**
  63750. * Gets the output component
  63751. */
  63752. get output(): NodeMaterialConnectionPoint;
  63753. protected _buildBlock(state: NodeMaterialBuildState): this;
  63754. }
  63755. }
  63756. declare module BABYLON {
  63757. /**
  63758. * Block used to scale a vector by a float
  63759. */
  63760. export class ScaleBlock extends NodeMaterialBlock {
  63761. /**
  63762. * Creates a new ScaleBlock
  63763. * @param name defines the block name
  63764. */
  63765. constructor(name: string);
  63766. /**
  63767. * Gets the current class name
  63768. * @returns the class name
  63769. */
  63770. getClassName(): string;
  63771. /**
  63772. * Gets the input component
  63773. */
  63774. get input(): NodeMaterialConnectionPoint;
  63775. /**
  63776. * Gets the factor input component
  63777. */
  63778. get factor(): NodeMaterialConnectionPoint;
  63779. /**
  63780. * Gets the output component
  63781. */
  63782. get output(): NodeMaterialConnectionPoint;
  63783. protected _buildBlock(state: NodeMaterialBuildState): this;
  63784. }
  63785. }
  63786. declare module BABYLON {
  63787. /**
  63788. * Block used to clamp a float
  63789. */
  63790. export class ClampBlock extends NodeMaterialBlock {
  63791. /** Gets or sets the minimum range */
  63792. minimum: number;
  63793. /** Gets or sets the maximum range */
  63794. maximum: number;
  63795. /**
  63796. * Creates a new ClampBlock
  63797. * @param name defines the block name
  63798. */
  63799. constructor(name: string);
  63800. /**
  63801. * Gets the current class name
  63802. * @returns the class name
  63803. */
  63804. getClassName(): string;
  63805. /**
  63806. * Gets the value input component
  63807. */
  63808. get value(): NodeMaterialConnectionPoint;
  63809. /**
  63810. * Gets the output component
  63811. */
  63812. get output(): NodeMaterialConnectionPoint;
  63813. protected _buildBlock(state: NodeMaterialBuildState): this;
  63814. protected _dumpPropertiesCode(): string;
  63815. serialize(): any;
  63816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63817. }
  63818. }
  63819. declare module BABYLON {
  63820. /**
  63821. * Block used to apply a cross product between 2 vectors
  63822. */
  63823. export class CrossBlock extends NodeMaterialBlock {
  63824. /**
  63825. * Creates a new CrossBlock
  63826. * @param name defines the block name
  63827. */
  63828. constructor(name: string);
  63829. /**
  63830. * Gets the current class name
  63831. * @returns the class name
  63832. */
  63833. getClassName(): string;
  63834. /**
  63835. * Gets the left operand input component
  63836. */
  63837. get left(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the right operand input component
  63840. */
  63841. get right(): NodeMaterialConnectionPoint;
  63842. /**
  63843. * Gets the output component
  63844. */
  63845. get output(): NodeMaterialConnectionPoint;
  63846. protected _buildBlock(state: NodeMaterialBuildState): this;
  63847. }
  63848. }
  63849. declare module BABYLON {
  63850. /**
  63851. * Block used to apply a dot product between 2 vectors
  63852. */
  63853. export class DotBlock extends NodeMaterialBlock {
  63854. /**
  63855. * Creates a new DotBlock
  63856. * @param name defines the block name
  63857. */
  63858. constructor(name: string);
  63859. /**
  63860. * Gets the current class name
  63861. * @returns the class name
  63862. */
  63863. getClassName(): string;
  63864. /**
  63865. * Gets the left operand input component
  63866. */
  63867. get left(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the right operand input component
  63870. */
  63871. get right(): NodeMaterialConnectionPoint;
  63872. /**
  63873. * Gets the output component
  63874. */
  63875. get output(): NodeMaterialConnectionPoint;
  63876. protected _buildBlock(state: NodeMaterialBuildState): this;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Block used to normalize a vector
  63882. */
  63883. export class NormalizeBlock extends NodeMaterialBlock {
  63884. /**
  63885. * Creates a new NormalizeBlock
  63886. * @param name defines the block name
  63887. */
  63888. constructor(name: string);
  63889. /**
  63890. * Gets the current class name
  63891. * @returns the class name
  63892. */
  63893. getClassName(): string;
  63894. /**
  63895. * Gets the input component
  63896. */
  63897. get input(): 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 create a Color3/4 out of individual inputs (one for each component)
  63908. */
  63909. export class ColorMergerBlock extends NodeMaterialBlock {
  63910. /**
  63911. * Create a new ColorMergerBlock
  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 rgb component (input)
  63922. */
  63923. get rgbIn(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the r component (input)
  63926. */
  63927. get r(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the g component (input)
  63930. */
  63931. get g(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Gets the b component (input)
  63934. */
  63935. get b(): NodeMaterialConnectionPoint;
  63936. /**
  63937. * Gets the a component (input)
  63938. */
  63939. get a(): NodeMaterialConnectionPoint;
  63940. /**
  63941. * Gets the rgba component (output)
  63942. */
  63943. get rgba(): NodeMaterialConnectionPoint;
  63944. /**
  63945. * Gets the rgb component (output)
  63946. */
  63947. get rgbOut(): NodeMaterialConnectionPoint;
  63948. /**
  63949. * Gets the rgb component (output)
  63950. * @deprecated Please use rgbOut instead.
  63951. */
  63952. get rgb(): NodeMaterialConnectionPoint;
  63953. protected _buildBlock(state: NodeMaterialBuildState): this;
  63954. }
  63955. }
  63956. declare module BABYLON {
  63957. /**
  63958. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63959. */
  63960. export class VectorSplitterBlock extends NodeMaterialBlock {
  63961. /**
  63962. * Create a new VectorSplitterBlock
  63963. * @param name defines the block name
  63964. */
  63965. constructor(name: string);
  63966. /**
  63967. * Gets the current class name
  63968. * @returns the class name
  63969. */
  63970. getClassName(): string;
  63971. /**
  63972. * Gets the xyzw component (input)
  63973. */
  63974. get xyzw(): NodeMaterialConnectionPoint;
  63975. /**
  63976. * Gets the xyz component (input)
  63977. */
  63978. get xyzIn(): NodeMaterialConnectionPoint;
  63979. /**
  63980. * Gets the xy component (input)
  63981. */
  63982. get xyIn(): NodeMaterialConnectionPoint;
  63983. /**
  63984. * Gets the xyz component (output)
  63985. */
  63986. get xyzOut(): NodeMaterialConnectionPoint;
  63987. /**
  63988. * Gets the xy component (output)
  63989. */
  63990. get xyOut(): NodeMaterialConnectionPoint;
  63991. /**
  63992. * Gets the x component (output)
  63993. */
  63994. get x(): NodeMaterialConnectionPoint;
  63995. /**
  63996. * Gets the y component (output)
  63997. */
  63998. get y(): NodeMaterialConnectionPoint;
  63999. /**
  64000. * Gets the z component (output)
  64001. */
  64002. get z(): NodeMaterialConnectionPoint;
  64003. /**
  64004. * Gets the w component (output)
  64005. */
  64006. get w(): NodeMaterialConnectionPoint;
  64007. protected _inputRename(name: string): string;
  64008. protected _outputRename(name: string): string;
  64009. protected _buildBlock(state: NodeMaterialBuildState): this;
  64010. }
  64011. }
  64012. declare module BABYLON {
  64013. /**
  64014. * Block used to lerp between 2 values
  64015. */
  64016. export class LerpBlock extends NodeMaterialBlock {
  64017. /**
  64018. * Creates a new LerpBlock
  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 left operand input component
  64029. */
  64030. get left(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the right operand input component
  64033. */
  64034. get right(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the gradient operand input component
  64037. */
  64038. get gradient(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the output component
  64041. */
  64042. get output(): NodeMaterialConnectionPoint;
  64043. protected _buildBlock(state: NodeMaterialBuildState): this;
  64044. }
  64045. }
  64046. declare module BABYLON {
  64047. /**
  64048. * Block used to divide 2 vectors
  64049. */
  64050. export class DivideBlock extends NodeMaterialBlock {
  64051. /**
  64052. * Creates a new DivideBlock
  64053. * @param name defines the block name
  64054. */
  64055. constructor(name: string);
  64056. /**
  64057. * Gets the current class name
  64058. * @returns the class name
  64059. */
  64060. getClassName(): string;
  64061. /**
  64062. * Gets the left operand input component
  64063. */
  64064. get left(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the right operand input component
  64067. */
  64068. get right(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the output component
  64071. */
  64072. get output(): NodeMaterialConnectionPoint;
  64073. protected _buildBlock(state: NodeMaterialBuildState): this;
  64074. }
  64075. }
  64076. declare module BABYLON {
  64077. /**
  64078. * Block used to subtract 2 vectors
  64079. */
  64080. export class SubtractBlock extends NodeMaterialBlock {
  64081. /**
  64082. * Creates a new SubtractBlock
  64083. * @param name defines the block name
  64084. */
  64085. constructor(name: string);
  64086. /**
  64087. * Gets the current class name
  64088. * @returns the class name
  64089. */
  64090. getClassName(): string;
  64091. /**
  64092. * Gets the left operand input component
  64093. */
  64094. get left(): NodeMaterialConnectionPoint;
  64095. /**
  64096. * Gets the right operand input component
  64097. */
  64098. get right(): NodeMaterialConnectionPoint;
  64099. /**
  64100. * Gets the output component
  64101. */
  64102. get output(): NodeMaterialConnectionPoint;
  64103. protected _buildBlock(state: NodeMaterialBuildState): this;
  64104. }
  64105. }
  64106. declare module BABYLON {
  64107. /**
  64108. * Block used to step a value
  64109. */
  64110. export class StepBlock extends NodeMaterialBlock {
  64111. /**
  64112. * Creates a new StepBlock
  64113. * @param name defines the block name
  64114. */
  64115. constructor(name: string);
  64116. /**
  64117. * Gets the current class name
  64118. * @returns the class name
  64119. */
  64120. getClassName(): string;
  64121. /**
  64122. * Gets the value operand input component
  64123. */
  64124. get value(): NodeMaterialConnectionPoint;
  64125. /**
  64126. * Gets the edge operand input component
  64127. */
  64128. get edge(): NodeMaterialConnectionPoint;
  64129. /**
  64130. * Gets the output component
  64131. */
  64132. get output(): NodeMaterialConnectionPoint;
  64133. protected _buildBlock(state: NodeMaterialBuildState): this;
  64134. }
  64135. }
  64136. declare module BABYLON {
  64137. /**
  64138. * Block used to get the opposite (1 - x) of a value
  64139. */
  64140. export class OneMinusBlock extends NodeMaterialBlock {
  64141. /**
  64142. * Creates a new OneMinusBlock
  64143. * @param name defines the block name
  64144. */
  64145. constructor(name: string);
  64146. /**
  64147. * Gets the current class name
  64148. * @returns the class name
  64149. */
  64150. getClassName(): string;
  64151. /**
  64152. * Gets the input component
  64153. */
  64154. get input(): 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 get the view direction
  64165. */
  64166. export class ViewDirectionBlock extends NodeMaterialBlock {
  64167. /**
  64168. * Creates a new ViewDirectionBlock
  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 world position component
  64179. */
  64180. get worldPosition(): NodeMaterialConnectionPoint;
  64181. /**
  64182. * Gets the camera position component
  64183. */
  64184. get cameraPosition(): NodeMaterialConnectionPoint;
  64185. /**
  64186. * Gets the output component
  64187. */
  64188. get output(): NodeMaterialConnectionPoint;
  64189. autoConfigure(material: NodeMaterial): void;
  64190. protected _buildBlock(state: NodeMaterialBuildState): this;
  64191. }
  64192. }
  64193. declare module BABYLON {
  64194. /**
  64195. * Block used to compute fresnel value
  64196. */
  64197. export class FresnelBlock extends NodeMaterialBlock {
  64198. /**
  64199. * Create a new FresnelBlock
  64200. * @param name defines the block name
  64201. */
  64202. constructor(name: string);
  64203. /**
  64204. * Gets the current class name
  64205. * @returns the class name
  64206. */
  64207. getClassName(): string;
  64208. /**
  64209. * Gets the world normal input component
  64210. */
  64211. get worldNormal(): NodeMaterialConnectionPoint;
  64212. /**
  64213. * Gets the view direction input component
  64214. */
  64215. get viewDirection(): NodeMaterialConnectionPoint;
  64216. /**
  64217. * Gets the bias input component
  64218. */
  64219. get bias(): NodeMaterialConnectionPoint;
  64220. /**
  64221. * Gets the camera (or eye) position component
  64222. */
  64223. get power(): NodeMaterialConnectionPoint;
  64224. /**
  64225. * Gets the fresnel output component
  64226. */
  64227. get fresnel(): NodeMaterialConnectionPoint;
  64228. autoConfigure(material: NodeMaterial): void;
  64229. protected _buildBlock(state: NodeMaterialBuildState): this;
  64230. }
  64231. }
  64232. declare module BABYLON {
  64233. /**
  64234. * Block used to get the max of 2 values
  64235. */
  64236. export class MaxBlock extends NodeMaterialBlock {
  64237. /**
  64238. * Creates a new MaxBlock
  64239. * @param name defines the block name
  64240. */
  64241. constructor(name: string);
  64242. /**
  64243. * Gets the current class name
  64244. * @returns the class name
  64245. */
  64246. getClassName(): string;
  64247. /**
  64248. * Gets the left operand input component
  64249. */
  64250. get left(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the right operand input component
  64253. */
  64254. get right(): NodeMaterialConnectionPoint;
  64255. /**
  64256. * Gets the output component
  64257. */
  64258. get output(): NodeMaterialConnectionPoint;
  64259. protected _buildBlock(state: NodeMaterialBuildState): this;
  64260. }
  64261. }
  64262. declare module BABYLON {
  64263. /**
  64264. * Block used to get the min of 2 values
  64265. */
  64266. export class MinBlock extends NodeMaterialBlock {
  64267. /**
  64268. * Creates a new MinBlock
  64269. * @param name defines the block name
  64270. */
  64271. constructor(name: string);
  64272. /**
  64273. * Gets the current class name
  64274. * @returns the class name
  64275. */
  64276. getClassName(): string;
  64277. /**
  64278. * Gets the left operand input component
  64279. */
  64280. get left(): NodeMaterialConnectionPoint;
  64281. /**
  64282. * Gets the right operand input component
  64283. */
  64284. get right(): NodeMaterialConnectionPoint;
  64285. /**
  64286. * Gets the output component
  64287. */
  64288. get output(): NodeMaterialConnectionPoint;
  64289. protected _buildBlock(state: NodeMaterialBuildState): this;
  64290. }
  64291. }
  64292. declare module BABYLON {
  64293. /**
  64294. * Block used to get the distance between 2 values
  64295. */
  64296. export class DistanceBlock extends NodeMaterialBlock {
  64297. /**
  64298. * Creates a new DistanceBlock
  64299. * @param name defines the block name
  64300. */
  64301. constructor(name: string);
  64302. /**
  64303. * Gets the current class name
  64304. * @returns the class name
  64305. */
  64306. getClassName(): string;
  64307. /**
  64308. * Gets the left operand input component
  64309. */
  64310. get left(): NodeMaterialConnectionPoint;
  64311. /**
  64312. * Gets the right operand input component
  64313. */
  64314. get right(): NodeMaterialConnectionPoint;
  64315. /**
  64316. * Gets the output component
  64317. */
  64318. get output(): NodeMaterialConnectionPoint;
  64319. protected _buildBlock(state: NodeMaterialBuildState): this;
  64320. }
  64321. }
  64322. declare module BABYLON {
  64323. /**
  64324. * Block used to get the length of a vector
  64325. */
  64326. export class LengthBlock extends NodeMaterialBlock {
  64327. /**
  64328. * Creates a new LengthBlock
  64329. * @param name defines the block name
  64330. */
  64331. constructor(name: string);
  64332. /**
  64333. * Gets the current class name
  64334. * @returns the class name
  64335. */
  64336. getClassName(): string;
  64337. /**
  64338. * Gets the value input component
  64339. */
  64340. get value(): 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 negative version of a value (i.e. x * -1)
  64351. */
  64352. export class NegateBlock extends NodeMaterialBlock {
  64353. /**
  64354. * Creates a new NegateBlock
  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 value input component
  64365. */
  64366. get value(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the output component
  64369. */
  64370. get output(): NodeMaterialConnectionPoint;
  64371. protected _buildBlock(state: NodeMaterialBuildState): this;
  64372. }
  64373. }
  64374. declare module BABYLON {
  64375. /**
  64376. * Block used to get the value of the first parameter raised to the power of the second
  64377. */
  64378. export class PowBlock extends NodeMaterialBlock {
  64379. /**
  64380. * Creates a new PowBlock
  64381. * @param name defines the block name
  64382. */
  64383. constructor(name: string);
  64384. /**
  64385. * Gets the current class name
  64386. * @returns the class name
  64387. */
  64388. getClassName(): string;
  64389. /**
  64390. * Gets the value operand input component
  64391. */
  64392. get value(): NodeMaterialConnectionPoint;
  64393. /**
  64394. * Gets the power operand input component
  64395. */
  64396. get power(): 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 a random number
  64407. */
  64408. export class RandomNumberBlock extends NodeMaterialBlock {
  64409. /**
  64410. * Creates a new RandomNumberBlock
  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 seed input component
  64421. */
  64422. get seed(): 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 compute arc tangent of 2 values
  64433. */
  64434. export class ArcTan2Block extends NodeMaterialBlock {
  64435. /**
  64436. * Creates a new ArcTan2Block
  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 x operand input component
  64447. */
  64448. get x(): NodeMaterialConnectionPoint;
  64449. /**
  64450. * Gets the y operand input component
  64451. */
  64452. get y(): 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 smooth step a value
  64463. */
  64464. export class SmoothStepBlock extends NodeMaterialBlock {
  64465. /**
  64466. * Creates a new SmoothStepBlock
  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 value operand input component
  64477. */
  64478. get value(): NodeMaterialConnectionPoint;
  64479. /**
  64480. * Gets the first edge operand input component
  64481. */
  64482. get edge0(): NodeMaterialConnectionPoint;
  64483. /**
  64484. * Gets the second edge operand input component
  64485. */
  64486. get edge1(): NodeMaterialConnectionPoint;
  64487. /**
  64488. * Gets the output component
  64489. */
  64490. get output(): NodeMaterialConnectionPoint;
  64491. protected _buildBlock(state: NodeMaterialBuildState): this;
  64492. }
  64493. }
  64494. declare module BABYLON {
  64495. /**
  64496. * Block used to get the reciprocal (1 / x) of a value
  64497. */
  64498. export class ReciprocalBlock extends NodeMaterialBlock {
  64499. /**
  64500. * Creates a new ReciprocalBlock
  64501. * @param name defines the block name
  64502. */
  64503. constructor(name: string);
  64504. /**
  64505. * Gets the current class name
  64506. * @returns the class name
  64507. */
  64508. getClassName(): string;
  64509. /**
  64510. * Gets the input component
  64511. */
  64512. get input(): NodeMaterialConnectionPoint;
  64513. /**
  64514. * Gets the output component
  64515. */
  64516. get output(): NodeMaterialConnectionPoint;
  64517. protected _buildBlock(state: NodeMaterialBuildState): this;
  64518. }
  64519. }
  64520. declare module BABYLON {
  64521. /**
  64522. * Block used to replace a color by another one
  64523. */
  64524. export class ReplaceColorBlock extends NodeMaterialBlock {
  64525. /**
  64526. * Creates a new ReplaceColorBlock
  64527. * @param name defines the block name
  64528. */
  64529. constructor(name: string);
  64530. /**
  64531. * Gets the current class name
  64532. * @returns the class name
  64533. */
  64534. getClassName(): string;
  64535. /**
  64536. * Gets the value input component
  64537. */
  64538. get value(): NodeMaterialConnectionPoint;
  64539. /**
  64540. * Gets the reference input component
  64541. */
  64542. get reference(): NodeMaterialConnectionPoint;
  64543. /**
  64544. * Gets the distance input component
  64545. */
  64546. get distance(): NodeMaterialConnectionPoint;
  64547. /**
  64548. * Gets the replacement input component
  64549. */
  64550. get replacement(): NodeMaterialConnectionPoint;
  64551. /**
  64552. * Gets the output component
  64553. */
  64554. get output(): NodeMaterialConnectionPoint;
  64555. protected _buildBlock(state: NodeMaterialBuildState): this;
  64556. }
  64557. }
  64558. declare module BABYLON {
  64559. /**
  64560. * Block used to posterize a value
  64561. * @see https://en.wikipedia.org/wiki/Posterization
  64562. */
  64563. export class PosterizeBlock extends NodeMaterialBlock {
  64564. /**
  64565. * Creates a new PosterizeBlock
  64566. * @param name defines the block name
  64567. */
  64568. constructor(name: string);
  64569. /**
  64570. * Gets the current class name
  64571. * @returns the class name
  64572. */
  64573. getClassName(): string;
  64574. /**
  64575. * Gets the value input component
  64576. */
  64577. get value(): NodeMaterialConnectionPoint;
  64578. /**
  64579. * Gets the steps input component
  64580. */
  64581. get steps(): NodeMaterialConnectionPoint;
  64582. /**
  64583. * Gets the output component
  64584. */
  64585. get output(): NodeMaterialConnectionPoint;
  64586. protected _buildBlock(state: NodeMaterialBuildState): this;
  64587. }
  64588. }
  64589. declare module BABYLON {
  64590. /**
  64591. * Operations supported by the Wave block
  64592. */
  64593. export enum WaveBlockKind {
  64594. /** SawTooth */
  64595. SawTooth = 0,
  64596. /** Square */
  64597. Square = 1,
  64598. /** Triangle */
  64599. Triangle = 2
  64600. }
  64601. /**
  64602. * Block used to apply wave operation to floats
  64603. */
  64604. export class WaveBlock extends NodeMaterialBlock {
  64605. /**
  64606. * Gets or sets the kibnd of wave to be applied by the block
  64607. */
  64608. kind: WaveBlockKind;
  64609. /**
  64610. * Creates a new WaveBlock
  64611. * @param name defines the block name
  64612. */
  64613. constructor(name: string);
  64614. /**
  64615. * Gets the current class name
  64616. * @returns the class name
  64617. */
  64618. getClassName(): string;
  64619. /**
  64620. * Gets the input component
  64621. */
  64622. get input(): NodeMaterialConnectionPoint;
  64623. /**
  64624. * Gets the output component
  64625. */
  64626. get output(): NodeMaterialConnectionPoint;
  64627. protected _buildBlock(state: NodeMaterialBuildState): this;
  64628. serialize(): any;
  64629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64630. }
  64631. }
  64632. declare module BABYLON {
  64633. /**
  64634. * Class used to store a color step for the GradientBlock
  64635. */
  64636. export class GradientBlockColorStep {
  64637. private _step;
  64638. /**
  64639. * Gets value indicating which step this color is associated with (between 0 and 1)
  64640. */
  64641. get step(): number;
  64642. /**
  64643. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64644. */
  64645. set step(val: number);
  64646. private _color;
  64647. /**
  64648. * Gets the color associated with this step
  64649. */
  64650. get color(): Color3;
  64651. /**
  64652. * Sets the color associated with this step
  64653. */
  64654. set color(val: Color3);
  64655. /**
  64656. * Creates a new GradientBlockColorStep
  64657. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64658. * @param color defines the color associated with this step
  64659. */
  64660. constructor(step: number, color: Color3);
  64661. }
  64662. /**
  64663. * Block used to return a color from a gradient based on an input value between 0 and 1
  64664. */
  64665. export class GradientBlock extends NodeMaterialBlock {
  64666. /**
  64667. * Gets or sets the list of color steps
  64668. */
  64669. colorSteps: GradientBlockColorStep[];
  64670. /** Gets an observable raised when the value is changed */
  64671. onValueChangedObservable: Observable<GradientBlock>;
  64672. /** calls observable when the value is changed*/
  64673. colorStepsUpdated(): void;
  64674. /**
  64675. * Creates a new GradientBlock
  64676. * @param name defines the block name
  64677. */
  64678. constructor(name: string);
  64679. /**
  64680. * Gets the current class name
  64681. * @returns the class name
  64682. */
  64683. getClassName(): string;
  64684. /**
  64685. * Gets the gradient input component
  64686. */
  64687. get gradient(): NodeMaterialConnectionPoint;
  64688. /**
  64689. * Gets the output component
  64690. */
  64691. get output(): NodeMaterialConnectionPoint;
  64692. private _writeColorConstant;
  64693. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64694. serialize(): any;
  64695. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64696. protected _dumpPropertiesCode(): string;
  64697. }
  64698. }
  64699. declare module BABYLON {
  64700. /**
  64701. * Block used to normalize lerp between 2 values
  64702. */
  64703. export class NLerpBlock extends NodeMaterialBlock {
  64704. /**
  64705. * Creates a new NLerpBlock
  64706. * @param name defines the block name
  64707. */
  64708. constructor(name: string);
  64709. /**
  64710. * Gets the current class name
  64711. * @returns the class name
  64712. */
  64713. getClassName(): string;
  64714. /**
  64715. * Gets the left operand input component
  64716. */
  64717. get left(): NodeMaterialConnectionPoint;
  64718. /**
  64719. * Gets the right operand input component
  64720. */
  64721. get right(): NodeMaterialConnectionPoint;
  64722. /**
  64723. * Gets the gradient operand input component
  64724. */
  64725. get gradient(): NodeMaterialConnectionPoint;
  64726. /**
  64727. * Gets the output component
  64728. */
  64729. get output(): NodeMaterialConnectionPoint;
  64730. protected _buildBlock(state: NodeMaterialBuildState): this;
  64731. }
  64732. }
  64733. declare module BABYLON {
  64734. /**
  64735. * block used to Generate a Worley Noise 3D Noise Pattern
  64736. */
  64737. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64738. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64739. manhattanDistance: boolean;
  64740. /**
  64741. * Creates a new WorleyNoise3DBlock
  64742. * @param name defines the block name
  64743. */
  64744. constructor(name: string);
  64745. /**
  64746. * Gets the current class name
  64747. * @returns the class name
  64748. */
  64749. getClassName(): string;
  64750. /**
  64751. * Gets the seed input component
  64752. */
  64753. get seed(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the jitter input component
  64756. */
  64757. get jitter(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the output component
  64760. */
  64761. get output(): NodeMaterialConnectionPoint;
  64762. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64763. /**
  64764. * Exposes the properties to the UI?
  64765. */
  64766. protected _dumpPropertiesCode(): string;
  64767. /**
  64768. * Exposes the properties to the Seralize?
  64769. */
  64770. serialize(): any;
  64771. /**
  64772. * Exposes the properties to the deseralize?
  64773. */
  64774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64775. }
  64776. }
  64777. declare module BABYLON {
  64778. /**
  64779. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64780. */
  64781. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64782. /**
  64783. * Creates a new SimplexPerlin3DBlock
  64784. * @param name defines the block name
  64785. */
  64786. constructor(name: string);
  64787. /**
  64788. * Gets the current class name
  64789. * @returns the class name
  64790. */
  64791. getClassName(): string;
  64792. /**
  64793. * Gets the seed operand input component
  64794. */
  64795. get seed(): NodeMaterialConnectionPoint;
  64796. /**
  64797. * Gets the output component
  64798. */
  64799. get output(): NodeMaterialConnectionPoint;
  64800. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64801. }
  64802. }
  64803. declare module BABYLON {
  64804. /**
  64805. * Block used to blend normals
  64806. */
  64807. export class NormalBlendBlock extends NodeMaterialBlock {
  64808. /**
  64809. * Creates a new NormalBlendBlock
  64810. * @param name defines the block name
  64811. */
  64812. constructor(name: string);
  64813. /**
  64814. * Gets the current class name
  64815. * @returns the class name
  64816. */
  64817. getClassName(): string;
  64818. /**
  64819. * Gets the first input component
  64820. */
  64821. get normalMap0(): NodeMaterialConnectionPoint;
  64822. /**
  64823. * Gets the second input component
  64824. */
  64825. get normalMap1(): NodeMaterialConnectionPoint;
  64826. /**
  64827. * Gets the output component
  64828. */
  64829. get output(): NodeMaterialConnectionPoint;
  64830. protected _buildBlock(state: NodeMaterialBuildState): this;
  64831. }
  64832. }
  64833. declare module BABYLON {
  64834. /**
  64835. * Block used to rotate a 2d vector by a given angle
  64836. */
  64837. export class Rotate2dBlock extends NodeMaterialBlock {
  64838. /**
  64839. * Creates a new Rotate2dBlock
  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 input vector
  64850. */
  64851. get input(): NodeMaterialConnectionPoint;
  64852. /**
  64853. * Gets the input angle
  64854. */
  64855. get angle(): NodeMaterialConnectionPoint;
  64856. /**
  64857. * Gets the output component
  64858. */
  64859. get output(): NodeMaterialConnectionPoint;
  64860. autoConfigure(material: NodeMaterial): void;
  64861. protected _buildBlock(state: NodeMaterialBuildState): this;
  64862. }
  64863. }
  64864. declare module BABYLON {
  64865. /**
  64866. * Block used to get the reflected vector from a direction and a normal
  64867. */
  64868. export class ReflectBlock extends NodeMaterialBlock {
  64869. /**
  64870. * Creates a new ReflectBlock
  64871. * @param name defines the block name
  64872. */
  64873. constructor(name: string);
  64874. /**
  64875. * Gets the current class name
  64876. * @returns the class name
  64877. */
  64878. getClassName(): string;
  64879. /**
  64880. * Gets the incident component
  64881. */
  64882. get incident(): NodeMaterialConnectionPoint;
  64883. /**
  64884. * Gets the normal component
  64885. */
  64886. get normal(): NodeMaterialConnectionPoint;
  64887. /**
  64888. * Gets the output component
  64889. */
  64890. get output(): NodeMaterialConnectionPoint;
  64891. protected _buildBlock(state: NodeMaterialBuildState): this;
  64892. }
  64893. }
  64894. declare module BABYLON {
  64895. /**
  64896. * Block used to get the refracted vector from a direction and a normal
  64897. */
  64898. export class RefractBlock extends NodeMaterialBlock {
  64899. /**
  64900. * Creates a new RefractBlock
  64901. * @param name defines the block name
  64902. */
  64903. constructor(name: string);
  64904. /**
  64905. * Gets the current class name
  64906. * @returns the class name
  64907. */
  64908. getClassName(): string;
  64909. /**
  64910. * Gets the incident component
  64911. */
  64912. get incident(): NodeMaterialConnectionPoint;
  64913. /**
  64914. * Gets the normal component
  64915. */
  64916. get normal(): NodeMaterialConnectionPoint;
  64917. /**
  64918. * Gets the index of refraction component
  64919. */
  64920. get ior(): NodeMaterialConnectionPoint;
  64921. /**
  64922. * Gets the output component
  64923. */
  64924. get output(): NodeMaterialConnectionPoint;
  64925. protected _buildBlock(state: NodeMaterialBuildState): this;
  64926. }
  64927. }
  64928. declare module BABYLON {
  64929. /**
  64930. * Block used to desaturate a color
  64931. */
  64932. export class DesaturateBlock extends NodeMaterialBlock {
  64933. /**
  64934. * Creates a new DesaturateBlock
  64935. * @param name defines the block name
  64936. */
  64937. constructor(name: string);
  64938. /**
  64939. * Gets the current class name
  64940. * @returns the class name
  64941. */
  64942. getClassName(): string;
  64943. /**
  64944. * Gets the color operand input component
  64945. */
  64946. get color(): NodeMaterialConnectionPoint;
  64947. /**
  64948. * Gets the level operand input component
  64949. */
  64950. get level(): NodeMaterialConnectionPoint;
  64951. /**
  64952. * Gets the output component
  64953. */
  64954. get output(): NodeMaterialConnectionPoint;
  64955. protected _buildBlock(state: NodeMaterialBuildState): this;
  64956. }
  64957. }
  64958. declare module BABYLON {
  64959. /**
  64960. * Block used to implement the ambient occlusion module of the PBR material
  64961. */
  64962. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64963. /**
  64964. * Create a new AmbientOcclusionBlock
  64965. * @param name defines the block name
  64966. */
  64967. constructor(name: string);
  64968. /**
  64969. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64970. */
  64971. useAmbientInGrayScale: boolean;
  64972. /**
  64973. * Initialize the block and prepare the context for build
  64974. * @param state defines the state that will be used for the build
  64975. */
  64976. initialize(state: NodeMaterialBuildState): void;
  64977. /**
  64978. * Gets the current class name
  64979. * @returns the class name
  64980. */
  64981. getClassName(): string;
  64982. /**
  64983. * Gets the texture input component
  64984. */
  64985. get texture(): NodeMaterialConnectionPoint;
  64986. /**
  64987. * Gets the texture intensity component
  64988. */
  64989. get intensity(): NodeMaterialConnectionPoint;
  64990. /**
  64991. * Gets the direct light intensity input component
  64992. */
  64993. get directLightIntensity(): NodeMaterialConnectionPoint;
  64994. /**
  64995. * Gets the ambient occlusion object output component
  64996. */
  64997. get ambientOcc(): NodeMaterialConnectionPoint;
  64998. /**
  64999. * Gets the main code of the block (fragment side)
  65000. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65001. * @returns the shader code
  65002. */
  65003. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65004. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65005. protected _buildBlock(state: NodeMaterialBuildState): this;
  65006. protected _dumpPropertiesCode(): string;
  65007. serialize(): any;
  65008. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65009. }
  65010. }
  65011. declare module BABYLON {
  65012. /**
  65013. * Block used to implement the reflection module of the PBR material
  65014. */
  65015. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65016. /** @hidden */
  65017. _defineLODReflectionAlpha: string;
  65018. /** @hidden */
  65019. _defineLinearSpecularReflection: string;
  65020. private _vEnvironmentIrradianceName;
  65021. /** @hidden */
  65022. _vReflectionMicrosurfaceInfosName: string;
  65023. /** @hidden */
  65024. _vReflectionInfosName: string;
  65025. /** @hidden */
  65026. _vReflectionFilteringInfoName: string;
  65027. private _scene;
  65028. /**
  65029. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65030. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65031. * It's less burden on the user side in the editor part.
  65032. */
  65033. /** @hidden */
  65034. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65035. /** @hidden */
  65036. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65037. /** @hidden */
  65038. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65039. /**
  65040. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65041. * diffuse part of the IBL.
  65042. */
  65043. useSphericalHarmonics: boolean;
  65044. /**
  65045. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65046. */
  65047. forceIrradianceInFragment: boolean;
  65048. /**
  65049. * Create a new ReflectionBlock
  65050. * @param name defines the block name
  65051. */
  65052. constructor(name: string);
  65053. /**
  65054. * Gets the current class name
  65055. * @returns the class name
  65056. */
  65057. getClassName(): string;
  65058. /**
  65059. * Gets the position input component
  65060. */
  65061. get position(): NodeMaterialConnectionPoint;
  65062. /**
  65063. * Gets the world position input component
  65064. */
  65065. get worldPosition(): NodeMaterialConnectionPoint;
  65066. /**
  65067. * Gets the world normal input component
  65068. */
  65069. get worldNormal(): NodeMaterialConnectionPoint;
  65070. /**
  65071. * Gets the world input component
  65072. */
  65073. get world(): NodeMaterialConnectionPoint;
  65074. /**
  65075. * Gets the camera (or eye) position component
  65076. */
  65077. get cameraPosition(): NodeMaterialConnectionPoint;
  65078. /**
  65079. * Gets the view input component
  65080. */
  65081. get view(): NodeMaterialConnectionPoint;
  65082. /**
  65083. * Gets the color input component
  65084. */
  65085. get color(): NodeMaterialConnectionPoint;
  65086. /**
  65087. * Gets the reflection object output component
  65088. */
  65089. get reflection(): NodeMaterialConnectionPoint;
  65090. /**
  65091. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65092. */
  65093. get hasTexture(): boolean;
  65094. /**
  65095. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65096. */
  65097. get reflectionColor(): string;
  65098. protected _getTexture(): Nullable<BaseTexture>;
  65099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65100. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65101. /**
  65102. * Gets the code to inject in the vertex shader
  65103. * @param state current state of the node material building
  65104. * @returns the shader code
  65105. */
  65106. handleVertexSide(state: NodeMaterialBuildState): string;
  65107. /**
  65108. * Gets the main code of the block (fragment side)
  65109. * @param state current state of the node material building
  65110. * @param normalVarName name of the existing variable corresponding to the normal
  65111. * @returns the shader code
  65112. */
  65113. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65114. protected _buildBlock(state: NodeMaterialBuildState): this;
  65115. protected _dumpPropertiesCode(): string;
  65116. serialize(): any;
  65117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65118. }
  65119. }
  65120. declare module BABYLON {
  65121. /**
  65122. * Block used to implement the sheen module of the PBR material
  65123. */
  65124. export class SheenBlock extends NodeMaterialBlock {
  65125. /**
  65126. * Create a new SheenBlock
  65127. * @param name defines the block name
  65128. */
  65129. constructor(name: string);
  65130. /**
  65131. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65132. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65133. * making it easier to setup and tweak the effect
  65134. */
  65135. albedoScaling: boolean;
  65136. /**
  65137. * Defines if the sheen is linked to the sheen color.
  65138. */
  65139. linkSheenWithAlbedo: boolean;
  65140. /**
  65141. * Initialize the block and prepare the context for build
  65142. * @param state defines the state that will be used for the build
  65143. */
  65144. initialize(state: NodeMaterialBuildState): void;
  65145. /**
  65146. * Gets the current class name
  65147. * @returns the class name
  65148. */
  65149. getClassName(): string;
  65150. /**
  65151. * Gets the intensity input component
  65152. */
  65153. get intensity(): NodeMaterialConnectionPoint;
  65154. /**
  65155. * Gets the color input component
  65156. */
  65157. get color(): NodeMaterialConnectionPoint;
  65158. /**
  65159. * Gets the roughness input component
  65160. */
  65161. get roughness(): NodeMaterialConnectionPoint;
  65162. /**
  65163. * Gets the sheen object output component
  65164. */
  65165. get sheen(): NodeMaterialConnectionPoint;
  65166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65167. /**
  65168. * Gets the main code of the block (fragment side)
  65169. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65170. * @returns the shader code
  65171. */
  65172. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65173. protected _buildBlock(state: NodeMaterialBuildState): this;
  65174. protected _dumpPropertiesCode(): string;
  65175. serialize(): any;
  65176. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65177. }
  65178. }
  65179. declare module BABYLON {
  65180. /**
  65181. * Block used to implement the reflectivity module of the PBR material
  65182. */
  65183. export class ReflectivityBlock extends NodeMaterialBlock {
  65184. private _metallicReflectanceColor;
  65185. private _metallicF0Factor;
  65186. /** @hidden */
  65187. _vMetallicReflectanceFactorsName: string;
  65188. /**
  65189. * The property below is set by the main PBR block prior to calling methods of this class.
  65190. */
  65191. /** @hidden */
  65192. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65193. /**
  65194. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65195. */
  65196. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65197. /**
  65198. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65199. */
  65200. useMetallnessFromMetallicTextureBlue: boolean;
  65201. /**
  65202. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65203. */
  65204. useRoughnessFromMetallicTextureAlpha: boolean;
  65205. /**
  65206. * Specifies if the metallic texture contains the roughness information in its green channel.
  65207. */
  65208. useRoughnessFromMetallicTextureGreen: boolean;
  65209. /**
  65210. * Create a new ReflectivityBlock
  65211. * @param name defines the block name
  65212. */
  65213. constructor(name: string);
  65214. /**
  65215. * Initialize the block and prepare the context for build
  65216. * @param state defines the state that will be used for the build
  65217. */
  65218. initialize(state: NodeMaterialBuildState): void;
  65219. /**
  65220. * Gets the current class name
  65221. * @returns the class name
  65222. */
  65223. getClassName(): string;
  65224. /**
  65225. * Gets the metallic input component
  65226. */
  65227. get metallic(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the roughness input component
  65230. */
  65231. get roughness(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the texture input component
  65234. */
  65235. get texture(): NodeMaterialConnectionPoint;
  65236. /**
  65237. * Gets the reflectivity object output component
  65238. */
  65239. get reflectivity(): NodeMaterialConnectionPoint;
  65240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65241. /**
  65242. * Gets the main code of the block (fragment side)
  65243. * @param state current state of the node material building
  65244. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65245. * @returns the shader code
  65246. */
  65247. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65249. protected _buildBlock(state: NodeMaterialBuildState): this;
  65250. protected _dumpPropertiesCode(): string;
  65251. serialize(): any;
  65252. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65253. }
  65254. }
  65255. declare module BABYLON {
  65256. /**
  65257. * Block used to implement the anisotropy module of the PBR material
  65258. */
  65259. export class AnisotropyBlock extends NodeMaterialBlock {
  65260. /**
  65261. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65262. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65263. * It's less burden on the user side in the editor part.
  65264. */
  65265. /** @hidden */
  65266. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65267. /** @hidden */
  65268. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65269. /**
  65270. * Create a new AnisotropyBlock
  65271. * @param name defines the block name
  65272. */
  65273. constructor(name: string);
  65274. /**
  65275. * Initialize the block and prepare the context for build
  65276. * @param state defines the state that will be used for the build
  65277. */
  65278. initialize(state: NodeMaterialBuildState): void;
  65279. /**
  65280. * Gets the current class name
  65281. * @returns the class name
  65282. */
  65283. getClassName(): string;
  65284. /**
  65285. * Gets the intensity input component
  65286. */
  65287. get intensity(): NodeMaterialConnectionPoint;
  65288. /**
  65289. * Gets the direction input component
  65290. */
  65291. get direction(): NodeMaterialConnectionPoint;
  65292. /**
  65293. * Gets the texture input component
  65294. */
  65295. get texture(): NodeMaterialConnectionPoint;
  65296. /**
  65297. * Gets the uv input component
  65298. */
  65299. get uv(): NodeMaterialConnectionPoint;
  65300. /**
  65301. * Gets the worldTangent input component
  65302. */
  65303. get worldTangent(): NodeMaterialConnectionPoint;
  65304. /**
  65305. * Gets the anisotropy object output component
  65306. */
  65307. get anisotropy(): NodeMaterialConnectionPoint;
  65308. private _generateTBNSpace;
  65309. /**
  65310. * Gets the main code of the block (fragment side)
  65311. * @param state current state of the node material building
  65312. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65313. * @returns the shader code
  65314. */
  65315. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65317. protected _buildBlock(state: NodeMaterialBuildState): this;
  65318. }
  65319. }
  65320. declare module BABYLON {
  65321. /**
  65322. * Block used to implement the clear coat module of the PBR material
  65323. */
  65324. export class ClearCoatBlock extends NodeMaterialBlock {
  65325. private _scene;
  65326. /**
  65327. * Create a new ClearCoatBlock
  65328. * @param name defines the block name
  65329. */
  65330. constructor(name: string);
  65331. /**
  65332. * Initialize the block and prepare the context for build
  65333. * @param state defines the state that will be used for the build
  65334. */
  65335. initialize(state: NodeMaterialBuildState): void;
  65336. /**
  65337. * Gets the current class name
  65338. * @returns the class name
  65339. */
  65340. getClassName(): string;
  65341. /**
  65342. * Gets the intensity input component
  65343. */
  65344. get intensity(): NodeMaterialConnectionPoint;
  65345. /**
  65346. * Gets the roughness input component
  65347. */
  65348. get roughness(): NodeMaterialConnectionPoint;
  65349. /**
  65350. * Gets the ior input component
  65351. */
  65352. get ior(): NodeMaterialConnectionPoint;
  65353. /**
  65354. * Gets the texture input component
  65355. */
  65356. get texture(): NodeMaterialConnectionPoint;
  65357. /**
  65358. * Gets the bump texture input component
  65359. */
  65360. get bumpTexture(): NodeMaterialConnectionPoint;
  65361. /**
  65362. * Gets the uv input component
  65363. */
  65364. get uv(): NodeMaterialConnectionPoint;
  65365. /**
  65366. * Gets the tint color input component
  65367. */
  65368. get tintColor(): NodeMaterialConnectionPoint;
  65369. /**
  65370. * Gets the tint "at distance" input component
  65371. */
  65372. get tintAtDistance(): NodeMaterialConnectionPoint;
  65373. /**
  65374. * Gets the tint thickness input component
  65375. */
  65376. get tintThickness(): NodeMaterialConnectionPoint;
  65377. /**
  65378. * Gets the world tangent input component
  65379. */
  65380. get worldTangent(): NodeMaterialConnectionPoint;
  65381. /**
  65382. * Gets the clear coat object output component
  65383. */
  65384. get clearcoat(): NodeMaterialConnectionPoint;
  65385. autoConfigure(material: NodeMaterial): void;
  65386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65388. private _generateTBNSpace;
  65389. /**
  65390. * Gets the main code of the block (fragment side)
  65391. * @param state current state of the node material building
  65392. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65393. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65394. * @param worldPosVarName name of the variable holding the world position
  65395. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65396. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65397. * @param worldNormalVarName name of the variable holding the world normal
  65398. * @returns the shader code
  65399. */
  65400. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65401. protected _buildBlock(state: NodeMaterialBuildState): this;
  65402. }
  65403. }
  65404. declare module BABYLON {
  65405. /**
  65406. * Block used to implement the sub surface module of the PBR material
  65407. */
  65408. export class SubSurfaceBlock extends NodeMaterialBlock {
  65409. /**
  65410. * Create a new SubSurfaceBlock
  65411. * @param name defines the block name
  65412. */
  65413. constructor(name: string);
  65414. /**
  65415. * Stores the intensity of the different subsurface effects in the thickness texture.
  65416. * * the green channel is the translucency intensity.
  65417. * * the blue channel is the scattering intensity.
  65418. * * the alpha channel is the refraction intensity.
  65419. */
  65420. useMaskFromThicknessTexture: boolean;
  65421. /**
  65422. * Initialize the block and prepare the context for build
  65423. * @param state defines the state that will be used for the build
  65424. */
  65425. initialize(state: NodeMaterialBuildState): void;
  65426. /**
  65427. * Gets the current class name
  65428. * @returns the class name
  65429. */
  65430. getClassName(): string;
  65431. /**
  65432. * Gets the min thickness input component
  65433. */
  65434. get minThickness(): NodeMaterialConnectionPoint;
  65435. /**
  65436. * Gets the max thickness input component
  65437. */
  65438. get maxThickness(): NodeMaterialConnectionPoint;
  65439. /**
  65440. * Gets the thickness texture component
  65441. */
  65442. get thicknessTexture(): NodeMaterialConnectionPoint;
  65443. /**
  65444. * Gets the tint color input component
  65445. */
  65446. get tintColor(): NodeMaterialConnectionPoint;
  65447. /**
  65448. * Gets the translucency intensity input component
  65449. */
  65450. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65451. /**
  65452. * Gets the translucency diffusion distance input component
  65453. */
  65454. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65455. /**
  65456. * Gets the refraction object parameters
  65457. */
  65458. get refraction(): NodeMaterialConnectionPoint;
  65459. /**
  65460. * Gets the sub surface object output component
  65461. */
  65462. get subsurface(): NodeMaterialConnectionPoint;
  65463. autoConfigure(material: NodeMaterial): void;
  65464. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65465. /**
  65466. * Gets the main code of the block (fragment side)
  65467. * @param state current state of the node material building
  65468. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65469. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65470. * @param worldPosVarName name of the variable holding the world position
  65471. * @returns the shader code
  65472. */
  65473. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65474. protected _buildBlock(state: NodeMaterialBuildState): this;
  65475. }
  65476. }
  65477. declare module BABYLON {
  65478. /**
  65479. * Block used to implement the PBR metallic/roughness model
  65480. */
  65481. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65482. /**
  65483. * Gets or sets the light associated with this block
  65484. */
  65485. light: Nullable<Light>;
  65486. private _lightId;
  65487. private _scene;
  65488. private _environmentBRDFTexture;
  65489. private _environmentBrdfSamplerName;
  65490. private _vNormalWName;
  65491. private _invertNormalName;
  65492. /**
  65493. * Create a new ReflectionBlock
  65494. * @param name defines the block name
  65495. */
  65496. constructor(name: string);
  65497. /**
  65498. * Intensity of the direct lights e.g. the four lights available in your scene.
  65499. * This impacts both the direct diffuse and specular highlights.
  65500. */
  65501. directIntensity: number;
  65502. /**
  65503. * Intensity of the environment e.g. how much the environment will light the object
  65504. * either through harmonics for rough material or through the refelction for shiny ones.
  65505. */
  65506. environmentIntensity: number;
  65507. /**
  65508. * This is a special control allowing the reduction of the specular highlights coming from the
  65509. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65510. */
  65511. specularIntensity: number;
  65512. /**
  65513. * Defines the falloff type used in this material.
  65514. * It by default is Physical.
  65515. */
  65516. lightFalloff: number;
  65517. /**
  65518. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65519. */
  65520. useAlphaFromAlbedoTexture: boolean;
  65521. /**
  65522. * Specifies that alpha test should be used
  65523. */
  65524. useAlphaTest: boolean;
  65525. /**
  65526. * Defines the alpha limits in alpha test mode.
  65527. */
  65528. alphaTestCutoff: number;
  65529. /**
  65530. * Specifies that alpha blending should be used
  65531. */
  65532. useAlphaBlending: boolean;
  65533. /**
  65534. * Defines if the alpha value should be determined via the rgb values.
  65535. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65536. */
  65537. opacityRGB: boolean;
  65538. /**
  65539. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65540. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65541. */
  65542. useRadianceOverAlpha: boolean;
  65543. /**
  65544. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65545. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65546. */
  65547. useSpecularOverAlpha: boolean;
  65548. /**
  65549. * Enables specular anti aliasing in the PBR shader.
  65550. * It will both interacts on the Geometry for analytical and IBL lighting.
  65551. * It also prefilter the roughness map based on the bump values.
  65552. */
  65553. enableSpecularAntiAliasing: boolean;
  65554. /**
  65555. * Enables realtime filtering on the texture.
  65556. */
  65557. realTimeFiltering: boolean;
  65558. /**
  65559. * Quality switch for realtime filtering
  65560. */
  65561. realTimeFilteringQuality: number;
  65562. /**
  65563. * Defines if the material uses energy conservation.
  65564. */
  65565. useEnergyConservation: boolean;
  65566. /**
  65567. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65568. * too much the area relying on ambient texture to define their ambient occlusion.
  65569. */
  65570. useRadianceOcclusion: boolean;
  65571. /**
  65572. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65573. * makes the reflect vector face the model (under horizon).
  65574. */
  65575. useHorizonOcclusion: boolean;
  65576. /**
  65577. * If set to true, no lighting calculations will be applied.
  65578. */
  65579. unlit: boolean;
  65580. /**
  65581. * Force normal to face away from face.
  65582. */
  65583. forceNormalForward: boolean;
  65584. /**
  65585. * Defines the material debug mode.
  65586. * It helps seeing only some components of the material while troubleshooting.
  65587. */
  65588. debugMode: number;
  65589. /**
  65590. * Specify from where on screen the debug mode should start.
  65591. * The value goes from -1 (full screen) to 1 (not visible)
  65592. * It helps with side by side comparison against the final render
  65593. * This defaults to 0
  65594. */
  65595. debugLimit: number;
  65596. /**
  65597. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65598. * You can use the factor to better multiply the final value.
  65599. */
  65600. debugFactor: number;
  65601. /**
  65602. * Initialize the block and prepare the context for build
  65603. * @param state defines the state that will be used for the build
  65604. */
  65605. initialize(state: NodeMaterialBuildState): void;
  65606. /**
  65607. * Gets the current class name
  65608. * @returns the class name
  65609. */
  65610. getClassName(): string;
  65611. /**
  65612. * Gets the world position input component
  65613. */
  65614. get worldPosition(): NodeMaterialConnectionPoint;
  65615. /**
  65616. * Gets the world normal input component
  65617. */
  65618. get worldNormal(): NodeMaterialConnectionPoint;
  65619. /**
  65620. * Gets the perturbed normal input component
  65621. */
  65622. get perturbedNormal(): NodeMaterialConnectionPoint;
  65623. /**
  65624. * Gets the camera position input component
  65625. */
  65626. get cameraPosition(): NodeMaterialConnectionPoint;
  65627. /**
  65628. * Gets the base color input component
  65629. */
  65630. get baseColor(): NodeMaterialConnectionPoint;
  65631. /**
  65632. * Gets the opacity texture input component
  65633. */
  65634. get opacityTexture(): NodeMaterialConnectionPoint;
  65635. /**
  65636. * Gets the ambient color input component
  65637. */
  65638. get ambientColor(): NodeMaterialConnectionPoint;
  65639. /**
  65640. * Gets the reflectivity object parameters
  65641. */
  65642. get reflectivity(): NodeMaterialConnectionPoint;
  65643. /**
  65644. * Gets the ambient occlusion object parameters
  65645. */
  65646. get ambientOcc(): NodeMaterialConnectionPoint;
  65647. /**
  65648. * Gets the reflection object parameters
  65649. */
  65650. get reflection(): NodeMaterialConnectionPoint;
  65651. /**
  65652. * Gets the sheen object parameters
  65653. */
  65654. get sheen(): NodeMaterialConnectionPoint;
  65655. /**
  65656. * Gets the clear coat object parameters
  65657. */
  65658. get clearcoat(): NodeMaterialConnectionPoint;
  65659. /**
  65660. * Gets the sub surface object parameters
  65661. */
  65662. get subsurface(): NodeMaterialConnectionPoint;
  65663. /**
  65664. * Gets the anisotropy object parameters
  65665. */
  65666. get anisotropy(): NodeMaterialConnectionPoint;
  65667. /**
  65668. * Gets the ambient output component
  65669. */
  65670. get ambient(): NodeMaterialConnectionPoint;
  65671. /**
  65672. * Gets the diffuse output component
  65673. */
  65674. get diffuse(): NodeMaterialConnectionPoint;
  65675. /**
  65676. * Gets the specular output component
  65677. */
  65678. get specular(): NodeMaterialConnectionPoint;
  65679. /**
  65680. * Gets the sheen output component
  65681. */
  65682. get sheenDir(): NodeMaterialConnectionPoint;
  65683. /**
  65684. * Gets the clear coat output component
  65685. */
  65686. get clearcoatDir(): NodeMaterialConnectionPoint;
  65687. /**
  65688. * Gets the indirect diffuse output component
  65689. */
  65690. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65691. /**
  65692. * Gets the indirect specular output component
  65693. */
  65694. get specularIndirect(): NodeMaterialConnectionPoint;
  65695. /**
  65696. * Gets the indirect sheen output component
  65697. */
  65698. get sheenIndirect(): NodeMaterialConnectionPoint;
  65699. /**
  65700. * Gets the indirect clear coat output component
  65701. */
  65702. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65703. /**
  65704. * Gets the refraction output component
  65705. */
  65706. get refraction(): NodeMaterialConnectionPoint;
  65707. /**
  65708. * Gets the global lighting output component
  65709. */
  65710. get lighting(): NodeMaterialConnectionPoint;
  65711. /**
  65712. * Gets the shadow output component
  65713. */
  65714. get shadow(): NodeMaterialConnectionPoint;
  65715. /**
  65716. * Gets the alpha output component
  65717. */
  65718. get alpha(): NodeMaterialConnectionPoint;
  65719. autoConfigure(material: NodeMaterial): void;
  65720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65721. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65722. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65723. private _injectVertexCode;
  65724. /**
  65725. * Gets the code corresponding to the albedo/opacity module
  65726. * @returns the shader code
  65727. */
  65728. getAlbedoOpacityCode(): string;
  65729. protected _buildBlock(state: NodeMaterialBuildState): this;
  65730. protected _dumpPropertiesCode(): string;
  65731. serialize(): any;
  65732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65733. }
  65734. }
  65735. declare module BABYLON {
  65736. /**
  65737. * Block used to compute value of one parameter modulo another
  65738. */
  65739. export class ModBlock extends NodeMaterialBlock {
  65740. /**
  65741. * Creates a new ModBlock
  65742. * @param name defines the block name
  65743. */
  65744. constructor(name: string);
  65745. /**
  65746. * Gets the current class name
  65747. * @returns the class name
  65748. */
  65749. getClassName(): string;
  65750. /**
  65751. * Gets the left operand input component
  65752. */
  65753. get left(): NodeMaterialConnectionPoint;
  65754. /**
  65755. * Gets the right operand input component
  65756. */
  65757. get right(): NodeMaterialConnectionPoint;
  65758. /**
  65759. * Gets the output component
  65760. */
  65761. get output(): NodeMaterialConnectionPoint;
  65762. protected _buildBlock(state: NodeMaterialBuildState): this;
  65763. }
  65764. }
  65765. declare module BABYLON {
  65766. /**
  65767. * Configuration for Draco compression
  65768. */
  65769. export interface IDracoCompressionConfiguration {
  65770. /**
  65771. * Configuration for the decoder.
  65772. */
  65773. decoder: {
  65774. /**
  65775. * The url to the WebAssembly module.
  65776. */
  65777. wasmUrl?: string;
  65778. /**
  65779. * The url to the WebAssembly binary.
  65780. */
  65781. wasmBinaryUrl?: string;
  65782. /**
  65783. * The url to the fallback JavaScript module.
  65784. */
  65785. fallbackUrl?: string;
  65786. };
  65787. }
  65788. /**
  65789. * Draco compression (https://google.github.io/draco/)
  65790. *
  65791. * This class wraps the Draco module.
  65792. *
  65793. * **Encoder**
  65794. *
  65795. * The encoder is not currently implemented.
  65796. *
  65797. * **Decoder**
  65798. *
  65799. * 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.
  65800. *
  65801. * To update the configuration, use the following code:
  65802. * ```javascript
  65803. * DracoCompression.Configuration = {
  65804. * decoder: {
  65805. * wasmUrl: "<url to the WebAssembly library>",
  65806. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65807. * fallbackUrl: "<url to the fallback JavaScript library>",
  65808. * }
  65809. * };
  65810. * ```
  65811. *
  65812. * 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.
  65813. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65814. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65815. *
  65816. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65817. * ```javascript
  65818. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65819. * ```
  65820. *
  65821. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65822. */
  65823. export class DracoCompression implements IDisposable {
  65824. private _workerPoolPromise?;
  65825. private _decoderModulePromise?;
  65826. /**
  65827. * The configuration. Defaults to the following urls:
  65828. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65829. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65830. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65831. */
  65832. static Configuration: IDracoCompressionConfiguration;
  65833. /**
  65834. * Returns true if the decoder configuration is available.
  65835. */
  65836. static get DecoderAvailable(): boolean;
  65837. /**
  65838. * Default number of workers to create when creating the draco compression object.
  65839. */
  65840. static DefaultNumWorkers: number;
  65841. private static GetDefaultNumWorkers;
  65842. private static _Default;
  65843. /**
  65844. * Default instance for the draco compression object.
  65845. */
  65846. static get Default(): DracoCompression;
  65847. /**
  65848. * Constructor
  65849. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65850. */
  65851. constructor(numWorkers?: number);
  65852. /**
  65853. * Stop all async operations and release resources.
  65854. */
  65855. dispose(): void;
  65856. /**
  65857. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65858. * @returns a promise that resolves when ready
  65859. */
  65860. whenReadyAsync(): Promise<void>;
  65861. /**
  65862. * Decode Draco compressed mesh data to vertex data.
  65863. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65864. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65865. * @returns A promise that resolves with the decoded vertex data
  65866. */
  65867. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65868. [kind: string]: number;
  65869. }): Promise<VertexData>;
  65870. }
  65871. }
  65872. declare module BABYLON {
  65873. /**
  65874. * Class for building Constructive Solid Geometry
  65875. */
  65876. export class CSG {
  65877. private polygons;
  65878. /**
  65879. * The world matrix
  65880. */
  65881. matrix: Matrix;
  65882. /**
  65883. * Stores the position
  65884. */
  65885. position: Vector3;
  65886. /**
  65887. * Stores the rotation
  65888. */
  65889. rotation: Vector3;
  65890. /**
  65891. * Stores the rotation quaternion
  65892. */
  65893. rotationQuaternion: Nullable<Quaternion>;
  65894. /**
  65895. * Stores the scaling vector
  65896. */
  65897. scaling: Vector3;
  65898. /**
  65899. * Convert the Mesh to CSG
  65900. * @param mesh The Mesh to convert to CSG
  65901. * @returns A new CSG from the Mesh
  65902. */
  65903. static FromMesh(mesh: Mesh): CSG;
  65904. /**
  65905. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65906. * @param polygons Polygons used to construct a CSG solid
  65907. */
  65908. private static FromPolygons;
  65909. /**
  65910. * Clones, or makes a deep copy, of the CSG
  65911. * @returns A new CSG
  65912. */
  65913. clone(): CSG;
  65914. /**
  65915. * Unions this CSG with another CSG
  65916. * @param csg The CSG to union against this CSG
  65917. * @returns The unioned CSG
  65918. */
  65919. union(csg: CSG): CSG;
  65920. /**
  65921. * Unions this CSG with another CSG in place
  65922. * @param csg The CSG to union against this CSG
  65923. */
  65924. unionInPlace(csg: CSG): void;
  65925. /**
  65926. * Subtracts this CSG with another CSG
  65927. * @param csg The CSG to subtract against this CSG
  65928. * @returns A new CSG
  65929. */
  65930. subtract(csg: CSG): CSG;
  65931. /**
  65932. * Subtracts this CSG with another CSG in place
  65933. * @param csg The CSG to subtact against this CSG
  65934. */
  65935. subtractInPlace(csg: CSG): void;
  65936. /**
  65937. * Intersect this CSG with another CSG
  65938. * @param csg The CSG to intersect against this CSG
  65939. * @returns A new CSG
  65940. */
  65941. intersect(csg: CSG): CSG;
  65942. /**
  65943. * Intersects this CSG with another CSG in place
  65944. * @param csg The CSG to intersect against this CSG
  65945. */
  65946. intersectInPlace(csg: CSG): void;
  65947. /**
  65948. * Return a new CSG solid with solid and empty space switched. This solid is
  65949. * not modified.
  65950. * @returns A new CSG solid with solid and empty space switched
  65951. */
  65952. inverse(): CSG;
  65953. /**
  65954. * Inverses the CSG in place
  65955. */
  65956. inverseInPlace(): void;
  65957. /**
  65958. * This is used to keep meshes transformations so they can be restored
  65959. * when we build back a Babylon Mesh
  65960. * NB : All CSG operations are performed in world coordinates
  65961. * @param csg The CSG to copy the transform attributes from
  65962. * @returns This CSG
  65963. */
  65964. copyTransformAttributes(csg: CSG): CSG;
  65965. /**
  65966. * Build Raw mesh from CSG
  65967. * Coordinates here are in world space
  65968. * @param name The name of the mesh geometry
  65969. * @param scene The Scene
  65970. * @param keepSubMeshes Specifies if the submeshes should be kept
  65971. * @returns A new Mesh
  65972. */
  65973. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65974. /**
  65975. * Build Mesh from CSG taking material and transforms into account
  65976. * @param name The name of the Mesh
  65977. * @param material The material of the Mesh
  65978. * @param scene The Scene
  65979. * @param keepSubMeshes Specifies if submeshes should be kept
  65980. * @returns The new Mesh
  65981. */
  65982. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65983. }
  65984. }
  65985. declare module BABYLON {
  65986. /**
  65987. * Class used to create a trail following a mesh
  65988. */
  65989. export class TrailMesh extends Mesh {
  65990. private _generator;
  65991. private _autoStart;
  65992. private _running;
  65993. private _diameter;
  65994. private _length;
  65995. private _sectionPolygonPointsCount;
  65996. private _sectionVectors;
  65997. private _sectionNormalVectors;
  65998. private _beforeRenderObserver;
  65999. /**
  66000. * @constructor
  66001. * @param name The value used by scene.getMeshByName() to do a lookup.
  66002. * @param generator The mesh or transform node to generate a trail.
  66003. * @param scene The scene to add this mesh to.
  66004. * @param diameter Diameter of trailing mesh. Default is 1.
  66005. * @param length Length of trailing mesh. Default is 60.
  66006. * @param autoStart Automatically start trailing mesh. Default true.
  66007. */
  66008. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66009. /**
  66010. * "TrailMesh"
  66011. * @returns "TrailMesh"
  66012. */
  66013. getClassName(): string;
  66014. private _createMesh;
  66015. /**
  66016. * Start trailing mesh.
  66017. */
  66018. start(): void;
  66019. /**
  66020. * Stop trailing mesh.
  66021. */
  66022. stop(): void;
  66023. /**
  66024. * Update trailing mesh geometry.
  66025. */
  66026. update(): void;
  66027. /**
  66028. * Returns a new TrailMesh object.
  66029. * @param name is a string, the name given to the new mesh
  66030. * @param newGenerator use new generator object for cloned trail mesh
  66031. * @returns a new mesh
  66032. */
  66033. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66034. /**
  66035. * Serializes this trail mesh
  66036. * @param serializationObject object to write serialization to
  66037. */
  66038. serialize(serializationObject: any): void;
  66039. /**
  66040. * Parses a serialized trail mesh
  66041. * @param parsedMesh the serialized mesh
  66042. * @param scene the scene to create the trail mesh in
  66043. * @returns the created trail mesh
  66044. */
  66045. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66046. }
  66047. }
  66048. declare module BABYLON {
  66049. /**
  66050. * Class containing static functions to help procedurally build meshes
  66051. */
  66052. export class TiledBoxBuilder {
  66053. /**
  66054. * Creates a box mesh
  66055. * 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)
  66056. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66060. * @param name defines the name of the mesh
  66061. * @param options defines the options used to create the mesh
  66062. * @param scene defines the hosting scene
  66063. * @returns the box mesh
  66064. */
  66065. static CreateTiledBox(name: string, options: {
  66066. pattern?: number;
  66067. width?: number;
  66068. height?: number;
  66069. depth?: number;
  66070. tileSize?: number;
  66071. tileWidth?: number;
  66072. tileHeight?: number;
  66073. alignHorizontal?: number;
  66074. alignVertical?: number;
  66075. faceUV?: Vector4[];
  66076. faceColors?: Color4[];
  66077. sideOrientation?: number;
  66078. updatable?: boolean;
  66079. }, scene?: Nullable<Scene>): Mesh;
  66080. }
  66081. }
  66082. declare module BABYLON {
  66083. /**
  66084. * Class containing static functions to help procedurally build meshes
  66085. */
  66086. export class TorusKnotBuilder {
  66087. /**
  66088. * Creates a torus knot mesh
  66089. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66090. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66091. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66092. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66094. * * 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
  66095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66096. * @param name defines the name of the mesh
  66097. * @param options defines the options used to create the mesh
  66098. * @param scene defines the hosting scene
  66099. * @returns the torus knot mesh
  66100. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66101. */
  66102. static CreateTorusKnot(name: string, options: {
  66103. radius?: number;
  66104. tube?: number;
  66105. radialSegments?: number;
  66106. tubularSegments?: number;
  66107. p?: number;
  66108. q?: number;
  66109. updatable?: boolean;
  66110. sideOrientation?: number;
  66111. frontUVs?: Vector4;
  66112. backUVs?: Vector4;
  66113. }, scene: any): Mesh;
  66114. }
  66115. }
  66116. declare module BABYLON {
  66117. /**
  66118. * Polygon
  66119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66120. */
  66121. export class Polygon {
  66122. /**
  66123. * Creates a rectangle
  66124. * @param xmin bottom X coord
  66125. * @param ymin bottom Y coord
  66126. * @param xmax top X coord
  66127. * @param ymax top Y coord
  66128. * @returns points that make the resulting rectation
  66129. */
  66130. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66131. /**
  66132. * Creates a circle
  66133. * @param radius radius of circle
  66134. * @param cx scale in x
  66135. * @param cy scale in y
  66136. * @param numberOfSides number of sides that make up the circle
  66137. * @returns points that make the resulting circle
  66138. */
  66139. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66140. /**
  66141. * Creates a polygon from input string
  66142. * @param input Input polygon data
  66143. * @returns the parsed points
  66144. */
  66145. static Parse(input: string): Vector2[];
  66146. /**
  66147. * Starts building a polygon from x and y coordinates
  66148. * @param x x coordinate
  66149. * @param y y coordinate
  66150. * @returns the started path2
  66151. */
  66152. static StartingAt(x: number, y: number): Path2;
  66153. }
  66154. /**
  66155. * Builds a polygon
  66156. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66157. */
  66158. export class PolygonMeshBuilder {
  66159. private _points;
  66160. private _outlinepoints;
  66161. private _holes;
  66162. private _name;
  66163. private _scene;
  66164. private _epoints;
  66165. private _eholes;
  66166. private _addToepoint;
  66167. /**
  66168. * Babylon reference to the earcut plugin.
  66169. */
  66170. bjsEarcut: any;
  66171. /**
  66172. * Creates a PolygonMeshBuilder
  66173. * @param name name of the builder
  66174. * @param contours Path of the polygon
  66175. * @param scene scene to add to when creating the mesh
  66176. * @param earcutInjection can be used to inject your own earcut reference
  66177. */
  66178. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66179. /**
  66180. * Adds a whole within the polygon
  66181. * @param hole Array of points defining the hole
  66182. * @returns this
  66183. */
  66184. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66185. /**
  66186. * Creates the polygon
  66187. * @param updatable If the mesh should be updatable
  66188. * @param depth The depth of the mesh created
  66189. * @returns the created mesh
  66190. */
  66191. build(updatable?: boolean, depth?: number): Mesh;
  66192. /**
  66193. * Creates the polygon
  66194. * @param depth The depth of the mesh created
  66195. * @returns the created VertexData
  66196. */
  66197. buildVertexData(depth?: number): VertexData;
  66198. /**
  66199. * Adds a side to the polygon
  66200. * @param positions points that make the polygon
  66201. * @param normals normals of the polygon
  66202. * @param uvs uvs of the polygon
  66203. * @param indices indices of the polygon
  66204. * @param bounds bounds of the polygon
  66205. * @param points points of the polygon
  66206. * @param depth depth of the polygon
  66207. * @param flip flip of the polygon
  66208. */
  66209. private addSide;
  66210. }
  66211. }
  66212. declare module BABYLON {
  66213. /**
  66214. * Class containing static functions to help procedurally build meshes
  66215. */
  66216. export class PolygonBuilder {
  66217. /**
  66218. * Creates a polygon mesh
  66219. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66220. * * 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
  66221. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66224. * * Remember you can only change the shape positions, not their number when updating a polygon
  66225. * @param name defines the name of the mesh
  66226. * @param options defines the options used to create the mesh
  66227. * @param scene defines the hosting scene
  66228. * @param earcutInjection can be used to inject your own earcut reference
  66229. * @returns the polygon mesh
  66230. */
  66231. static CreatePolygon(name: string, options: {
  66232. shape: Vector3[];
  66233. holes?: Vector3[][];
  66234. depth?: number;
  66235. faceUV?: Vector4[];
  66236. faceColors?: Color4[];
  66237. updatable?: boolean;
  66238. sideOrientation?: number;
  66239. frontUVs?: Vector4;
  66240. backUVs?: Vector4;
  66241. wrap?: boolean;
  66242. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66243. /**
  66244. * Creates an extruded polygon mesh, with depth in the Y direction.
  66245. * * 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)
  66246. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66247. * @param name defines the name of the mesh
  66248. * @param options defines the options used to create the mesh
  66249. * @param scene defines the hosting scene
  66250. * @param earcutInjection can be used to inject your own earcut reference
  66251. * @returns the polygon mesh
  66252. */
  66253. static ExtrudePolygon(name: string, options: {
  66254. shape: Vector3[];
  66255. holes?: Vector3[][];
  66256. depth?: number;
  66257. faceUV?: Vector4[];
  66258. faceColors?: Color4[];
  66259. updatable?: boolean;
  66260. sideOrientation?: number;
  66261. frontUVs?: Vector4;
  66262. backUVs?: Vector4;
  66263. wrap?: boolean;
  66264. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66265. }
  66266. }
  66267. declare module BABYLON {
  66268. /**
  66269. * Class containing static functions to help procedurally build meshes
  66270. */
  66271. export class LatheBuilder {
  66272. /**
  66273. * Creates lathe mesh.
  66274. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66275. * * 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
  66276. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66277. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66278. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66279. * * 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
  66280. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66281. * * 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
  66282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66284. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66286. * @param name defines the name of the mesh
  66287. * @param options defines the options used to create the mesh
  66288. * @param scene defines the hosting scene
  66289. * @returns the lathe mesh
  66290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66291. */
  66292. static CreateLathe(name: string, options: {
  66293. shape: Vector3[];
  66294. radius?: number;
  66295. tessellation?: number;
  66296. clip?: number;
  66297. arc?: number;
  66298. closed?: boolean;
  66299. updatable?: boolean;
  66300. sideOrientation?: number;
  66301. frontUVs?: Vector4;
  66302. backUVs?: Vector4;
  66303. cap?: number;
  66304. invertUV?: boolean;
  66305. }, scene?: Nullable<Scene>): Mesh;
  66306. }
  66307. }
  66308. declare module BABYLON {
  66309. /**
  66310. * Class containing static functions to help procedurally build meshes
  66311. */
  66312. export class TiledPlaneBuilder {
  66313. /**
  66314. * Creates a tiled plane mesh
  66315. * * The parameter `pattern` will, depending on value, do nothing or
  66316. * * * flip (reflect about central vertical) alternate tiles across and up
  66317. * * * flip every tile on alternate rows
  66318. * * * rotate (180 degs) alternate tiles across and up
  66319. * * * rotate every tile on alternate rows
  66320. * * * flip and rotate alternate tiles across and up
  66321. * * * flip and rotate every tile on alternate rows
  66322. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66323. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66326. * * 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)
  66327. * * 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)
  66328. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66329. * @param name defines the name of the mesh
  66330. * @param options defines the options used to create the mesh
  66331. * @param scene defines the hosting scene
  66332. * @returns the box mesh
  66333. */
  66334. static CreateTiledPlane(name: string, options: {
  66335. pattern?: number;
  66336. tileSize?: number;
  66337. tileWidth?: number;
  66338. tileHeight?: number;
  66339. size?: number;
  66340. width?: number;
  66341. height?: number;
  66342. alignHorizontal?: number;
  66343. alignVertical?: number;
  66344. sideOrientation?: number;
  66345. frontUVs?: Vector4;
  66346. backUVs?: Vector4;
  66347. updatable?: boolean;
  66348. }, scene?: Nullable<Scene>): Mesh;
  66349. }
  66350. }
  66351. declare module BABYLON {
  66352. /**
  66353. * Class containing static functions to help procedurally build meshes
  66354. */
  66355. export class TubeBuilder {
  66356. /**
  66357. * Creates a tube mesh.
  66358. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66359. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66360. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66361. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66362. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66363. * * 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)
  66364. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66365. * * 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
  66366. * * 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
  66367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66368. * * 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
  66369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66371. * @param name defines the name of the mesh
  66372. * @param options defines the options used to create the mesh
  66373. * @param scene defines the hosting scene
  66374. * @returns the tube mesh
  66375. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66376. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66377. */
  66378. static CreateTube(name: string, options: {
  66379. path: Vector3[];
  66380. radius?: number;
  66381. tessellation?: number;
  66382. radiusFunction?: {
  66383. (i: number, distance: number): number;
  66384. };
  66385. cap?: number;
  66386. arc?: number;
  66387. updatable?: boolean;
  66388. sideOrientation?: number;
  66389. frontUVs?: Vector4;
  66390. backUVs?: Vector4;
  66391. instance?: Mesh;
  66392. invertUV?: boolean;
  66393. }, scene?: Nullable<Scene>): Mesh;
  66394. }
  66395. }
  66396. declare module BABYLON {
  66397. /**
  66398. * Class containing static functions to help procedurally build meshes
  66399. */
  66400. export class IcoSphereBuilder {
  66401. /**
  66402. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66403. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66404. * * 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`)
  66405. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66406. * * 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
  66407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66408. * * 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
  66409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66410. * @param name defines the name of the mesh
  66411. * @param options defines the options used to create the mesh
  66412. * @param scene defines the hosting scene
  66413. * @returns the icosahedron mesh
  66414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66415. */
  66416. static CreateIcoSphere(name: string, options: {
  66417. radius?: number;
  66418. radiusX?: number;
  66419. radiusY?: number;
  66420. radiusZ?: number;
  66421. flat?: boolean;
  66422. subdivisions?: number;
  66423. sideOrientation?: number;
  66424. frontUVs?: Vector4;
  66425. backUVs?: Vector4;
  66426. updatable?: boolean;
  66427. }, scene?: Nullable<Scene>): Mesh;
  66428. }
  66429. }
  66430. declare module BABYLON {
  66431. /**
  66432. * Class containing static functions to help procedurally build meshes
  66433. */
  66434. export class DecalBuilder {
  66435. /**
  66436. * Creates a decal mesh.
  66437. * 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
  66438. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66439. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66440. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66441. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66442. * @param name defines the name of the mesh
  66443. * @param sourceMesh defines the mesh where the decal must be applied
  66444. * @param options defines the options used to create the mesh
  66445. * @param scene defines the hosting scene
  66446. * @returns the decal mesh
  66447. * @see https://doc.babylonjs.com/how_to/decals
  66448. */
  66449. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66450. position?: Vector3;
  66451. normal?: Vector3;
  66452. size?: Vector3;
  66453. angle?: number;
  66454. }): Mesh;
  66455. }
  66456. }
  66457. declare module BABYLON {
  66458. /**
  66459. * Class containing static functions to help procedurally build meshes
  66460. */
  66461. export class MeshBuilder {
  66462. /**
  66463. * Creates a box mesh
  66464. * * The parameter `size` sets the size (float) of each box side (default 1)
  66465. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66466. * * 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)
  66467. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66469. * * 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
  66470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66471. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66472. * @param name defines the name of the mesh
  66473. * @param options defines the options used to create the mesh
  66474. * @param scene defines the hosting scene
  66475. * @returns the box mesh
  66476. */
  66477. static CreateBox(name: string, options: {
  66478. size?: number;
  66479. width?: number;
  66480. height?: number;
  66481. depth?: number;
  66482. faceUV?: Vector4[];
  66483. faceColors?: Color4[];
  66484. sideOrientation?: number;
  66485. frontUVs?: Vector4;
  66486. backUVs?: Vector4;
  66487. wrap?: boolean;
  66488. topBaseAt?: number;
  66489. bottomBaseAt?: number;
  66490. updatable?: boolean;
  66491. }, scene?: Nullable<Scene>): Mesh;
  66492. /**
  66493. * Creates a tiled box mesh
  66494. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66496. * @param name defines the name of the mesh
  66497. * @param options defines the options used to create the mesh
  66498. * @param scene defines the hosting scene
  66499. * @returns the tiled box mesh
  66500. */
  66501. static CreateTiledBox(name: string, options: {
  66502. pattern?: number;
  66503. size?: number;
  66504. width?: number;
  66505. height?: number;
  66506. depth: number;
  66507. tileSize?: number;
  66508. tileWidth?: number;
  66509. tileHeight?: number;
  66510. faceUV?: Vector4[];
  66511. faceColors?: Color4[];
  66512. alignHorizontal?: number;
  66513. alignVertical?: number;
  66514. sideOrientation?: number;
  66515. updatable?: boolean;
  66516. }, scene?: Nullable<Scene>): Mesh;
  66517. /**
  66518. * Creates a sphere mesh
  66519. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66520. * * 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`)
  66521. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66522. * * 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
  66523. * * 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)
  66524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66525. * * 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
  66526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66527. * @param name defines the name of the mesh
  66528. * @param options defines the options used to create the mesh
  66529. * @param scene defines the hosting scene
  66530. * @returns the sphere mesh
  66531. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66532. */
  66533. static CreateSphere(name: string, options: {
  66534. segments?: number;
  66535. diameter?: number;
  66536. diameterX?: number;
  66537. diameterY?: number;
  66538. diameterZ?: number;
  66539. arc?: number;
  66540. slice?: number;
  66541. sideOrientation?: number;
  66542. frontUVs?: Vector4;
  66543. backUVs?: Vector4;
  66544. updatable?: boolean;
  66545. }, scene?: Nullable<Scene>): Mesh;
  66546. /**
  66547. * Creates a plane polygonal mesh. By default, this is a disc
  66548. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66549. * * 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
  66550. * * 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
  66551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66552. * * 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
  66553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66554. * @param name defines the name of the mesh
  66555. * @param options defines the options used to create the mesh
  66556. * @param scene defines the hosting scene
  66557. * @returns the plane polygonal mesh
  66558. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66559. */
  66560. static CreateDisc(name: string, options: {
  66561. radius?: number;
  66562. tessellation?: number;
  66563. arc?: number;
  66564. updatable?: boolean;
  66565. sideOrientation?: number;
  66566. frontUVs?: Vector4;
  66567. backUVs?: Vector4;
  66568. }, scene?: Nullable<Scene>): Mesh;
  66569. /**
  66570. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66571. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66572. * * 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`)
  66573. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66574. * * 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
  66575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66576. * * 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
  66577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66578. * @param name defines the name of the mesh
  66579. * @param options defines the options used to create the mesh
  66580. * @param scene defines the hosting scene
  66581. * @returns the icosahedron mesh
  66582. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66583. */
  66584. static CreateIcoSphere(name: string, options: {
  66585. radius?: number;
  66586. radiusX?: number;
  66587. radiusY?: number;
  66588. radiusZ?: number;
  66589. flat?: boolean;
  66590. subdivisions?: number;
  66591. sideOrientation?: number;
  66592. frontUVs?: Vector4;
  66593. backUVs?: Vector4;
  66594. updatable?: boolean;
  66595. }, scene?: Nullable<Scene>): Mesh;
  66596. /**
  66597. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66598. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66599. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66600. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66601. * * 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
  66602. * * 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
  66603. * * 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
  66604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66605. * * 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
  66606. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66607. * * 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
  66608. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66609. * * 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
  66610. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66612. * @param name defines the name of the mesh
  66613. * @param options defines the options used to create the mesh
  66614. * @param scene defines the hosting scene
  66615. * @returns the ribbon mesh
  66616. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66617. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66618. */
  66619. static CreateRibbon(name: string, options: {
  66620. pathArray: Vector3[][];
  66621. closeArray?: boolean;
  66622. closePath?: boolean;
  66623. offset?: number;
  66624. updatable?: boolean;
  66625. sideOrientation?: number;
  66626. frontUVs?: Vector4;
  66627. backUVs?: Vector4;
  66628. instance?: Mesh;
  66629. invertUV?: boolean;
  66630. uvs?: Vector2[];
  66631. colors?: Color4[];
  66632. }, scene?: Nullable<Scene>): Mesh;
  66633. /**
  66634. * Creates a cylinder or a cone mesh
  66635. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66636. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66637. * * 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.
  66638. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66639. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66640. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66641. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66642. * * 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).
  66643. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66644. * * 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).
  66645. * * 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
  66646. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66647. * * 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
  66648. * * 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.
  66649. * * If `enclose` is false, a ring surface is one element.
  66650. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66651. * * 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
  66652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66653. * * 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
  66654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66655. * @param name defines the name of the mesh
  66656. * @param options defines the options used to create the mesh
  66657. * @param scene defines the hosting scene
  66658. * @returns the cylinder mesh
  66659. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66660. */
  66661. static CreateCylinder(name: string, options: {
  66662. height?: number;
  66663. diameterTop?: number;
  66664. diameterBottom?: number;
  66665. diameter?: number;
  66666. tessellation?: number;
  66667. subdivisions?: number;
  66668. arc?: number;
  66669. faceColors?: Color4[];
  66670. faceUV?: Vector4[];
  66671. updatable?: boolean;
  66672. hasRings?: boolean;
  66673. enclose?: boolean;
  66674. cap?: number;
  66675. sideOrientation?: number;
  66676. frontUVs?: Vector4;
  66677. backUVs?: Vector4;
  66678. }, scene?: Nullable<Scene>): Mesh;
  66679. /**
  66680. * Creates a torus mesh
  66681. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66682. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66683. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66685. * * 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
  66686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66687. * @param name defines the name of the mesh
  66688. * @param options defines the options used to create the mesh
  66689. * @param scene defines the hosting scene
  66690. * @returns the torus mesh
  66691. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66692. */
  66693. static CreateTorus(name: string, options: {
  66694. diameter?: number;
  66695. thickness?: number;
  66696. tessellation?: number;
  66697. updatable?: boolean;
  66698. sideOrientation?: number;
  66699. frontUVs?: Vector4;
  66700. backUVs?: Vector4;
  66701. }, scene?: Nullable<Scene>): Mesh;
  66702. /**
  66703. * Creates a torus knot mesh
  66704. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66705. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66706. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66707. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66709. * * 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
  66710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66711. * @param name defines the name of the mesh
  66712. * @param options defines the options used to create the mesh
  66713. * @param scene defines the hosting scene
  66714. * @returns the torus knot mesh
  66715. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66716. */
  66717. static CreateTorusKnot(name: string, options: {
  66718. radius?: number;
  66719. tube?: number;
  66720. radialSegments?: number;
  66721. tubularSegments?: number;
  66722. p?: number;
  66723. q?: number;
  66724. updatable?: boolean;
  66725. sideOrientation?: number;
  66726. frontUVs?: Vector4;
  66727. backUVs?: Vector4;
  66728. }, scene?: Nullable<Scene>): Mesh;
  66729. /**
  66730. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66731. * * 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
  66732. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66733. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66734. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66735. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66736. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66737. * * 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
  66738. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66741. * @param name defines the name of the new line system
  66742. * @param options defines the options used to create the line system
  66743. * @param scene defines the hosting scene
  66744. * @returns a new line system mesh
  66745. */
  66746. static CreateLineSystem(name: string, options: {
  66747. lines: Vector3[][];
  66748. updatable?: boolean;
  66749. instance?: Nullable<LinesMesh>;
  66750. colors?: Nullable<Color4[][]>;
  66751. useVertexAlpha?: boolean;
  66752. }, scene: Nullable<Scene>): LinesMesh;
  66753. /**
  66754. * Creates a line mesh
  66755. * 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
  66756. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66757. * * The parameter `points` is an array successive Vector3
  66758. * * 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
  66759. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66760. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66761. * * When updating an instance, remember that only point positions can change, not the number of points
  66762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66764. * @param name defines the name of the new line system
  66765. * @param options defines the options used to create the line system
  66766. * @param scene defines the hosting scene
  66767. * @returns a new line mesh
  66768. */
  66769. static CreateLines(name: string, options: {
  66770. points: Vector3[];
  66771. updatable?: boolean;
  66772. instance?: Nullable<LinesMesh>;
  66773. colors?: Color4[];
  66774. useVertexAlpha?: boolean;
  66775. }, scene?: Nullable<Scene>): LinesMesh;
  66776. /**
  66777. * Creates a dashed line mesh
  66778. * * 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
  66779. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66780. * * The parameter `points` is an array successive Vector3
  66781. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66782. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66783. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66784. * * 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
  66785. * * When updating an instance, remember that only point positions can change, not the number of points
  66786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66787. * @param name defines the name of the mesh
  66788. * @param options defines the options used to create the mesh
  66789. * @param scene defines the hosting scene
  66790. * @returns the dashed line mesh
  66791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66792. */
  66793. static CreateDashedLines(name: string, options: {
  66794. points: Vector3[];
  66795. dashSize?: number;
  66796. gapSize?: number;
  66797. dashNb?: number;
  66798. updatable?: boolean;
  66799. instance?: LinesMesh;
  66800. }, scene?: Nullable<Scene>): LinesMesh;
  66801. /**
  66802. * 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.
  66803. * * 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.
  66804. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66805. * * 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.
  66806. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66807. * * 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
  66808. * * 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
  66809. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66811. * * 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
  66812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66814. * @param name defines the name of the mesh
  66815. * @param options defines the options used to create the mesh
  66816. * @param scene defines the hosting scene
  66817. * @returns the extruded shape mesh
  66818. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66820. */
  66821. static ExtrudeShape(name: string, options: {
  66822. shape: Vector3[];
  66823. path: Vector3[];
  66824. scale?: number;
  66825. rotation?: number;
  66826. cap?: number;
  66827. updatable?: boolean;
  66828. sideOrientation?: number;
  66829. frontUVs?: Vector4;
  66830. backUVs?: Vector4;
  66831. instance?: Mesh;
  66832. invertUV?: boolean;
  66833. }, scene?: Nullable<Scene>): Mesh;
  66834. /**
  66835. * Creates an custom extruded shape mesh.
  66836. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66837. * * 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.
  66838. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66839. * * 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
  66840. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66841. * * 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
  66842. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66843. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66844. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66845. * * 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
  66846. * * 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
  66847. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66849. * * 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
  66850. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66852. * @param name defines the name of the mesh
  66853. * @param options defines the options used to create the mesh
  66854. * @param scene defines the hosting scene
  66855. * @returns the custom extruded shape mesh
  66856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66857. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66859. */
  66860. static ExtrudeShapeCustom(name: string, options: {
  66861. shape: Vector3[];
  66862. path: Vector3[];
  66863. scaleFunction?: any;
  66864. rotationFunction?: any;
  66865. ribbonCloseArray?: boolean;
  66866. ribbonClosePath?: boolean;
  66867. cap?: number;
  66868. updatable?: boolean;
  66869. sideOrientation?: number;
  66870. frontUVs?: Vector4;
  66871. backUVs?: Vector4;
  66872. instance?: Mesh;
  66873. invertUV?: boolean;
  66874. }, scene?: Nullable<Scene>): Mesh;
  66875. /**
  66876. * Creates lathe mesh.
  66877. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66878. * * 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
  66879. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66880. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66881. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66882. * * 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
  66883. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66884. * * 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
  66885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66886. * * 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
  66887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66889. * @param name defines the name of the mesh
  66890. * @param options defines the options used to create the mesh
  66891. * @param scene defines the hosting scene
  66892. * @returns the lathe mesh
  66893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66894. */
  66895. static CreateLathe(name: string, options: {
  66896. shape: Vector3[];
  66897. radius?: number;
  66898. tessellation?: number;
  66899. clip?: number;
  66900. arc?: number;
  66901. closed?: boolean;
  66902. updatable?: boolean;
  66903. sideOrientation?: number;
  66904. frontUVs?: Vector4;
  66905. backUVs?: Vector4;
  66906. cap?: number;
  66907. invertUV?: boolean;
  66908. }, scene?: Nullable<Scene>): Mesh;
  66909. /**
  66910. * Creates a tiled plane mesh
  66911. * * You can set a limited pattern arrangement with the tiles
  66912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66913. * * 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
  66914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66915. * @param name defines the name of the mesh
  66916. * @param options defines the options used to create the mesh
  66917. * @param scene defines the hosting scene
  66918. * @returns the plane mesh
  66919. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66920. */
  66921. static CreateTiledPlane(name: string, options: {
  66922. pattern?: number;
  66923. tileSize?: number;
  66924. tileWidth?: number;
  66925. tileHeight?: number;
  66926. size?: number;
  66927. width?: number;
  66928. height?: number;
  66929. alignHorizontal?: number;
  66930. alignVertical?: number;
  66931. sideOrientation?: number;
  66932. frontUVs?: Vector4;
  66933. backUVs?: Vector4;
  66934. updatable?: boolean;
  66935. }, scene?: Nullable<Scene>): Mesh;
  66936. /**
  66937. * Creates a plane mesh
  66938. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66939. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66940. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66942. * * 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
  66943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66944. * @param name defines the name of the mesh
  66945. * @param options defines the options used to create the mesh
  66946. * @param scene defines the hosting scene
  66947. * @returns the plane mesh
  66948. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66949. */
  66950. static CreatePlane(name: string, options: {
  66951. size?: number;
  66952. width?: number;
  66953. height?: number;
  66954. sideOrientation?: number;
  66955. frontUVs?: Vector4;
  66956. backUVs?: Vector4;
  66957. updatable?: boolean;
  66958. sourcePlane?: Plane;
  66959. }, scene?: Nullable<Scene>): Mesh;
  66960. /**
  66961. * Creates a ground mesh
  66962. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66963. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66965. * @param name defines the name of the mesh
  66966. * @param options defines the options used to create the mesh
  66967. * @param scene defines the hosting scene
  66968. * @returns the ground mesh
  66969. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66970. */
  66971. static CreateGround(name: string, options: {
  66972. width?: number;
  66973. height?: number;
  66974. subdivisions?: number;
  66975. subdivisionsX?: number;
  66976. subdivisionsY?: number;
  66977. updatable?: boolean;
  66978. }, scene?: Nullable<Scene>): Mesh;
  66979. /**
  66980. * Creates a tiled ground mesh
  66981. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66982. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66983. * * 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
  66984. * * 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
  66985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66986. * @param name defines the name of the mesh
  66987. * @param options defines the options used to create the mesh
  66988. * @param scene defines the hosting scene
  66989. * @returns the tiled ground mesh
  66990. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66991. */
  66992. static CreateTiledGround(name: string, options: {
  66993. xmin: number;
  66994. zmin: number;
  66995. xmax: number;
  66996. zmax: number;
  66997. subdivisions?: {
  66998. w: number;
  66999. h: number;
  67000. };
  67001. precision?: {
  67002. w: number;
  67003. h: number;
  67004. };
  67005. updatable?: boolean;
  67006. }, scene?: Nullable<Scene>): Mesh;
  67007. /**
  67008. * Creates a ground mesh from a height map
  67009. * * The parameter `url` sets the URL of the height map image resource.
  67010. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67011. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67012. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67013. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67014. * * 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.
  67015. * * 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).
  67016. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67018. * @param name defines the name of the mesh
  67019. * @param url defines the url to the height map
  67020. * @param options defines the options used to create the mesh
  67021. * @param scene defines the hosting scene
  67022. * @returns the ground mesh
  67023. * @see https://doc.babylonjs.com/babylon101/height_map
  67024. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67025. */
  67026. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67027. width?: number;
  67028. height?: number;
  67029. subdivisions?: number;
  67030. minHeight?: number;
  67031. maxHeight?: number;
  67032. colorFilter?: Color3;
  67033. alphaFilter?: number;
  67034. updatable?: boolean;
  67035. onReady?: (mesh: GroundMesh) => void;
  67036. }, scene?: Nullable<Scene>): GroundMesh;
  67037. /**
  67038. * Creates a polygon mesh
  67039. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67040. * * 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
  67041. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67043. * * 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)
  67044. * * Remember you can only change the shape positions, not their number when updating a polygon
  67045. * @param name defines the name of the mesh
  67046. * @param options defines the options used to create the mesh
  67047. * @param scene defines the hosting scene
  67048. * @param earcutInjection can be used to inject your own earcut reference
  67049. * @returns the polygon mesh
  67050. */
  67051. static CreatePolygon(name: string, options: {
  67052. shape: Vector3[];
  67053. holes?: Vector3[][];
  67054. depth?: number;
  67055. faceUV?: Vector4[];
  67056. faceColors?: Color4[];
  67057. updatable?: boolean;
  67058. sideOrientation?: number;
  67059. frontUVs?: Vector4;
  67060. backUVs?: Vector4;
  67061. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67062. /**
  67063. * Creates an extruded polygon mesh, with depth in the Y direction.
  67064. * * 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)
  67065. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67066. * @param name defines the name of the mesh
  67067. * @param options defines the options used to create the mesh
  67068. * @param scene defines the hosting scene
  67069. * @param earcutInjection can be used to inject your own earcut reference
  67070. * @returns the polygon mesh
  67071. */
  67072. static ExtrudePolygon(name: string, options: {
  67073. shape: Vector3[];
  67074. holes?: Vector3[][];
  67075. depth?: number;
  67076. faceUV?: Vector4[];
  67077. faceColors?: Color4[];
  67078. updatable?: boolean;
  67079. sideOrientation?: number;
  67080. frontUVs?: Vector4;
  67081. backUVs?: Vector4;
  67082. wrap?: boolean;
  67083. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67084. /**
  67085. * Creates a tube mesh.
  67086. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67087. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67088. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67089. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67090. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67091. * * 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)
  67092. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67093. * * 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
  67094. * * 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
  67095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67096. * * 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
  67097. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67099. * @param name defines the name of the mesh
  67100. * @param options defines the options used to create the mesh
  67101. * @param scene defines the hosting scene
  67102. * @returns the tube mesh
  67103. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67104. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67105. */
  67106. static CreateTube(name: string, options: {
  67107. path: Vector3[];
  67108. radius?: number;
  67109. tessellation?: number;
  67110. radiusFunction?: {
  67111. (i: number, distance: number): number;
  67112. };
  67113. cap?: number;
  67114. arc?: number;
  67115. updatable?: boolean;
  67116. sideOrientation?: number;
  67117. frontUVs?: Vector4;
  67118. backUVs?: Vector4;
  67119. instance?: Mesh;
  67120. invertUV?: boolean;
  67121. }, scene?: Nullable<Scene>): Mesh;
  67122. /**
  67123. * Creates a polyhedron mesh
  67124. * * 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
  67125. * * The parameter `size` (positive float, default 1) sets the polygon size
  67126. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67127. * * 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`
  67128. * * 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
  67129. * * 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)`)
  67130. * * 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
  67131. * * 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
  67132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67133. * * 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
  67134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67135. * @param name defines the name of the mesh
  67136. * @param options defines the options used to create the mesh
  67137. * @param scene defines the hosting scene
  67138. * @returns the polyhedron mesh
  67139. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67140. */
  67141. static CreatePolyhedron(name: string, options: {
  67142. type?: number;
  67143. size?: number;
  67144. sizeX?: number;
  67145. sizeY?: number;
  67146. sizeZ?: number;
  67147. custom?: any;
  67148. faceUV?: Vector4[];
  67149. faceColors?: Color4[];
  67150. flat?: boolean;
  67151. updatable?: boolean;
  67152. sideOrientation?: number;
  67153. frontUVs?: Vector4;
  67154. backUVs?: Vector4;
  67155. }, scene?: Nullable<Scene>): Mesh;
  67156. /**
  67157. * Creates a decal mesh.
  67158. * 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
  67159. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67160. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67161. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67162. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67163. * @param name defines the name of the mesh
  67164. * @param sourceMesh defines the mesh where the decal must be applied
  67165. * @param options defines the options used to create the mesh
  67166. * @param scene defines the hosting scene
  67167. * @returns the decal mesh
  67168. * @see https://doc.babylonjs.com/how_to/decals
  67169. */
  67170. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67171. position?: Vector3;
  67172. normal?: Vector3;
  67173. size?: Vector3;
  67174. angle?: number;
  67175. }): Mesh;
  67176. /**
  67177. * Creates a Capsule Mesh
  67178. * @param name defines the name of the mesh.
  67179. * @param options the constructors options used to shape the mesh.
  67180. * @param scene defines the scene the mesh is scoped to.
  67181. * @returns the capsule mesh
  67182. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67183. */
  67184. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67185. }
  67186. }
  67187. declare module BABYLON {
  67188. /**
  67189. * A simplifier interface for future simplification implementations
  67190. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67191. */
  67192. export interface ISimplifier {
  67193. /**
  67194. * Simplification of a given mesh according to the given settings.
  67195. * Since this requires computation, it is assumed that the function runs async.
  67196. * @param settings The settings of the simplification, including quality and distance
  67197. * @param successCallback A callback that will be called after the mesh was simplified.
  67198. * @param errorCallback in case of an error, this callback will be called. optional.
  67199. */
  67200. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67201. }
  67202. /**
  67203. * Expected simplification settings.
  67204. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67205. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67206. */
  67207. export interface ISimplificationSettings {
  67208. /**
  67209. * Gets or sets the expected quality
  67210. */
  67211. quality: number;
  67212. /**
  67213. * Gets or sets the distance when this optimized version should be used
  67214. */
  67215. distance: number;
  67216. /**
  67217. * Gets an already optimized mesh
  67218. */
  67219. optimizeMesh?: boolean;
  67220. }
  67221. /**
  67222. * Class used to specify simplification options
  67223. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67224. */
  67225. export class SimplificationSettings implements ISimplificationSettings {
  67226. /** expected quality */
  67227. quality: number;
  67228. /** distance when this optimized version should be used */
  67229. distance: number;
  67230. /** already optimized mesh */
  67231. optimizeMesh?: boolean | undefined;
  67232. /**
  67233. * Creates a SimplificationSettings
  67234. * @param quality expected quality
  67235. * @param distance distance when this optimized version should be used
  67236. * @param optimizeMesh already optimized mesh
  67237. */
  67238. constructor(
  67239. /** expected quality */
  67240. quality: number,
  67241. /** distance when this optimized version should be used */
  67242. distance: number,
  67243. /** already optimized mesh */
  67244. optimizeMesh?: boolean | undefined);
  67245. }
  67246. /**
  67247. * Interface used to define a simplification task
  67248. */
  67249. export interface ISimplificationTask {
  67250. /**
  67251. * Array of settings
  67252. */
  67253. settings: Array<ISimplificationSettings>;
  67254. /**
  67255. * Simplification type
  67256. */
  67257. simplificationType: SimplificationType;
  67258. /**
  67259. * Mesh to simplify
  67260. */
  67261. mesh: Mesh;
  67262. /**
  67263. * Callback called on success
  67264. */
  67265. successCallback?: () => void;
  67266. /**
  67267. * Defines if parallel processing can be used
  67268. */
  67269. parallelProcessing: boolean;
  67270. }
  67271. /**
  67272. * Queue used to order the simplification tasks
  67273. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67274. */
  67275. export class SimplificationQueue {
  67276. private _simplificationArray;
  67277. /**
  67278. * Gets a boolean indicating that the process is still running
  67279. */
  67280. running: boolean;
  67281. /**
  67282. * Creates a new queue
  67283. */
  67284. constructor();
  67285. /**
  67286. * Adds a new simplification task
  67287. * @param task defines a task to add
  67288. */
  67289. addTask(task: ISimplificationTask): void;
  67290. /**
  67291. * Execute next task
  67292. */
  67293. executeNext(): void;
  67294. /**
  67295. * Execute a simplification task
  67296. * @param task defines the task to run
  67297. */
  67298. runSimplification(task: ISimplificationTask): void;
  67299. private getSimplifier;
  67300. }
  67301. /**
  67302. * The implemented types of simplification
  67303. * At the moment only Quadratic Error Decimation is implemented
  67304. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67305. */
  67306. export enum SimplificationType {
  67307. /** Quadratic error decimation */
  67308. QUADRATIC = 0
  67309. }
  67310. /**
  67311. * An implementation of the Quadratic Error simplification algorithm.
  67312. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67313. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67314. * @author RaananW
  67315. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67316. */
  67317. export class QuadraticErrorSimplification implements ISimplifier {
  67318. private _mesh;
  67319. private triangles;
  67320. private vertices;
  67321. private references;
  67322. private _reconstructedMesh;
  67323. /** Gets or sets the number pf sync interations */
  67324. syncIterations: number;
  67325. /** Gets or sets the aggressiveness of the simplifier */
  67326. aggressiveness: number;
  67327. /** Gets or sets the number of allowed iterations for decimation */
  67328. decimationIterations: number;
  67329. /** Gets or sets the espilon to use for bounding box computation */
  67330. boundingBoxEpsilon: number;
  67331. /**
  67332. * Creates a new QuadraticErrorSimplification
  67333. * @param _mesh defines the target mesh
  67334. */
  67335. constructor(_mesh: Mesh);
  67336. /**
  67337. * Simplification of a given mesh according to the given settings.
  67338. * Since this requires computation, it is assumed that the function runs async.
  67339. * @param settings The settings of the simplification, including quality and distance
  67340. * @param successCallback A callback that will be called after the mesh was simplified.
  67341. */
  67342. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67343. private runDecimation;
  67344. private initWithMesh;
  67345. private init;
  67346. private reconstructMesh;
  67347. private initDecimatedMesh;
  67348. private isFlipped;
  67349. private updateTriangles;
  67350. private identifyBorder;
  67351. private updateMesh;
  67352. private vertexError;
  67353. private calculateError;
  67354. }
  67355. }
  67356. declare module BABYLON {
  67357. interface Scene {
  67358. /** @hidden (Backing field) */
  67359. _simplificationQueue: SimplificationQueue;
  67360. /**
  67361. * Gets or sets the simplification queue attached to the scene
  67362. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67363. */
  67364. simplificationQueue: SimplificationQueue;
  67365. }
  67366. interface Mesh {
  67367. /**
  67368. * Simplify the mesh according to the given array of settings.
  67369. * Function will return immediately and will simplify async
  67370. * @param settings a collection of simplification settings
  67371. * @param parallelProcessing should all levels calculate parallel or one after the other
  67372. * @param simplificationType the type of simplification to run
  67373. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67374. * @returns the current mesh
  67375. */
  67376. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67377. }
  67378. /**
  67379. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67380. * created in a scene
  67381. */
  67382. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67383. /**
  67384. * The component name helpfull to identify the component in the list of scene components.
  67385. */
  67386. readonly name: string;
  67387. /**
  67388. * The scene the component belongs to.
  67389. */
  67390. scene: Scene;
  67391. /**
  67392. * Creates a new instance of the component for the given scene
  67393. * @param scene Defines the scene to register the component in
  67394. */
  67395. constructor(scene: Scene);
  67396. /**
  67397. * Registers the component in a given scene
  67398. */
  67399. register(): void;
  67400. /**
  67401. * Rebuilds the elements related to this component in case of
  67402. * context lost for instance.
  67403. */
  67404. rebuild(): void;
  67405. /**
  67406. * Disposes the component and the associated ressources
  67407. */
  67408. dispose(): void;
  67409. private _beforeCameraUpdate;
  67410. }
  67411. }
  67412. declare module BABYLON {
  67413. interface Mesh {
  67414. /**
  67415. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67416. */
  67417. thinInstanceEnablePicking: boolean;
  67418. /**
  67419. * Creates a new thin instance
  67420. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67421. * @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
  67422. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67423. */
  67424. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67425. /**
  67426. * Adds the transformation (matrix) of the current mesh as a thin instance
  67427. * @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
  67428. * @returns the thin instance index number
  67429. */
  67430. thinInstanceAddSelf(refresh: boolean): number;
  67431. /**
  67432. * Registers a custom attribute to be used with thin instances
  67433. * @param kind name of the attribute
  67434. * @param stride size in floats of the attribute
  67435. */
  67436. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67437. /**
  67438. * Sets the matrix of a thin instance
  67439. * @param index index of the thin instance
  67440. * @param matrix matrix to set
  67441. * @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
  67442. */
  67443. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67444. /**
  67445. * Sets the value of a custom attribute for a thin instance
  67446. * @param kind name of the attribute
  67447. * @param index index of the thin instance
  67448. * @param value value to set
  67449. * @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
  67450. */
  67451. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67452. /**
  67453. * 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.
  67454. */
  67455. thinInstanceCount: number;
  67456. /**
  67457. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67458. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67459. * @param buffer buffer to set
  67460. * @param stride size in floats of each value of the buffer
  67461. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67462. */
  67463. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67464. /**
  67465. * Gets the list of world matrices
  67466. * @return an array containing all the world matrices from the thin instances
  67467. */
  67468. thinInstanceGetWorldMatrices(): Matrix[];
  67469. /**
  67470. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67471. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67472. */
  67473. thinInstanceBufferUpdated(kind: string): void;
  67474. /**
  67475. * Applies a partial update to a buffer directly on the GPU
  67476. * 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
  67477. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67478. * @param data the data to set in the GPU buffer
  67479. * @param offset the offset in the GPU buffer where to update the data
  67480. */
  67481. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67482. /**
  67483. * Refreshes the bounding info, taking into account all the thin instances defined
  67484. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67485. */
  67486. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67487. /** @hidden */
  67488. _thinInstanceInitializeUserStorage(): void;
  67489. /** @hidden */
  67490. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67491. /** @hidden */
  67492. _userThinInstanceBuffersStorage: {
  67493. data: {
  67494. [key: string]: Float32Array;
  67495. };
  67496. sizes: {
  67497. [key: string]: number;
  67498. };
  67499. vertexBuffers: {
  67500. [key: string]: Nullable<VertexBuffer>;
  67501. };
  67502. strides: {
  67503. [key: string]: number;
  67504. };
  67505. };
  67506. }
  67507. }
  67508. declare module BABYLON {
  67509. /**
  67510. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67511. */
  67512. export interface INavigationEnginePlugin {
  67513. /**
  67514. * plugin name
  67515. */
  67516. name: string;
  67517. /**
  67518. * Creates a navigation mesh
  67519. * @param meshes array of all the geometry used to compute the navigatio mesh
  67520. * @param parameters bunch of parameters used to filter geometry
  67521. */
  67522. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67523. /**
  67524. * Create a navigation mesh debug mesh
  67525. * @param scene is where the mesh will be added
  67526. * @returns debug display mesh
  67527. */
  67528. createDebugNavMesh(scene: Scene): Mesh;
  67529. /**
  67530. * Get a navigation mesh constrained position, closest to the parameter position
  67531. * @param position world position
  67532. * @returns the closest point to position constrained by the navigation mesh
  67533. */
  67534. getClosestPoint(position: Vector3): Vector3;
  67535. /**
  67536. * Get a navigation mesh constrained position, closest to the parameter position
  67537. * @param position world position
  67538. * @param result output the closest point to position constrained by the navigation mesh
  67539. */
  67540. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67541. /**
  67542. * Get a navigation mesh constrained position, within a particular radius
  67543. * @param position world position
  67544. * @param maxRadius the maximum distance to the constrained world position
  67545. * @returns the closest point to position constrained by the navigation mesh
  67546. */
  67547. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67548. /**
  67549. * Get a navigation mesh constrained position, within a particular radius
  67550. * @param position world position
  67551. * @param maxRadius the maximum distance to the constrained world position
  67552. * @param result output the closest point to position constrained by the navigation mesh
  67553. */
  67554. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67555. /**
  67556. * Compute the final position from a segment made of destination-position
  67557. * @param position world position
  67558. * @param destination world position
  67559. * @returns the resulting point along the navmesh
  67560. */
  67561. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67562. /**
  67563. * Compute the final position from a segment made of destination-position
  67564. * @param position world position
  67565. * @param destination world position
  67566. * @param result output the resulting point along the navmesh
  67567. */
  67568. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67569. /**
  67570. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67571. * @param start world position
  67572. * @param end world position
  67573. * @returns array containing world position composing the path
  67574. */
  67575. computePath(start: Vector3, end: Vector3): Vector3[];
  67576. /**
  67577. * If this plugin is supported
  67578. * @returns true if plugin is supported
  67579. */
  67580. isSupported(): boolean;
  67581. /**
  67582. * Create a new Crowd so you can add agents
  67583. * @param maxAgents the maximum agent count in the crowd
  67584. * @param maxAgentRadius the maximum radius an agent can have
  67585. * @param scene to attach the crowd to
  67586. * @returns the crowd you can add agents to
  67587. */
  67588. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67589. /**
  67590. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67591. * The queries will try to find a solution within those bounds
  67592. * default is (1,1,1)
  67593. * @param extent x,y,z value that define the extent around the queries point of reference
  67594. */
  67595. setDefaultQueryExtent(extent: Vector3): void;
  67596. /**
  67597. * Get the Bounding box extent specified by setDefaultQueryExtent
  67598. * @returns the box extent values
  67599. */
  67600. getDefaultQueryExtent(): Vector3;
  67601. /**
  67602. * build the navmesh from a previously saved state using getNavmeshData
  67603. * @param data the Uint8Array returned by getNavmeshData
  67604. */
  67605. buildFromNavmeshData(data: Uint8Array): void;
  67606. /**
  67607. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67608. * @returns data the Uint8Array that can be saved and reused
  67609. */
  67610. getNavmeshData(): Uint8Array;
  67611. /**
  67612. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67613. * @param result output the box extent values
  67614. */
  67615. getDefaultQueryExtentToRef(result: Vector3): void;
  67616. /**
  67617. * Release all resources
  67618. */
  67619. dispose(): void;
  67620. }
  67621. /**
  67622. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67623. */
  67624. export interface ICrowd {
  67625. /**
  67626. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67627. * You can attach anything to that node. The node position is updated in the scene update tick.
  67628. * @param pos world position that will be constrained by the navigation mesh
  67629. * @param parameters agent parameters
  67630. * @param transform hooked to the agent that will be update by the scene
  67631. * @returns agent index
  67632. */
  67633. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67634. /**
  67635. * Returns the agent position in world space
  67636. * @param index agent index returned by addAgent
  67637. * @returns world space position
  67638. */
  67639. getAgentPosition(index: number): Vector3;
  67640. /**
  67641. * Gets the agent position result in world space
  67642. * @param index agent index returned by addAgent
  67643. * @param result output world space position
  67644. */
  67645. getAgentPositionToRef(index: number, result: Vector3): void;
  67646. /**
  67647. * Gets the agent velocity in world space
  67648. * @param index agent index returned by addAgent
  67649. * @returns world space velocity
  67650. */
  67651. getAgentVelocity(index: number): Vector3;
  67652. /**
  67653. * Gets the agent velocity result in world space
  67654. * @param index agent index returned by addAgent
  67655. * @param result output world space velocity
  67656. */
  67657. getAgentVelocityToRef(index: number, result: Vector3): void;
  67658. /**
  67659. * remove a particular agent previously created
  67660. * @param index agent index returned by addAgent
  67661. */
  67662. removeAgent(index: number): void;
  67663. /**
  67664. * get the list of all agents attached to this crowd
  67665. * @returns list of agent indices
  67666. */
  67667. getAgents(): number[];
  67668. /**
  67669. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67670. * @param deltaTime in seconds
  67671. */
  67672. update(deltaTime: number): void;
  67673. /**
  67674. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67675. * @param index agent index returned by addAgent
  67676. * @param destination targeted world position
  67677. */
  67678. agentGoto(index: number, destination: Vector3): void;
  67679. /**
  67680. * Teleport the agent to a new position
  67681. * @param index agent index returned by addAgent
  67682. * @param destination targeted world position
  67683. */
  67684. agentTeleport(index: number, destination: Vector3): void;
  67685. /**
  67686. * Update agent parameters
  67687. * @param index agent index returned by addAgent
  67688. * @param parameters agent parameters
  67689. */
  67690. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67691. /**
  67692. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67693. * The queries will try to find a solution within those bounds
  67694. * default is (1,1,1)
  67695. * @param extent x,y,z value that define the extent around the queries point of reference
  67696. */
  67697. setDefaultQueryExtent(extent: Vector3): void;
  67698. /**
  67699. * Get the Bounding box extent specified by setDefaultQueryExtent
  67700. * @returns the box extent values
  67701. */
  67702. getDefaultQueryExtent(): Vector3;
  67703. /**
  67704. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67705. * @param result output the box extent values
  67706. */
  67707. getDefaultQueryExtentToRef(result: Vector3): void;
  67708. /**
  67709. * Release all resources
  67710. */
  67711. dispose(): void;
  67712. }
  67713. /**
  67714. * Configures an agent
  67715. */
  67716. export interface IAgentParameters {
  67717. /**
  67718. * Agent radius. [Limit: >= 0]
  67719. */
  67720. radius: number;
  67721. /**
  67722. * Agent height. [Limit: > 0]
  67723. */
  67724. height: number;
  67725. /**
  67726. * Maximum allowed acceleration. [Limit: >= 0]
  67727. */
  67728. maxAcceleration: number;
  67729. /**
  67730. * Maximum allowed speed. [Limit: >= 0]
  67731. */
  67732. maxSpeed: number;
  67733. /**
  67734. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67735. */
  67736. collisionQueryRange: number;
  67737. /**
  67738. * The path visibility optimization range. [Limit: > 0]
  67739. */
  67740. pathOptimizationRange: number;
  67741. /**
  67742. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67743. */
  67744. separationWeight: number;
  67745. }
  67746. /**
  67747. * Configures the navigation mesh creation
  67748. */
  67749. export interface INavMeshParameters {
  67750. /**
  67751. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67752. */
  67753. cs: number;
  67754. /**
  67755. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67756. */
  67757. ch: number;
  67758. /**
  67759. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67760. */
  67761. walkableSlopeAngle: number;
  67762. /**
  67763. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67764. * be considered walkable. [Limit: >= 3] [Units: vx]
  67765. */
  67766. walkableHeight: number;
  67767. /**
  67768. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67769. */
  67770. walkableClimb: number;
  67771. /**
  67772. * The distance to erode/shrink the walkable area of the heightfield away from
  67773. * obstructions. [Limit: >=0] [Units: vx]
  67774. */
  67775. walkableRadius: number;
  67776. /**
  67777. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67778. */
  67779. maxEdgeLen: number;
  67780. /**
  67781. * The maximum distance a simplfied contour's border edges should deviate
  67782. * the original raw contour. [Limit: >=0] [Units: vx]
  67783. */
  67784. maxSimplificationError: number;
  67785. /**
  67786. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67787. */
  67788. minRegionArea: number;
  67789. /**
  67790. * Any regions with a span count smaller than this value will, if possible,
  67791. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67792. */
  67793. mergeRegionArea: number;
  67794. /**
  67795. * The maximum number of vertices allowed for polygons generated during the
  67796. * contour to polygon conversion process. [Limit: >= 3]
  67797. */
  67798. maxVertsPerPoly: number;
  67799. /**
  67800. * Sets the sampling distance to use when generating the detail mesh.
  67801. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67802. */
  67803. detailSampleDist: number;
  67804. /**
  67805. * The maximum distance the detail mesh surface should deviate from heightfield
  67806. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67807. */
  67808. detailSampleMaxError: number;
  67809. }
  67810. }
  67811. declare module BABYLON {
  67812. /**
  67813. * RecastJS navigation plugin
  67814. */
  67815. export class RecastJSPlugin implements INavigationEnginePlugin {
  67816. /**
  67817. * Reference to the Recast library
  67818. */
  67819. bjsRECAST: any;
  67820. /**
  67821. * plugin name
  67822. */
  67823. name: string;
  67824. /**
  67825. * the first navmesh created. We might extend this to support multiple navmeshes
  67826. */
  67827. navMesh: any;
  67828. /**
  67829. * Initializes the recastJS plugin
  67830. * @param recastInjection can be used to inject your own recast reference
  67831. */
  67832. constructor(recastInjection?: any);
  67833. /**
  67834. * Creates a navigation mesh
  67835. * @param meshes array of all the geometry used to compute the navigatio mesh
  67836. * @param parameters bunch of parameters used to filter geometry
  67837. */
  67838. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67839. /**
  67840. * Create a navigation mesh debug mesh
  67841. * @param scene is where the mesh will be added
  67842. * @returns debug display mesh
  67843. */
  67844. createDebugNavMesh(scene: Scene): Mesh;
  67845. /**
  67846. * Get a navigation mesh constrained position, closest to the parameter position
  67847. * @param position world position
  67848. * @returns the closest point to position constrained by the navigation mesh
  67849. */
  67850. getClosestPoint(position: Vector3): Vector3;
  67851. /**
  67852. * Get a navigation mesh constrained position, closest to the parameter position
  67853. * @param position world position
  67854. * @param result output the closest point to position constrained by the navigation mesh
  67855. */
  67856. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67857. /**
  67858. * Get a navigation mesh constrained position, within a particular radius
  67859. * @param position world position
  67860. * @param maxRadius the maximum distance to the constrained world position
  67861. * @returns the closest point to position constrained by the navigation mesh
  67862. */
  67863. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67864. /**
  67865. * Get a navigation mesh constrained position, within a particular radius
  67866. * @param position world position
  67867. * @param maxRadius the maximum distance to the constrained world position
  67868. * @param result output the closest point to position constrained by the navigation mesh
  67869. */
  67870. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67871. /**
  67872. * Compute the final position from a segment made of destination-position
  67873. * @param position world position
  67874. * @param destination world position
  67875. * @returns the resulting point along the navmesh
  67876. */
  67877. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67878. /**
  67879. * Compute the final position from a segment made of destination-position
  67880. * @param position world position
  67881. * @param destination world position
  67882. * @param result output the resulting point along the navmesh
  67883. */
  67884. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67885. /**
  67886. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67887. * @param start world position
  67888. * @param end world position
  67889. * @returns array containing world position composing the path
  67890. */
  67891. computePath(start: Vector3, end: Vector3): Vector3[];
  67892. /**
  67893. * Create a new Crowd so you can add agents
  67894. * @param maxAgents the maximum agent count in the crowd
  67895. * @param maxAgentRadius the maximum radius an agent can have
  67896. * @param scene to attach the crowd to
  67897. * @returns the crowd you can add agents to
  67898. */
  67899. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67900. /**
  67901. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67902. * The queries will try to find a solution within those bounds
  67903. * default is (1,1,1)
  67904. * @param extent x,y,z value that define the extent around the queries point of reference
  67905. */
  67906. setDefaultQueryExtent(extent: Vector3): void;
  67907. /**
  67908. * Get the Bounding box extent specified by setDefaultQueryExtent
  67909. * @returns the box extent values
  67910. */
  67911. getDefaultQueryExtent(): Vector3;
  67912. /**
  67913. * build the navmesh from a previously saved state using getNavmeshData
  67914. * @param data the Uint8Array returned by getNavmeshData
  67915. */
  67916. buildFromNavmeshData(data: Uint8Array): void;
  67917. /**
  67918. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67919. * @returns data the Uint8Array that can be saved and reused
  67920. */
  67921. getNavmeshData(): Uint8Array;
  67922. /**
  67923. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67924. * @param result output the box extent values
  67925. */
  67926. getDefaultQueryExtentToRef(result: Vector3): void;
  67927. /**
  67928. * Disposes
  67929. */
  67930. dispose(): void;
  67931. /**
  67932. * If this plugin is supported
  67933. * @returns true if plugin is supported
  67934. */
  67935. isSupported(): boolean;
  67936. }
  67937. /**
  67938. * Recast detour crowd implementation
  67939. */
  67940. export class RecastJSCrowd implements ICrowd {
  67941. /**
  67942. * Recast/detour plugin
  67943. */
  67944. bjsRECASTPlugin: RecastJSPlugin;
  67945. /**
  67946. * Link to the detour crowd
  67947. */
  67948. recastCrowd: any;
  67949. /**
  67950. * One transform per agent
  67951. */
  67952. transforms: TransformNode[];
  67953. /**
  67954. * All agents created
  67955. */
  67956. agents: number[];
  67957. /**
  67958. * Link to the scene is kept to unregister the crowd from the scene
  67959. */
  67960. private _scene;
  67961. /**
  67962. * Observer for crowd updates
  67963. */
  67964. private _onBeforeAnimationsObserver;
  67965. /**
  67966. * Constructor
  67967. * @param plugin recastJS plugin
  67968. * @param maxAgents the maximum agent count in the crowd
  67969. * @param maxAgentRadius the maximum radius an agent can have
  67970. * @param scene to attach the crowd to
  67971. * @returns the crowd you can add agents to
  67972. */
  67973. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67974. /**
  67975. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67976. * You can attach anything to that node. The node position is updated in the scene update tick.
  67977. * @param pos world position that will be constrained by the navigation mesh
  67978. * @param parameters agent parameters
  67979. * @param transform hooked to the agent that will be update by the scene
  67980. * @returns agent index
  67981. */
  67982. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67983. /**
  67984. * Returns the agent position in world space
  67985. * @param index agent index returned by addAgent
  67986. * @returns world space position
  67987. */
  67988. getAgentPosition(index: number): Vector3;
  67989. /**
  67990. * Returns the agent position result in world space
  67991. * @param index agent index returned by addAgent
  67992. * @param result output world space position
  67993. */
  67994. getAgentPositionToRef(index: number, result: Vector3): void;
  67995. /**
  67996. * Returns the agent velocity in world space
  67997. * @param index agent index returned by addAgent
  67998. * @returns world space velocity
  67999. */
  68000. getAgentVelocity(index: number): Vector3;
  68001. /**
  68002. * Returns the agent velocity result in world space
  68003. * @param index agent index returned by addAgent
  68004. * @param result output world space velocity
  68005. */
  68006. getAgentVelocityToRef(index: number, result: Vector3): void;
  68007. /**
  68008. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68009. * @param index agent index returned by addAgent
  68010. * @param destination targeted world position
  68011. */
  68012. agentGoto(index: number, destination: Vector3): void;
  68013. /**
  68014. * Teleport the agent to a new position
  68015. * @param index agent index returned by addAgent
  68016. * @param destination targeted world position
  68017. */
  68018. agentTeleport(index: number, destination: Vector3): void;
  68019. /**
  68020. * Update agent parameters
  68021. * @param index agent index returned by addAgent
  68022. * @param parameters agent parameters
  68023. */
  68024. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68025. /**
  68026. * remove a particular agent previously created
  68027. * @param index agent index returned by addAgent
  68028. */
  68029. removeAgent(index: number): void;
  68030. /**
  68031. * get the list of all agents attached to this crowd
  68032. * @returns list of agent indices
  68033. */
  68034. getAgents(): number[];
  68035. /**
  68036. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68037. * @param deltaTime in seconds
  68038. */
  68039. update(deltaTime: number): void;
  68040. /**
  68041. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68042. * The queries will try to find a solution within those bounds
  68043. * default is (1,1,1)
  68044. * @param extent x,y,z value that define the extent around the queries point of reference
  68045. */
  68046. setDefaultQueryExtent(extent: Vector3): void;
  68047. /**
  68048. * Get the Bounding box extent specified by setDefaultQueryExtent
  68049. * @returns the box extent values
  68050. */
  68051. getDefaultQueryExtent(): Vector3;
  68052. /**
  68053. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68054. * @param result output the box extent values
  68055. */
  68056. getDefaultQueryExtentToRef(result: Vector3): void;
  68057. /**
  68058. * Release all resources
  68059. */
  68060. dispose(): void;
  68061. }
  68062. }
  68063. declare module BABYLON {
  68064. /**
  68065. * Class used to enable access to IndexedDB
  68066. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68067. */
  68068. export class Database implements IOfflineProvider {
  68069. private _callbackManifestChecked;
  68070. private _currentSceneUrl;
  68071. private _db;
  68072. private _enableSceneOffline;
  68073. private _enableTexturesOffline;
  68074. private _manifestVersionFound;
  68075. private _mustUpdateRessources;
  68076. private _hasReachedQuota;
  68077. private _isSupported;
  68078. private _idbFactory;
  68079. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68080. private static IsUASupportingBlobStorage;
  68081. /**
  68082. * Gets a boolean indicating if Database storate is enabled (off by default)
  68083. */
  68084. static IDBStorageEnabled: boolean;
  68085. /**
  68086. * Gets a boolean indicating if scene must be saved in the database
  68087. */
  68088. get enableSceneOffline(): boolean;
  68089. /**
  68090. * Gets a boolean indicating if textures must be saved in the database
  68091. */
  68092. get enableTexturesOffline(): boolean;
  68093. /**
  68094. * Creates a new Database
  68095. * @param urlToScene defines the url to load the scene
  68096. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68097. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68098. */
  68099. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68100. private static _ParseURL;
  68101. private static _ReturnFullUrlLocation;
  68102. private _checkManifestFile;
  68103. /**
  68104. * Open the database and make it available
  68105. * @param successCallback defines the callback to call on success
  68106. * @param errorCallback defines the callback to call on error
  68107. */
  68108. open(successCallback: () => void, errorCallback: () => void): void;
  68109. /**
  68110. * Loads an image from the database
  68111. * @param url defines the url to load from
  68112. * @param image defines the target DOM image
  68113. */
  68114. loadImage(url: string, image: HTMLImageElement): void;
  68115. private _loadImageFromDBAsync;
  68116. private _saveImageIntoDBAsync;
  68117. private _checkVersionFromDB;
  68118. private _loadVersionFromDBAsync;
  68119. private _saveVersionIntoDBAsync;
  68120. /**
  68121. * Loads a file from database
  68122. * @param url defines the URL to load from
  68123. * @param sceneLoaded defines a callback to call on success
  68124. * @param progressCallBack defines a callback to call when progress changed
  68125. * @param errorCallback defines a callback to call on error
  68126. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68127. */
  68128. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68129. private _loadFileAsync;
  68130. private _saveFileAsync;
  68131. /**
  68132. * Validates if xhr data is correct
  68133. * @param xhr defines the request to validate
  68134. * @param dataType defines the expected data type
  68135. * @returns true if data is correct
  68136. */
  68137. private static _ValidateXHRData;
  68138. }
  68139. }
  68140. declare module BABYLON {
  68141. /** @hidden */
  68142. export var gpuUpdateParticlesPixelShader: {
  68143. name: string;
  68144. shader: string;
  68145. };
  68146. }
  68147. declare module BABYLON {
  68148. /** @hidden */
  68149. export var gpuUpdateParticlesVertexShader: {
  68150. name: string;
  68151. shader: string;
  68152. };
  68153. }
  68154. declare module BABYLON {
  68155. /** @hidden */
  68156. export var clipPlaneFragmentDeclaration2: {
  68157. name: string;
  68158. shader: string;
  68159. };
  68160. }
  68161. declare module BABYLON {
  68162. /** @hidden */
  68163. export var gpuRenderParticlesPixelShader: {
  68164. name: string;
  68165. shader: string;
  68166. };
  68167. }
  68168. declare module BABYLON {
  68169. /** @hidden */
  68170. export var clipPlaneVertexDeclaration2: {
  68171. name: string;
  68172. shader: string;
  68173. };
  68174. }
  68175. declare module BABYLON {
  68176. /** @hidden */
  68177. export var gpuRenderParticlesVertexShader: {
  68178. name: string;
  68179. shader: string;
  68180. };
  68181. }
  68182. declare module BABYLON {
  68183. /**
  68184. * This represents a GPU particle system in Babylon
  68185. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68186. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68187. */
  68188. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68189. /**
  68190. * The layer mask we are rendering the particles through.
  68191. */
  68192. layerMask: number;
  68193. private _capacity;
  68194. private _activeCount;
  68195. private _currentActiveCount;
  68196. private _accumulatedCount;
  68197. private _renderEffect;
  68198. private _updateEffect;
  68199. private _buffer0;
  68200. private _buffer1;
  68201. private _spriteBuffer;
  68202. private _updateVAO;
  68203. private _renderVAO;
  68204. private _targetIndex;
  68205. private _sourceBuffer;
  68206. private _targetBuffer;
  68207. private _currentRenderId;
  68208. private _started;
  68209. private _stopped;
  68210. private _timeDelta;
  68211. private _randomTexture;
  68212. private _randomTexture2;
  68213. private _attributesStrideSize;
  68214. private _updateEffectOptions;
  68215. private _randomTextureSize;
  68216. private _actualFrame;
  68217. private _customEffect;
  68218. private readonly _rawTextureWidth;
  68219. /**
  68220. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68221. */
  68222. static get IsSupported(): boolean;
  68223. /**
  68224. * An event triggered when the system is disposed.
  68225. */
  68226. onDisposeObservable: Observable<IParticleSystem>;
  68227. /**
  68228. * An event triggered when the system is stopped
  68229. */
  68230. onStoppedObservable: Observable<IParticleSystem>;
  68231. /**
  68232. * Gets the maximum number of particles active at the same time.
  68233. * @returns The max number of active particles.
  68234. */
  68235. getCapacity(): number;
  68236. /**
  68237. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68238. * to override the particles.
  68239. */
  68240. forceDepthWrite: boolean;
  68241. /**
  68242. * Gets or set the number of active particles
  68243. */
  68244. get activeParticleCount(): number;
  68245. set activeParticleCount(value: number);
  68246. private _preWarmDone;
  68247. /**
  68248. * Specifies if the particles are updated in emitter local space or world space.
  68249. */
  68250. isLocal: boolean;
  68251. /** Gets or sets a matrix to use to compute projection */
  68252. defaultProjectionMatrix: Matrix;
  68253. /**
  68254. * Is this system ready to be used/rendered
  68255. * @return true if the system is ready
  68256. */
  68257. isReady(): boolean;
  68258. /**
  68259. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68260. * @returns True if it has been started, otherwise false.
  68261. */
  68262. isStarted(): boolean;
  68263. /**
  68264. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68265. * @returns True if it has been stopped, otherwise false.
  68266. */
  68267. isStopped(): boolean;
  68268. /**
  68269. * Gets a boolean indicating that the system is stopping
  68270. * @returns true if the system is currently stopping
  68271. */
  68272. isStopping(): boolean;
  68273. /**
  68274. * Gets the number of particles active at the same time.
  68275. * @returns The number of active particles.
  68276. */
  68277. getActiveCount(): number;
  68278. /**
  68279. * Starts the particle system and begins to emit
  68280. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68281. */
  68282. start(delay?: number): void;
  68283. /**
  68284. * Stops the particle system.
  68285. */
  68286. stop(): void;
  68287. /**
  68288. * Remove all active particles
  68289. */
  68290. reset(): void;
  68291. /**
  68292. * Returns the string "GPUParticleSystem"
  68293. * @returns a string containing the class name
  68294. */
  68295. getClassName(): string;
  68296. /**
  68297. * Gets the custom effect used to render the particles
  68298. * @param blendMode Blend mode for which the effect should be retrieved
  68299. * @returns The effect
  68300. */
  68301. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68302. /**
  68303. * Sets the custom effect used to render the particles
  68304. * @param effect The effect to set
  68305. * @param blendMode Blend mode for which the effect should be set
  68306. */
  68307. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68308. /** @hidden */
  68309. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68310. /**
  68311. * Observable that will be called just before the particles are drawn
  68312. */
  68313. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68314. /**
  68315. * Gets the name of the particle vertex shader
  68316. */
  68317. get vertexShaderName(): string;
  68318. private _colorGradientsTexture;
  68319. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68320. /**
  68321. * Adds a new color gradient
  68322. * @param gradient defines the gradient to use (between 0 and 1)
  68323. * @param color1 defines the color to affect to the specified gradient
  68324. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68325. * @returns the current particle system
  68326. */
  68327. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68328. private _refreshColorGradient;
  68329. /** Force the system to rebuild all gradients that need to be resync */
  68330. forceRefreshGradients(): void;
  68331. /**
  68332. * Remove a specific color gradient
  68333. * @param gradient defines the gradient to remove
  68334. * @returns the current particle system
  68335. */
  68336. removeColorGradient(gradient: number): GPUParticleSystem;
  68337. private _angularSpeedGradientsTexture;
  68338. private _sizeGradientsTexture;
  68339. private _velocityGradientsTexture;
  68340. private _limitVelocityGradientsTexture;
  68341. private _dragGradientsTexture;
  68342. private _addFactorGradient;
  68343. /**
  68344. * Adds a new size gradient
  68345. * @param gradient defines the gradient to use (between 0 and 1)
  68346. * @param factor defines the size factor to affect to the specified gradient
  68347. * @returns the current particle system
  68348. */
  68349. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68350. /**
  68351. * Remove a specific size gradient
  68352. * @param gradient defines the gradient to remove
  68353. * @returns the current particle system
  68354. */
  68355. removeSizeGradient(gradient: number): GPUParticleSystem;
  68356. private _refreshFactorGradient;
  68357. /**
  68358. * Adds a new angular speed gradient
  68359. * @param gradient defines the gradient to use (between 0 and 1)
  68360. * @param factor defines the angular speed to affect to the specified gradient
  68361. * @returns the current particle system
  68362. */
  68363. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68364. /**
  68365. * Remove a specific angular speed gradient
  68366. * @param gradient defines the gradient to remove
  68367. * @returns the current particle system
  68368. */
  68369. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68370. /**
  68371. * Adds a new velocity gradient
  68372. * @param gradient defines the gradient to use (between 0 and 1)
  68373. * @param factor defines the velocity to affect to the specified gradient
  68374. * @returns the current particle system
  68375. */
  68376. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68377. /**
  68378. * Remove a specific velocity gradient
  68379. * @param gradient defines the gradient to remove
  68380. * @returns the current particle system
  68381. */
  68382. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68383. /**
  68384. * Adds a new limit velocity gradient
  68385. * @param gradient defines the gradient to use (between 0 and 1)
  68386. * @param factor defines the limit velocity value to affect to the specified gradient
  68387. * @returns the current particle system
  68388. */
  68389. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68390. /**
  68391. * Remove a specific limit velocity gradient
  68392. * @param gradient defines the gradient to remove
  68393. * @returns the current particle system
  68394. */
  68395. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68396. /**
  68397. * Adds a new drag gradient
  68398. * @param gradient defines the gradient to use (between 0 and 1)
  68399. * @param factor defines the drag value to affect to the specified gradient
  68400. * @returns the current particle system
  68401. */
  68402. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68403. /**
  68404. * Remove a specific drag gradient
  68405. * @param gradient defines the gradient to remove
  68406. * @returns the current particle system
  68407. */
  68408. removeDragGradient(gradient: number): GPUParticleSystem;
  68409. /**
  68410. * Not supported by GPUParticleSystem
  68411. * @param gradient defines the gradient to use (between 0 and 1)
  68412. * @param factor defines the emit rate value to affect to the specified gradient
  68413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68414. * @returns the current particle system
  68415. */
  68416. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68417. /**
  68418. * Not supported by GPUParticleSystem
  68419. * @param gradient defines the gradient to remove
  68420. * @returns the current particle system
  68421. */
  68422. removeEmitRateGradient(gradient: number): IParticleSystem;
  68423. /**
  68424. * Not supported by GPUParticleSystem
  68425. * @param gradient defines the gradient to use (between 0 and 1)
  68426. * @param factor defines the start size value to affect to the specified gradient
  68427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68428. * @returns the current particle system
  68429. */
  68430. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68431. /**
  68432. * Not supported by GPUParticleSystem
  68433. * @param gradient defines the gradient to remove
  68434. * @returns the current particle system
  68435. */
  68436. removeStartSizeGradient(gradient: number): IParticleSystem;
  68437. /**
  68438. * Not supported by GPUParticleSystem
  68439. * @param gradient defines the gradient to use (between 0 and 1)
  68440. * @param min defines the color remap minimal range
  68441. * @param max defines the color remap maximal range
  68442. * @returns the current particle system
  68443. */
  68444. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68445. /**
  68446. * Not supported by GPUParticleSystem
  68447. * @param gradient defines the gradient to remove
  68448. * @returns the current particle system
  68449. */
  68450. removeColorRemapGradient(): IParticleSystem;
  68451. /**
  68452. * Not supported by GPUParticleSystem
  68453. * @param gradient defines the gradient to use (between 0 and 1)
  68454. * @param min defines the alpha remap minimal range
  68455. * @param max defines the alpha remap maximal range
  68456. * @returns the current particle system
  68457. */
  68458. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68459. /**
  68460. * Not supported by GPUParticleSystem
  68461. * @param gradient defines the gradient to remove
  68462. * @returns the current particle system
  68463. */
  68464. removeAlphaRemapGradient(): IParticleSystem;
  68465. /**
  68466. * Not supported by GPUParticleSystem
  68467. * @param gradient defines the gradient to use (between 0 and 1)
  68468. * @param color defines the color to affect to the specified gradient
  68469. * @returns the current particle system
  68470. */
  68471. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68472. /**
  68473. * Not supported by GPUParticleSystem
  68474. * @param gradient defines the gradient to remove
  68475. * @returns the current particle system
  68476. */
  68477. removeRampGradient(): IParticleSystem;
  68478. /**
  68479. * Not supported by GPUParticleSystem
  68480. * @returns the list of ramp gradients
  68481. */
  68482. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68483. /**
  68484. * Not supported by GPUParticleSystem
  68485. * Gets or sets a boolean indicating that ramp gradients must be used
  68486. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68487. */
  68488. get useRampGradients(): boolean;
  68489. set useRampGradients(value: boolean);
  68490. /**
  68491. * Not supported by GPUParticleSystem
  68492. * @param gradient defines the gradient to use (between 0 and 1)
  68493. * @param factor defines the life time factor to affect to the specified gradient
  68494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68495. * @returns the current particle system
  68496. */
  68497. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68498. /**
  68499. * Not supported by GPUParticleSystem
  68500. * @param gradient defines the gradient to remove
  68501. * @returns the current particle system
  68502. */
  68503. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68504. /**
  68505. * Instantiates a GPU particle system.
  68506. * 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.
  68507. * @param name The name of the particle system
  68508. * @param options The options used to create the system
  68509. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68510. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68511. * @param customEffect a custom effect used to change the way particles are rendered by default
  68512. */
  68513. constructor(name: string, options: Partial<{
  68514. capacity: number;
  68515. randomTextureSize: number;
  68516. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68517. protected _reset(): void;
  68518. private _createUpdateVAO;
  68519. private _createRenderVAO;
  68520. private _initialize;
  68521. /** @hidden */
  68522. _recreateUpdateEffect(): void;
  68523. private _getEffect;
  68524. /**
  68525. * Fill the defines array according to the current settings of the particle system
  68526. * @param defines Array to be updated
  68527. * @param blendMode blend mode to take into account when updating the array
  68528. */
  68529. fillDefines(defines: Array<string>, blendMode?: number): void;
  68530. /**
  68531. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68532. * @param uniforms Uniforms array to fill
  68533. * @param attributes Attributes array to fill
  68534. * @param samplers Samplers array to fill
  68535. */
  68536. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68537. /** @hidden */
  68538. _recreateRenderEffect(): Effect;
  68539. /**
  68540. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68541. * @param preWarm defines if we are in the pre-warmimg phase
  68542. */
  68543. animate(preWarm?: boolean): void;
  68544. private _createFactorGradientTexture;
  68545. private _createSizeGradientTexture;
  68546. private _createAngularSpeedGradientTexture;
  68547. private _createVelocityGradientTexture;
  68548. private _createLimitVelocityGradientTexture;
  68549. private _createDragGradientTexture;
  68550. private _createColorGradientTexture;
  68551. /**
  68552. * Renders the particle system in its current state
  68553. * @param preWarm defines if the system should only update the particles but not render them
  68554. * @returns the current number of particles
  68555. */
  68556. render(preWarm?: boolean): number;
  68557. /**
  68558. * Rebuilds the particle system
  68559. */
  68560. rebuild(): void;
  68561. private _releaseBuffers;
  68562. private _releaseVAOs;
  68563. /**
  68564. * Disposes the particle system and free the associated resources
  68565. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68566. */
  68567. dispose(disposeTexture?: boolean): void;
  68568. /**
  68569. * Clones the particle system.
  68570. * @param name The name of the cloned object
  68571. * @param newEmitter The new emitter to use
  68572. * @returns the cloned particle system
  68573. */
  68574. clone(name: string, newEmitter: any): GPUParticleSystem;
  68575. /**
  68576. * Serializes the particle system to a JSON object
  68577. * @param serializeTexture defines if the texture must be serialized as well
  68578. * @returns the JSON object
  68579. */
  68580. serialize(serializeTexture?: boolean): any;
  68581. /**
  68582. * Parses a JSON object to create a GPU particle system.
  68583. * @param parsedParticleSystem The JSON object to parse
  68584. * @param sceneOrEngine The scene or the engine to create the particle system in
  68585. * @param rootUrl The root url to use to load external dependencies like texture
  68586. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68587. * @returns the parsed GPU particle system
  68588. */
  68589. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68590. }
  68591. }
  68592. declare module BABYLON {
  68593. /**
  68594. * Represents a set of particle systems working together to create a specific effect
  68595. */
  68596. export class ParticleSystemSet implements IDisposable {
  68597. /**
  68598. * Gets or sets base Assets URL
  68599. */
  68600. static BaseAssetsUrl: string;
  68601. private _emitterCreationOptions;
  68602. private _emitterNode;
  68603. /**
  68604. * Gets the particle system list
  68605. */
  68606. systems: IParticleSystem[];
  68607. /**
  68608. * Gets the emitter node used with this set
  68609. */
  68610. get emitterNode(): Nullable<TransformNode>;
  68611. /**
  68612. * Creates a new emitter mesh as a sphere
  68613. * @param options defines the options used to create the sphere
  68614. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68615. * @param scene defines the hosting scene
  68616. */
  68617. setEmitterAsSphere(options: {
  68618. diameter: number;
  68619. segments: number;
  68620. color: Color3;
  68621. }, renderingGroupId: number, scene: Scene): void;
  68622. /**
  68623. * Starts all particle systems of the set
  68624. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68625. */
  68626. start(emitter?: AbstractMesh): void;
  68627. /**
  68628. * Release all associated resources
  68629. */
  68630. dispose(): void;
  68631. /**
  68632. * Serialize the set into a JSON compatible object
  68633. * @param serializeTexture defines if the texture must be serialized as well
  68634. * @returns a JSON compatible representation of the set
  68635. */
  68636. serialize(serializeTexture?: boolean): any;
  68637. /**
  68638. * Parse a new ParticleSystemSet from a serialized source
  68639. * @param data defines a JSON compatible representation of the set
  68640. * @param scene defines the hosting scene
  68641. * @param gpu defines if we want GPU particles or CPU particles
  68642. * @returns a new ParticleSystemSet
  68643. */
  68644. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68645. }
  68646. }
  68647. declare module BABYLON {
  68648. /**
  68649. * This class is made for on one-liner static method to help creating particle system set.
  68650. */
  68651. export class ParticleHelper {
  68652. /**
  68653. * Gets or sets base Assets URL
  68654. */
  68655. static BaseAssetsUrl: string;
  68656. /** Define the Url to load snippets */
  68657. static SnippetUrl: string;
  68658. /**
  68659. * Create a default particle system that you can tweak
  68660. * @param emitter defines the emitter to use
  68661. * @param capacity defines the system capacity (default is 500 particles)
  68662. * @param scene defines the hosting scene
  68663. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68664. * @returns the new Particle system
  68665. */
  68666. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68667. /**
  68668. * This is the main static method (one-liner) of this helper to create different particle systems
  68669. * @param type This string represents the type to the particle system to create
  68670. * @param scene The scene where the particle system should live
  68671. * @param gpu If the system will use gpu
  68672. * @returns the ParticleSystemSet created
  68673. */
  68674. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68675. /**
  68676. * Static function used to export a particle system to a ParticleSystemSet variable.
  68677. * Please note that the emitter shape is not exported
  68678. * @param systems defines the particle systems to export
  68679. * @returns the created particle system set
  68680. */
  68681. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68682. /**
  68683. * Creates a particle system from a snippet saved in a remote file
  68684. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68685. * @param url defines the url to load from
  68686. * @param scene defines the hosting scene
  68687. * @param gpu If the system will use gpu
  68688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68689. * @returns a promise that will resolve to the new particle system
  68690. */
  68691. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68692. /**
  68693. * Creates a particle system from a snippet saved by the particle system editor
  68694. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68695. * @param scene defines the hosting scene
  68696. * @param gpu If the system will use gpu
  68697. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68698. * @returns a promise that will resolve to the new particle system
  68699. */
  68700. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68701. }
  68702. }
  68703. declare module BABYLON {
  68704. interface Engine {
  68705. /**
  68706. * Create an effect to use with particle systems.
  68707. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68708. * the particle system for which you want to create a custom effect in the last parameter
  68709. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68710. * @param uniformsNames defines a list of attribute names
  68711. * @param samplers defines an array of string used to represent textures
  68712. * @param defines defines the string containing the defines to use to compile the shaders
  68713. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68714. * @param onCompiled defines a function to call when the effect creation is successful
  68715. * @param onError defines a function to call when the effect creation has failed
  68716. * @param particleSystem the particle system you want to create the effect for
  68717. * @returns the new Effect
  68718. */
  68719. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68720. }
  68721. interface Mesh {
  68722. /**
  68723. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68724. * @returns an array of IParticleSystem
  68725. */
  68726. getEmittedParticleSystems(): IParticleSystem[];
  68727. /**
  68728. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68729. * @returns an array of IParticleSystem
  68730. */
  68731. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68732. }
  68733. }
  68734. declare module BABYLON {
  68735. /** Defines the 4 color options */
  68736. export enum PointColor {
  68737. /** color value */
  68738. Color = 2,
  68739. /** uv value */
  68740. UV = 1,
  68741. /** random value */
  68742. Random = 0,
  68743. /** stated value */
  68744. Stated = 3
  68745. }
  68746. /**
  68747. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68748. * 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.
  68749. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68750. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68751. *
  68752. * Full documentation here : TO BE ENTERED
  68753. */
  68754. export class PointsCloudSystem implements IDisposable {
  68755. /**
  68756. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68757. * Example : var p = SPS.particles[i];
  68758. */
  68759. particles: CloudPoint[];
  68760. /**
  68761. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68762. */
  68763. nbParticles: number;
  68764. /**
  68765. * This a counter for your own usage. It's not set by any SPS functions.
  68766. */
  68767. counter: number;
  68768. /**
  68769. * The PCS name. This name is also given to the underlying mesh.
  68770. */
  68771. name: string;
  68772. /**
  68773. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68774. */
  68775. mesh: Mesh;
  68776. /**
  68777. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68778. * Please read :
  68779. */
  68780. vars: any;
  68781. /**
  68782. * @hidden
  68783. */
  68784. _size: number;
  68785. private _scene;
  68786. private _promises;
  68787. private _positions;
  68788. private _indices;
  68789. private _normals;
  68790. private _colors;
  68791. private _uvs;
  68792. private _indices32;
  68793. private _positions32;
  68794. private _colors32;
  68795. private _uvs32;
  68796. private _updatable;
  68797. private _isVisibilityBoxLocked;
  68798. private _alwaysVisible;
  68799. private _groups;
  68800. private _groupCounter;
  68801. private _computeParticleColor;
  68802. private _computeParticleTexture;
  68803. private _computeParticleRotation;
  68804. private _computeBoundingBox;
  68805. private _isReady;
  68806. /**
  68807. * Creates a PCS (Points Cloud System) object
  68808. * @param name (String) is the PCS name, this will be the underlying mesh name
  68809. * @param pointSize (number) is the size for each point
  68810. * @param scene (Scene) is the scene in which the PCS is added
  68811. * @param options defines the options of the PCS e.g.
  68812. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68813. */
  68814. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68815. updatable?: boolean;
  68816. });
  68817. /**
  68818. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68819. * If no points were added to the PCS, the returned mesh is just a single point.
  68820. * @returns a promise for the created mesh
  68821. */
  68822. buildMeshAsync(): Promise<Mesh>;
  68823. /**
  68824. * @hidden
  68825. */
  68826. private _buildMesh;
  68827. private _addParticle;
  68828. private _randomUnitVector;
  68829. private _getColorIndicesForCoord;
  68830. private _setPointsColorOrUV;
  68831. private _colorFromTexture;
  68832. private _calculateDensity;
  68833. /**
  68834. * Adds points to the PCS in random positions within a unit sphere
  68835. * @param nb (positive integer) the number of particles to be created from this model
  68836. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68837. * @returns the number of groups in the system
  68838. */
  68839. addPoints(nb: number, pointFunction?: any): number;
  68840. /**
  68841. * Adds points to the PCS from the surface of the model shape
  68842. * @param mesh is any Mesh object that will be used as a surface model for the points
  68843. * @param nb (positive integer) the number of particles to be created from this model
  68844. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68845. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68846. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68847. * @returns the number of groups in the system
  68848. */
  68849. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68850. /**
  68851. * Adds points to the PCS inside the model shape
  68852. * @param mesh is any Mesh object that will be used as a surface model for the points
  68853. * @param nb (positive integer) the number of particles to be created from this model
  68854. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68855. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68856. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68857. * @returns the number of groups in the system
  68858. */
  68859. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68860. /**
  68861. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68862. * This method calls `updateParticle()` for each particle of the SPS.
  68863. * For an animated SPS, it is usually called within the render loop.
  68864. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68865. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68866. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68867. * @returns the PCS.
  68868. */
  68869. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68870. /**
  68871. * Disposes the PCS.
  68872. */
  68873. dispose(): void;
  68874. /**
  68875. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68876. * doc :
  68877. * @returns the PCS.
  68878. */
  68879. refreshVisibleSize(): PointsCloudSystem;
  68880. /**
  68881. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68882. * @param size the size (float) of the visibility box
  68883. * note : this doesn't lock the PCS mesh bounding box.
  68884. * doc :
  68885. */
  68886. setVisibilityBox(size: number): void;
  68887. /**
  68888. * Gets whether the PCS is always visible or not
  68889. * doc :
  68890. */
  68891. get isAlwaysVisible(): boolean;
  68892. /**
  68893. * Sets the PCS as always visible or not
  68894. * doc :
  68895. */
  68896. set isAlwaysVisible(val: boolean);
  68897. /**
  68898. * Tells to `setParticles()` to compute the particle rotations or not
  68899. * Default value : false. The PCS is faster when it's set to false
  68900. * Note : particle rotations are only applied to parent particles
  68901. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68902. */
  68903. set computeParticleRotation(val: boolean);
  68904. /**
  68905. * Tells to `setParticles()` to compute the particle colors or not.
  68906. * Default value : true. The PCS is faster when it's set to false.
  68907. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68908. */
  68909. set computeParticleColor(val: boolean);
  68910. set computeParticleTexture(val: boolean);
  68911. /**
  68912. * Gets if `setParticles()` computes the particle colors or not.
  68913. * Default value : false. The PCS is faster when it's set to false.
  68914. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68915. */
  68916. get computeParticleColor(): boolean;
  68917. /**
  68918. * Gets if `setParticles()` computes the particle textures or not.
  68919. * Default value : false. The PCS is faster when it's set to false.
  68920. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68921. */
  68922. get computeParticleTexture(): boolean;
  68923. /**
  68924. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68925. */
  68926. set computeBoundingBox(val: boolean);
  68927. /**
  68928. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68929. */
  68930. get computeBoundingBox(): boolean;
  68931. /**
  68932. * This function does nothing. It may be overwritten to set all the particle first values.
  68933. * The PCS doesn't call this function, you may have to call it by your own.
  68934. * doc :
  68935. */
  68936. initParticles(): void;
  68937. /**
  68938. * This function does nothing. It may be overwritten to recycle a particle
  68939. * The PCS doesn't call this function, you can to call it
  68940. * doc :
  68941. * @param particle The particle to recycle
  68942. * @returns the recycled particle
  68943. */
  68944. recycleParticle(particle: CloudPoint): CloudPoint;
  68945. /**
  68946. * Updates a particle : this function should be overwritten by the user.
  68947. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68948. * doc :
  68949. * @example : just set a particle position or velocity and recycle conditions
  68950. * @param particle The particle to update
  68951. * @returns the updated particle
  68952. */
  68953. updateParticle(particle: CloudPoint): CloudPoint;
  68954. /**
  68955. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68956. * This does nothing and may be overwritten by the user.
  68957. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68958. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68959. * @param update the boolean update value actually passed to setParticles()
  68960. */
  68961. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68962. /**
  68963. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68964. * This will be passed three parameters.
  68965. * This does nothing and may be overwritten by the user.
  68966. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68968. * @param update the boolean update value actually passed to setParticles()
  68969. */
  68970. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68971. }
  68972. }
  68973. declare module BABYLON {
  68974. /**
  68975. * Represents one particle of a points cloud system.
  68976. */
  68977. export class CloudPoint {
  68978. /**
  68979. * particle global index
  68980. */
  68981. idx: number;
  68982. /**
  68983. * The color of the particle
  68984. */
  68985. color: Nullable<Color4>;
  68986. /**
  68987. * The world space position of the particle.
  68988. */
  68989. position: Vector3;
  68990. /**
  68991. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68992. */
  68993. rotation: Vector3;
  68994. /**
  68995. * The world space rotation quaternion of the particle.
  68996. */
  68997. rotationQuaternion: Nullable<Quaternion>;
  68998. /**
  68999. * The uv of the particle.
  69000. */
  69001. uv: Nullable<Vector2>;
  69002. /**
  69003. * The current speed of the particle.
  69004. */
  69005. velocity: Vector3;
  69006. /**
  69007. * The pivot point in the particle local space.
  69008. */
  69009. pivot: Vector3;
  69010. /**
  69011. * Must the particle be translated from its pivot point in its local space ?
  69012. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69013. * Default : false
  69014. */
  69015. translateFromPivot: boolean;
  69016. /**
  69017. * Index of this particle in the global "positions" array (Internal use)
  69018. * @hidden
  69019. */
  69020. _pos: number;
  69021. /**
  69022. * @hidden Index of this particle in the global "indices" array (Internal use)
  69023. */
  69024. _ind: number;
  69025. /**
  69026. * Group this particle belongs to
  69027. */
  69028. _group: PointsGroup;
  69029. /**
  69030. * Group id of this particle
  69031. */
  69032. groupId: number;
  69033. /**
  69034. * Index of the particle in its group id (Internal use)
  69035. */
  69036. idxInGroup: number;
  69037. /**
  69038. * @hidden Particle BoundingInfo object (Internal use)
  69039. */
  69040. _boundingInfo: BoundingInfo;
  69041. /**
  69042. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69043. */
  69044. _pcs: PointsCloudSystem;
  69045. /**
  69046. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69047. */
  69048. _stillInvisible: boolean;
  69049. /**
  69050. * @hidden Last computed particle rotation matrix
  69051. */
  69052. _rotationMatrix: number[];
  69053. /**
  69054. * Parent particle Id, if any.
  69055. * Default null.
  69056. */
  69057. parentId: Nullable<number>;
  69058. /**
  69059. * @hidden Internal global position in the PCS.
  69060. */
  69061. _globalPosition: Vector3;
  69062. /**
  69063. * Creates a Point Cloud object.
  69064. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69065. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69066. * @param group (PointsGroup) is the group the particle belongs to
  69067. * @param groupId (integer) is the group identifier in the PCS.
  69068. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69069. * @param pcs defines the PCS it is associated to
  69070. */
  69071. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69072. /**
  69073. * get point size
  69074. */
  69075. get size(): Vector3;
  69076. /**
  69077. * Set point size
  69078. */
  69079. set size(scale: Vector3);
  69080. /**
  69081. * Legacy support, changed quaternion to rotationQuaternion
  69082. */
  69083. get quaternion(): Nullable<Quaternion>;
  69084. /**
  69085. * Legacy support, changed quaternion to rotationQuaternion
  69086. */
  69087. set quaternion(q: Nullable<Quaternion>);
  69088. /**
  69089. * Returns a boolean. True if the particle intersects a mesh, else false
  69090. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69091. * @param target is the object (point or mesh) what the intersection is computed against
  69092. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69093. * @returns true if it intersects
  69094. */
  69095. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69096. /**
  69097. * get the rotation matrix of the particle
  69098. * @hidden
  69099. */
  69100. getRotationMatrix(m: Matrix): void;
  69101. }
  69102. /**
  69103. * Represents a group of points in a points cloud system
  69104. * * PCS internal tool, don't use it manually.
  69105. */
  69106. export class PointsGroup {
  69107. /**
  69108. * The group id
  69109. * @hidden
  69110. */
  69111. groupID: number;
  69112. /**
  69113. * image data for group (internal use)
  69114. * @hidden
  69115. */
  69116. _groupImageData: Nullable<ArrayBufferView>;
  69117. /**
  69118. * Image Width (internal use)
  69119. * @hidden
  69120. */
  69121. _groupImgWidth: number;
  69122. /**
  69123. * Image Height (internal use)
  69124. * @hidden
  69125. */
  69126. _groupImgHeight: number;
  69127. /**
  69128. * Custom position function (internal use)
  69129. * @hidden
  69130. */
  69131. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69132. /**
  69133. * density per facet for surface points
  69134. * @hidden
  69135. */
  69136. _groupDensity: number[];
  69137. /**
  69138. * Only when points are colored by texture carries pointer to texture list array
  69139. * @hidden
  69140. */
  69141. _textureNb: number;
  69142. /**
  69143. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69144. * PCS internal tool, don't use it manually.
  69145. * @hidden
  69146. */
  69147. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69148. }
  69149. }
  69150. declare module BABYLON {
  69151. interface Scene {
  69152. /** @hidden (Backing field) */
  69153. _physicsEngine: Nullable<IPhysicsEngine>;
  69154. /** @hidden */
  69155. _physicsTimeAccumulator: number;
  69156. /**
  69157. * Gets the current physics engine
  69158. * @returns a IPhysicsEngine or null if none attached
  69159. */
  69160. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69161. /**
  69162. * Enables physics to the current scene
  69163. * @param gravity defines the scene's gravity for the physics engine
  69164. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69165. * @return a boolean indicating if the physics engine was initialized
  69166. */
  69167. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69168. /**
  69169. * Disables and disposes the physics engine associated with the scene
  69170. */
  69171. disablePhysicsEngine(): void;
  69172. /**
  69173. * Gets a boolean indicating if there is an active physics engine
  69174. * @returns a boolean indicating if there is an active physics engine
  69175. */
  69176. isPhysicsEnabled(): boolean;
  69177. /**
  69178. * Deletes a physics compound impostor
  69179. * @param compound defines the compound to delete
  69180. */
  69181. deleteCompoundImpostor(compound: any): void;
  69182. /**
  69183. * An event triggered when physic simulation is about to be run
  69184. */
  69185. onBeforePhysicsObservable: Observable<Scene>;
  69186. /**
  69187. * An event triggered when physic simulation has been done
  69188. */
  69189. onAfterPhysicsObservable: Observable<Scene>;
  69190. }
  69191. interface AbstractMesh {
  69192. /** @hidden */
  69193. _physicsImpostor: Nullable<PhysicsImpostor>;
  69194. /**
  69195. * Gets or sets impostor used for physic simulation
  69196. * @see https://doc.babylonjs.com/features/physics_engine
  69197. */
  69198. physicsImpostor: Nullable<PhysicsImpostor>;
  69199. /**
  69200. * Gets the current physics impostor
  69201. * @see https://doc.babylonjs.com/features/physics_engine
  69202. * @returns a physics impostor or null
  69203. */
  69204. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69205. /** Apply a physic impulse to the mesh
  69206. * @param force defines the force to apply
  69207. * @param contactPoint defines where to apply the force
  69208. * @returns the current mesh
  69209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69210. */
  69211. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69212. /**
  69213. * Creates a physic joint between two meshes
  69214. * @param otherMesh defines the other mesh to use
  69215. * @param pivot1 defines the pivot to use on this mesh
  69216. * @param pivot2 defines the pivot to use on the other mesh
  69217. * @param options defines additional options (can be plugin dependent)
  69218. * @returns the current mesh
  69219. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69220. */
  69221. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69222. /** @hidden */
  69223. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69224. }
  69225. /**
  69226. * Defines the physics engine scene component responsible to manage a physics engine
  69227. */
  69228. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69229. /**
  69230. * The component name helpful to identify the component in the list of scene components.
  69231. */
  69232. readonly name: string;
  69233. /**
  69234. * The scene the component belongs to.
  69235. */
  69236. scene: Scene;
  69237. /**
  69238. * Creates a new instance of the component for the given scene
  69239. * @param scene Defines the scene to register the component in
  69240. */
  69241. constructor(scene: Scene);
  69242. /**
  69243. * Registers the component in a given scene
  69244. */
  69245. register(): void;
  69246. /**
  69247. * Rebuilds the elements related to this component in case of
  69248. * context lost for instance.
  69249. */
  69250. rebuild(): void;
  69251. /**
  69252. * Disposes the component and the associated ressources
  69253. */
  69254. dispose(): void;
  69255. }
  69256. }
  69257. declare module BABYLON {
  69258. /**
  69259. * A helper for physics simulations
  69260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69261. */
  69262. export class PhysicsHelper {
  69263. private _scene;
  69264. private _physicsEngine;
  69265. /**
  69266. * Initializes the Physics helper
  69267. * @param scene Babylon.js scene
  69268. */
  69269. constructor(scene: Scene);
  69270. /**
  69271. * Applies a radial explosion impulse
  69272. * @param origin the origin of the explosion
  69273. * @param radiusOrEventOptions the radius or the options of radial explosion
  69274. * @param strength the explosion strength
  69275. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69276. * @returns A physics radial explosion event, or null
  69277. */
  69278. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69279. /**
  69280. * Applies a radial explosion force
  69281. * @param origin the origin of the explosion
  69282. * @param radiusOrEventOptions the radius or the options of radial explosion
  69283. * @param strength the explosion strength
  69284. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69285. * @returns A physics radial explosion event, or null
  69286. */
  69287. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69288. /**
  69289. * Creates a gravitational field
  69290. * @param origin the origin of the explosion
  69291. * @param radiusOrEventOptions the radius or the options of radial explosion
  69292. * @param strength the explosion strength
  69293. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69294. * @returns A physics gravitational field event, or null
  69295. */
  69296. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69297. /**
  69298. * Creates a physics updraft event
  69299. * @param origin the origin of the updraft
  69300. * @param radiusOrEventOptions the radius or the options of the updraft
  69301. * @param strength the strength of the updraft
  69302. * @param height the height of the updraft
  69303. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69304. * @returns A physics updraft event, or null
  69305. */
  69306. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69307. /**
  69308. * Creates a physics vortex event
  69309. * @param origin the of the vortex
  69310. * @param radiusOrEventOptions the radius or the options of the vortex
  69311. * @param strength the strength of the vortex
  69312. * @param height the height of the vortex
  69313. * @returns a Physics vortex event, or null
  69314. * A physics vortex event or null
  69315. */
  69316. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69317. }
  69318. /**
  69319. * Represents a physics radial explosion event
  69320. */
  69321. class PhysicsRadialExplosionEvent {
  69322. private _scene;
  69323. private _options;
  69324. private _sphere;
  69325. private _dataFetched;
  69326. /**
  69327. * Initializes a radial explosioin event
  69328. * @param _scene BabylonJS scene
  69329. * @param _options The options for the vortex event
  69330. */
  69331. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69332. /**
  69333. * Returns the data related to the radial explosion event (sphere).
  69334. * @returns The radial explosion event data
  69335. */
  69336. getData(): PhysicsRadialExplosionEventData;
  69337. /**
  69338. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69339. * @param impostor A physics imposter
  69340. * @param origin the origin of the explosion
  69341. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69342. */
  69343. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69344. /**
  69345. * Triggers affecterd impostors callbacks
  69346. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69347. */
  69348. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69349. /**
  69350. * Disposes the sphere.
  69351. * @param force Specifies if the sphere should be disposed by force
  69352. */
  69353. dispose(force?: boolean): void;
  69354. /*** Helpers ***/
  69355. private _prepareSphere;
  69356. private _intersectsWithSphere;
  69357. }
  69358. /**
  69359. * Represents a gravitational field event
  69360. */
  69361. class PhysicsGravitationalFieldEvent {
  69362. private _physicsHelper;
  69363. private _scene;
  69364. private _origin;
  69365. private _options;
  69366. private _tickCallback;
  69367. private _sphere;
  69368. private _dataFetched;
  69369. /**
  69370. * Initializes the physics gravitational field event
  69371. * @param _physicsHelper A physics helper
  69372. * @param _scene BabylonJS scene
  69373. * @param _origin The origin position of the gravitational field event
  69374. * @param _options The options for the vortex event
  69375. */
  69376. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69377. /**
  69378. * Returns the data related to the gravitational field event (sphere).
  69379. * @returns A gravitational field event
  69380. */
  69381. getData(): PhysicsGravitationalFieldEventData;
  69382. /**
  69383. * Enables the gravitational field.
  69384. */
  69385. enable(): void;
  69386. /**
  69387. * Disables the gravitational field.
  69388. */
  69389. disable(): void;
  69390. /**
  69391. * Disposes the sphere.
  69392. * @param force The force to dispose from the gravitational field event
  69393. */
  69394. dispose(force?: boolean): void;
  69395. private _tick;
  69396. }
  69397. /**
  69398. * Represents a physics updraft event
  69399. */
  69400. class PhysicsUpdraftEvent {
  69401. private _scene;
  69402. private _origin;
  69403. private _options;
  69404. private _physicsEngine;
  69405. private _originTop;
  69406. private _originDirection;
  69407. private _tickCallback;
  69408. private _cylinder;
  69409. private _cylinderPosition;
  69410. private _dataFetched;
  69411. /**
  69412. * Initializes the physics updraft event
  69413. * @param _scene BabylonJS scene
  69414. * @param _origin The origin position of the updraft
  69415. * @param _options The options for the updraft event
  69416. */
  69417. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69418. /**
  69419. * Returns the data related to the updraft event (cylinder).
  69420. * @returns A physics updraft event
  69421. */
  69422. getData(): PhysicsUpdraftEventData;
  69423. /**
  69424. * Enables the updraft.
  69425. */
  69426. enable(): void;
  69427. /**
  69428. * Disables the updraft.
  69429. */
  69430. disable(): void;
  69431. /**
  69432. * Disposes the cylinder.
  69433. * @param force Specifies if the updraft should be disposed by force
  69434. */
  69435. dispose(force?: boolean): void;
  69436. private getImpostorHitData;
  69437. private _tick;
  69438. /*** Helpers ***/
  69439. private _prepareCylinder;
  69440. private _intersectsWithCylinder;
  69441. }
  69442. /**
  69443. * Represents a physics vortex event
  69444. */
  69445. class PhysicsVortexEvent {
  69446. private _scene;
  69447. private _origin;
  69448. private _options;
  69449. private _physicsEngine;
  69450. private _originTop;
  69451. private _tickCallback;
  69452. private _cylinder;
  69453. private _cylinderPosition;
  69454. private _dataFetched;
  69455. /**
  69456. * Initializes the physics vortex event
  69457. * @param _scene The BabylonJS scene
  69458. * @param _origin The origin position of the vortex
  69459. * @param _options The options for the vortex event
  69460. */
  69461. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69462. /**
  69463. * Returns the data related to the vortex event (cylinder).
  69464. * @returns The physics vortex event data
  69465. */
  69466. getData(): PhysicsVortexEventData;
  69467. /**
  69468. * Enables the vortex.
  69469. */
  69470. enable(): void;
  69471. /**
  69472. * Disables the cortex.
  69473. */
  69474. disable(): void;
  69475. /**
  69476. * Disposes the sphere.
  69477. * @param force
  69478. */
  69479. dispose(force?: boolean): void;
  69480. private getImpostorHitData;
  69481. private _tick;
  69482. /*** Helpers ***/
  69483. private _prepareCylinder;
  69484. private _intersectsWithCylinder;
  69485. }
  69486. /**
  69487. * Options fot the radial explosion event
  69488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69489. */
  69490. export class PhysicsRadialExplosionEventOptions {
  69491. /**
  69492. * The radius of the sphere for the radial explosion.
  69493. */
  69494. radius: number;
  69495. /**
  69496. * The strenth of the explosion.
  69497. */
  69498. strength: number;
  69499. /**
  69500. * The strenght of the force in correspondence to the distance of the affected object
  69501. */
  69502. falloff: PhysicsRadialImpulseFalloff;
  69503. /**
  69504. * Sphere options for the radial explosion.
  69505. */
  69506. sphere: {
  69507. segments: number;
  69508. diameter: number;
  69509. };
  69510. /**
  69511. * Sphere options for the radial explosion.
  69512. */
  69513. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69514. }
  69515. /**
  69516. * Options fot the updraft event
  69517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69518. */
  69519. export class PhysicsUpdraftEventOptions {
  69520. /**
  69521. * The radius of the cylinder for the vortex
  69522. */
  69523. radius: number;
  69524. /**
  69525. * The strenth of the updraft.
  69526. */
  69527. strength: number;
  69528. /**
  69529. * The height of the cylinder for the updraft.
  69530. */
  69531. height: number;
  69532. /**
  69533. * The mode for the the updraft.
  69534. */
  69535. updraftMode: PhysicsUpdraftMode;
  69536. }
  69537. /**
  69538. * Options fot the vortex event
  69539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69540. */
  69541. export class PhysicsVortexEventOptions {
  69542. /**
  69543. * The radius of the cylinder for the vortex
  69544. */
  69545. radius: number;
  69546. /**
  69547. * The strenth of the vortex.
  69548. */
  69549. strength: number;
  69550. /**
  69551. * The height of the cylinder for the vortex.
  69552. */
  69553. height: number;
  69554. /**
  69555. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69556. */
  69557. centripetalForceThreshold: number;
  69558. /**
  69559. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69560. */
  69561. centripetalForceMultiplier: number;
  69562. /**
  69563. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69564. */
  69565. centrifugalForceMultiplier: number;
  69566. /**
  69567. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69568. */
  69569. updraftForceMultiplier: number;
  69570. }
  69571. /**
  69572. * The strenght of the force in correspondence to the distance of the affected object
  69573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69574. */
  69575. export enum PhysicsRadialImpulseFalloff {
  69576. /** Defines that impulse is constant in strength across it's whole radius */
  69577. Constant = 0,
  69578. /** Defines that impulse gets weaker if it's further from the origin */
  69579. Linear = 1
  69580. }
  69581. /**
  69582. * The strength of the force in correspondence to the distance of the affected object
  69583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69584. */
  69585. export enum PhysicsUpdraftMode {
  69586. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69587. Center = 0,
  69588. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69589. Perpendicular = 1
  69590. }
  69591. /**
  69592. * Interface for a physics hit data
  69593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69594. */
  69595. export interface PhysicsHitData {
  69596. /**
  69597. * The force applied at the contact point
  69598. */
  69599. force: Vector3;
  69600. /**
  69601. * The contact point
  69602. */
  69603. contactPoint: Vector3;
  69604. /**
  69605. * The distance from the origin to the contact point
  69606. */
  69607. distanceFromOrigin: number;
  69608. }
  69609. /**
  69610. * Interface for radial explosion event data
  69611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69612. */
  69613. export interface PhysicsRadialExplosionEventData {
  69614. /**
  69615. * A sphere used for the radial explosion event
  69616. */
  69617. sphere: Mesh;
  69618. }
  69619. /**
  69620. * Interface for gravitational field event data
  69621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69622. */
  69623. export interface PhysicsGravitationalFieldEventData {
  69624. /**
  69625. * A sphere mesh used for the gravitational field event
  69626. */
  69627. sphere: Mesh;
  69628. }
  69629. /**
  69630. * Interface for updraft event data
  69631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69632. */
  69633. export interface PhysicsUpdraftEventData {
  69634. /**
  69635. * A cylinder used for the updraft event
  69636. */
  69637. cylinder: Mesh;
  69638. }
  69639. /**
  69640. * Interface for vortex event data
  69641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69642. */
  69643. export interface PhysicsVortexEventData {
  69644. /**
  69645. * A cylinder used for the vortex event
  69646. */
  69647. cylinder: Mesh;
  69648. }
  69649. /**
  69650. * Interface for an affected physics impostor
  69651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69652. */
  69653. export interface PhysicsAffectedImpostorWithData {
  69654. /**
  69655. * The impostor affected by the effect
  69656. */
  69657. impostor: PhysicsImpostor;
  69658. /**
  69659. * The data about the hit/horce from the explosion
  69660. */
  69661. hitData: PhysicsHitData;
  69662. }
  69663. }
  69664. declare module BABYLON {
  69665. /** @hidden */
  69666. export var blackAndWhitePixelShader: {
  69667. name: string;
  69668. shader: string;
  69669. };
  69670. }
  69671. declare module BABYLON {
  69672. /**
  69673. * Post process used to render in black and white
  69674. */
  69675. export class BlackAndWhitePostProcess extends PostProcess {
  69676. /**
  69677. * Linear about to convert he result to black and white (default: 1)
  69678. */
  69679. degree: number;
  69680. /**
  69681. * Gets a string identifying the name of the class
  69682. * @returns "BlackAndWhitePostProcess" string
  69683. */
  69684. getClassName(): string;
  69685. /**
  69686. * Creates a black and white post process
  69687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69688. * @param name The name of the effect.
  69689. * @param options The required width/height ratio to downsize to before computing the render pass.
  69690. * @param camera The camera to apply the render pass to.
  69691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69692. * @param engine The engine which the post process will be applied. (default: current engine)
  69693. * @param reusable If the post process can be reused on the same frame. (default: false)
  69694. */
  69695. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69696. /** @hidden */
  69697. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69698. }
  69699. }
  69700. declare module BABYLON {
  69701. /**
  69702. * This represents a set of one or more post processes in Babylon.
  69703. * A post process can be used to apply a shader to a texture after it is rendered.
  69704. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69705. */
  69706. export class PostProcessRenderEffect {
  69707. private _postProcesses;
  69708. private _getPostProcesses;
  69709. private _singleInstance;
  69710. private _cameras;
  69711. private _indicesForCamera;
  69712. /**
  69713. * Name of the effect
  69714. * @hidden
  69715. */
  69716. _name: string;
  69717. /**
  69718. * Instantiates a post process render effect.
  69719. * A post process can be used to apply a shader to a texture after it is rendered.
  69720. * @param engine The engine the effect is tied to
  69721. * @param name The name of the effect
  69722. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69723. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69724. */
  69725. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69726. /**
  69727. * Checks if all the post processes in the effect are supported.
  69728. */
  69729. get isSupported(): boolean;
  69730. /**
  69731. * Updates the current state of the effect
  69732. * @hidden
  69733. */
  69734. _update(): void;
  69735. /**
  69736. * Attaches the effect on cameras
  69737. * @param cameras The camera to attach to.
  69738. * @hidden
  69739. */
  69740. _attachCameras(cameras: Camera): void;
  69741. /**
  69742. * Attaches the effect on cameras
  69743. * @param cameras The camera to attach to.
  69744. * @hidden
  69745. */
  69746. _attachCameras(cameras: Camera[]): void;
  69747. /**
  69748. * Detaches the effect on cameras
  69749. * @param cameras The camera to detatch from.
  69750. * @hidden
  69751. */
  69752. _detachCameras(cameras: Camera): void;
  69753. /**
  69754. * Detatches the effect on cameras
  69755. * @param cameras The camera to detatch from.
  69756. * @hidden
  69757. */
  69758. _detachCameras(cameras: Camera[]): void;
  69759. /**
  69760. * Enables the effect on given cameras
  69761. * @param cameras The camera to enable.
  69762. * @hidden
  69763. */
  69764. _enable(cameras: Camera): void;
  69765. /**
  69766. * Enables the effect on given cameras
  69767. * @param cameras The camera to enable.
  69768. * @hidden
  69769. */
  69770. _enable(cameras: Nullable<Camera[]>): void;
  69771. /**
  69772. * Disables the effect on the given cameras
  69773. * @param cameras The camera to disable.
  69774. * @hidden
  69775. */
  69776. _disable(cameras: Camera): void;
  69777. /**
  69778. * Disables the effect on the given cameras
  69779. * @param cameras The camera to disable.
  69780. * @hidden
  69781. */
  69782. _disable(cameras: Nullable<Camera[]>): void;
  69783. /**
  69784. * Gets a list of the post processes contained in the effect.
  69785. * @param camera The camera to get the post processes on.
  69786. * @returns The list of the post processes in the effect.
  69787. */
  69788. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69789. }
  69790. }
  69791. declare module BABYLON {
  69792. /** @hidden */
  69793. export var extractHighlightsPixelShader: {
  69794. name: string;
  69795. shader: string;
  69796. };
  69797. }
  69798. declare module BABYLON {
  69799. /**
  69800. * 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.
  69801. */
  69802. export class ExtractHighlightsPostProcess extends PostProcess {
  69803. /**
  69804. * The luminance threshold, pixels below this value will be set to black.
  69805. */
  69806. threshold: number;
  69807. /** @hidden */
  69808. _exposure: number;
  69809. /**
  69810. * Post process which has the input texture to be used when performing highlight extraction
  69811. * @hidden
  69812. */
  69813. _inputPostProcess: Nullable<PostProcess>;
  69814. /**
  69815. * Gets a string identifying the name of the class
  69816. * @returns "ExtractHighlightsPostProcess" string
  69817. */
  69818. getClassName(): string;
  69819. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69820. }
  69821. }
  69822. declare module BABYLON {
  69823. /** @hidden */
  69824. export var bloomMergePixelShader: {
  69825. name: string;
  69826. shader: string;
  69827. };
  69828. }
  69829. declare module BABYLON {
  69830. /**
  69831. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69832. */
  69833. export class BloomMergePostProcess extends PostProcess {
  69834. /** Weight of the bloom to be added to the original input. */
  69835. weight: number;
  69836. /**
  69837. * Gets a string identifying the name of the class
  69838. * @returns "BloomMergePostProcess" string
  69839. */
  69840. getClassName(): string;
  69841. /**
  69842. * Creates a new instance of @see BloomMergePostProcess
  69843. * @param name The name of the effect.
  69844. * @param originalFromInput Post process which's input will be used for the merge.
  69845. * @param blurred Blurred highlights post process which's output will be used.
  69846. * @param weight Weight of the bloom to be added to the original input.
  69847. * @param options The required width/height ratio to downsize to before computing the render pass.
  69848. * @param camera The camera to apply the render pass to.
  69849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69850. * @param engine The engine which the post process will be applied. (default: current engine)
  69851. * @param reusable If the post process can be reused on the same frame. (default: false)
  69852. * @param textureType Type of textures used when performing the post process. (default: 0)
  69853. * @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)
  69854. */
  69855. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69856. /** Weight of the bloom to be added to the original input. */
  69857. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69858. }
  69859. }
  69860. declare module BABYLON {
  69861. /**
  69862. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69863. */
  69864. export class BloomEffect extends PostProcessRenderEffect {
  69865. private bloomScale;
  69866. /**
  69867. * @hidden Internal
  69868. */
  69869. _effects: Array<PostProcess>;
  69870. /**
  69871. * @hidden Internal
  69872. */
  69873. _downscale: ExtractHighlightsPostProcess;
  69874. private _blurX;
  69875. private _blurY;
  69876. private _merge;
  69877. /**
  69878. * The luminance threshold to find bright areas of the image to bloom.
  69879. */
  69880. get threshold(): number;
  69881. set threshold(value: number);
  69882. /**
  69883. * The strength of the bloom.
  69884. */
  69885. get weight(): number;
  69886. set weight(value: number);
  69887. /**
  69888. * Specifies the size of the bloom blur kernel, relative to the final output size
  69889. */
  69890. get kernel(): number;
  69891. set kernel(value: number);
  69892. /**
  69893. * Creates a new instance of @see BloomEffect
  69894. * @param scene The scene the effect belongs to.
  69895. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69896. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69897. * @param bloomWeight The the strength of bloom.
  69898. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69899. * @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)
  69900. */
  69901. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69902. /**
  69903. * Disposes each of the internal effects for a given camera.
  69904. * @param camera The camera to dispose the effect on.
  69905. */
  69906. disposeEffects(camera: Camera): void;
  69907. /**
  69908. * @hidden Internal
  69909. */
  69910. _updateEffects(): void;
  69911. /**
  69912. * Internal
  69913. * @returns if all the contained post processes are ready.
  69914. * @hidden
  69915. */
  69916. _isReady(): boolean;
  69917. }
  69918. }
  69919. declare module BABYLON {
  69920. /** @hidden */
  69921. export var chromaticAberrationPixelShader: {
  69922. name: string;
  69923. shader: string;
  69924. };
  69925. }
  69926. declare module BABYLON {
  69927. /**
  69928. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69929. */
  69930. export class ChromaticAberrationPostProcess extends PostProcess {
  69931. /**
  69932. * The amount of seperation of rgb channels (default: 30)
  69933. */
  69934. aberrationAmount: number;
  69935. /**
  69936. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69937. */
  69938. radialIntensity: number;
  69939. /**
  69940. * 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))
  69941. */
  69942. direction: Vector2;
  69943. /**
  69944. * 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))
  69945. */
  69946. centerPosition: Vector2;
  69947. /** The width of the screen to apply the effect on */
  69948. screenWidth: number;
  69949. /** The height of the screen to apply the effect on */
  69950. screenHeight: number;
  69951. /**
  69952. * Gets a string identifying the name of the class
  69953. * @returns "ChromaticAberrationPostProcess" string
  69954. */
  69955. getClassName(): string;
  69956. /**
  69957. * Creates a new instance ChromaticAberrationPostProcess
  69958. * @param name The name of the effect.
  69959. * @param screenWidth The width of the screen to apply the effect on.
  69960. * @param screenHeight The height of the screen to apply the effect on.
  69961. * @param options The required width/height ratio to downsize to before computing the render pass.
  69962. * @param camera The camera to apply the render pass to.
  69963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69964. * @param engine The engine which the post process will be applied. (default: current engine)
  69965. * @param reusable If the post process can be reused on the same frame. (default: false)
  69966. * @param textureType Type of textures used when performing the post process. (default: 0)
  69967. * @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)
  69968. */
  69969. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69970. /** @hidden */
  69971. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69972. }
  69973. }
  69974. declare module BABYLON {
  69975. /** @hidden */
  69976. export var circleOfConfusionPixelShader: {
  69977. name: string;
  69978. shader: string;
  69979. };
  69980. }
  69981. declare module BABYLON {
  69982. /**
  69983. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69984. */
  69985. export class CircleOfConfusionPostProcess extends PostProcess {
  69986. /**
  69987. * 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.
  69988. */
  69989. lensSize: number;
  69990. /**
  69991. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69992. */
  69993. fStop: number;
  69994. /**
  69995. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69996. */
  69997. focusDistance: number;
  69998. /**
  69999. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70000. */
  70001. focalLength: number;
  70002. /**
  70003. * Gets a string identifying the name of the class
  70004. * @returns "CircleOfConfusionPostProcess" string
  70005. */
  70006. getClassName(): string;
  70007. private _depthTexture;
  70008. /**
  70009. * Creates a new instance CircleOfConfusionPostProcess
  70010. * @param name The name of the effect.
  70011. * @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.
  70012. * @param options The required width/height ratio to downsize to before computing the render pass.
  70013. * @param camera The camera to apply the render pass to.
  70014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70015. * @param engine The engine which the post process will be applied. (default: current engine)
  70016. * @param reusable If the post process can be reused on the same frame. (default: false)
  70017. * @param textureType Type of textures used when performing the post process. (default: 0)
  70018. * @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)
  70019. */
  70020. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70021. /**
  70022. * 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.
  70023. */
  70024. set depthTexture(value: RenderTargetTexture);
  70025. }
  70026. }
  70027. declare module BABYLON {
  70028. /** @hidden */
  70029. export var colorCorrectionPixelShader: {
  70030. name: string;
  70031. shader: string;
  70032. };
  70033. }
  70034. declare module BABYLON {
  70035. /**
  70036. *
  70037. * This post-process allows the modification of rendered colors by using
  70038. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70039. *
  70040. * The object needs to be provided an url to a texture containing the color
  70041. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70042. * Use an image editing software to tweak the LUT to match your needs.
  70043. *
  70044. * For an example of a color LUT, see here:
  70045. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70046. * For explanations on color grading, see here:
  70047. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70048. *
  70049. */
  70050. export class ColorCorrectionPostProcess extends PostProcess {
  70051. private _colorTableTexture;
  70052. /**
  70053. * Gets the color table url used to create the LUT texture
  70054. */
  70055. colorTableUrl: string;
  70056. /**
  70057. * Gets a string identifying the name of the class
  70058. * @returns "ColorCorrectionPostProcess" string
  70059. */
  70060. getClassName(): string;
  70061. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70062. /** @hidden */
  70063. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70064. }
  70065. }
  70066. declare module BABYLON {
  70067. /** @hidden */
  70068. export var convolutionPixelShader: {
  70069. name: string;
  70070. shader: string;
  70071. };
  70072. }
  70073. declare module BABYLON {
  70074. /**
  70075. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70076. * input texture to perform effects such as edge detection or sharpening
  70077. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70078. */
  70079. export class ConvolutionPostProcess extends PostProcess {
  70080. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70081. kernel: number[];
  70082. /**
  70083. * Gets a string identifying the name of the class
  70084. * @returns "ConvolutionPostProcess" string
  70085. */
  70086. getClassName(): string;
  70087. /**
  70088. * Creates a new instance ConvolutionPostProcess
  70089. * @param name The name of the effect.
  70090. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70091. * @param options The required width/height ratio to downsize to before computing the render pass.
  70092. * @param camera The camera to apply the render pass to.
  70093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70094. * @param engine The engine which the post process will be applied. (default: current engine)
  70095. * @param reusable If the post process can be reused on the same frame. (default: false)
  70096. * @param textureType Type of textures used when performing the post process. (default: 0)
  70097. */
  70098. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70099. /** @hidden */
  70100. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70101. /**
  70102. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70103. */
  70104. static EdgeDetect0Kernel: number[];
  70105. /**
  70106. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70107. */
  70108. static EdgeDetect1Kernel: number[];
  70109. /**
  70110. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70111. */
  70112. static EdgeDetect2Kernel: number[];
  70113. /**
  70114. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70115. */
  70116. static SharpenKernel: number[];
  70117. /**
  70118. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70119. */
  70120. static EmbossKernel: number[];
  70121. /**
  70122. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70123. */
  70124. static GaussianKernel: number[];
  70125. }
  70126. }
  70127. declare module BABYLON {
  70128. /**
  70129. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70130. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70131. * based on samples that have a large difference in distance than the center pixel.
  70132. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70133. */
  70134. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70135. /**
  70136. * The direction the blur should be applied
  70137. */
  70138. direction: Vector2;
  70139. /**
  70140. * Gets a string identifying the name of the class
  70141. * @returns "DepthOfFieldBlurPostProcess" string
  70142. */
  70143. getClassName(): string;
  70144. /**
  70145. * Creates a new instance CircleOfConfusionPostProcess
  70146. * @param name The name of the effect.
  70147. * @param scene The scene the effect belongs to.
  70148. * @param direction The direction the blur should be applied.
  70149. * @param kernel The size of the kernel used to blur.
  70150. * @param options The required width/height ratio to downsize to before computing the render pass.
  70151. * @param camera The camera to apply the render pass to.
  70152. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70153. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70155. * @param engine The engine which the post process will be applied. (default: current engine)
  70156. * @param reusable If the post process can be reused on the same frame. (default: false)
  70157. * @param textureType Type of textures used when performing the post process. (default: 0)
  70158. * @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)
  70159. */
  70160. 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);
  70161. }
  70162. }
  70163. declare module BABYLON {
  70164. /** @hidden */
  70165. export var depthOfFieldMergePixelShader: {
  70166. name: string;
  70167. shader: string;
  70168. };
  70169. }
  70170. declare module BABYLON {
  70171. /**
  70172. * Options to be set when merging outputs from the default pipeline.
  70173. */
  70174. export class DepthOfFieldMergePostProcessOptions {
  70175. /**
  70176. * The original image to merge on top of
  70177. */
  70178. originalFromInput: PostProcess;
  70179. /**
  70180. * Parameters to perform the merge of the depth of field effect
  70181. */
  70182. depthOfField?: {
  70183. circleOfConfusion: PostProcess;
  70184. blurSteps: Array<PostProcess>;
  70185. };
  70186. /**
  70187. * Parameters to perform the merge of bloom effect
  70188. */
  70189. bloom?: {
  70190. blurred: PostProcess;
  70191. weight: number;
  70192. };
  70193. }
  70194. /**
  70195. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70196. */
  70197. export class DepthOfFieldMergePostProcess extends PostProcess {
  70198. private blurSteps;
  70199. /**
  70200. * Gets a string identifying the name of the class
  70201. * @returns "DepthOfFieldMergePostProcess" string
  70202. */
  70203. getClassName(): string;
  70204. /**
  70205. * Creates a new instance of DepthOfFieldMergePostProcess
  70206. * @param name The name of the effect.
  70207. * @param originalFromInput Post process which's input will be used for the merge.
  70208. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70209. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  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 samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70213. * @param engine The engine which the post process will be applied. (default: current engine)
  70214. * @param reusable If the post process can be reused on the same frame. (default: false)
  70215. * @param textureType Type of textures used when performing the post process. (default: 0)
  70216. * @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)
  70217. */
  70218. 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);
  70219. /**
  70220. * Updates the effect with the current post process compile time values and recompiles the shader.
  70221. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70222. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70223. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70224. * @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
  70225. * @param onCompiled Called when the shader has been compiled.
  70226. * @param onError Called if there is an error when compiling a shader.
  70227. */
  70228. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70229. }
  70230. }
  70231. declare module BABYLON {
  70232. /**
  70233. * Specifies the level of max blur that should be applied when using the depth of field effect
  70234. */
  70235. export enum DepthOfFieldEffectBlurLevel {
  70236. /**
  70237. * Subtle blur
  70238. */
  70239. Low = 0,
  70240. /**
  70241. * Medium blur
  70242. */
  70243. Medium = 1,
  70244. /**
  70245. * Large blur
  70246. */
  70247. High = 2
  70248. }
  70249. /**
  70250. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70251. */
  70252. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70253. private _circleOfConfusion;
  70254. /**
  70255. * @hidden Internal, blurs from high to low
  70256. */
  70257. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70258. private _depthOfFieldBlurY;
  70259. private _dofMerge;
  70260. /**
  70261. * @hidden Internal post processes in depth of field effect
  70262. */
  70263. _effects: Array<PostProcess>;
  70264. /**
  70265. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70266. */
  70267. set focalLength(value: number);
  70268. get focalLength(): number;
  70269. /**
  70270. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70271. */
  70272. set fStop(value: number);
  70273. get fStop(): number;
  70274. /**
  70275. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70276. */
  70277. set focusDistance(value: number);
  70278. get focusDistance(): number;
  70279. /**
  70280. * 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.
  70281. */
  70282. set lensSize(value: number);
  70283. get lensSize(): number;
  70284. /**
  70285. * Creates a new instance DepthOfFieldEffect
  70286. * @param scene The scene the effect belongs to.
  70287. * @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.
  70288. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70289. * @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)
  70290. */
  70291. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70292. /**
  70293. * Get the current class name of the current effet
  70294. * @returns "DepthOfFieldEffect"
  70295. */
  70296. getClassName(): string;
  70297. /**
  70298. * 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.
  70299. */
  70300. set depthTexture(value: RenderTargetTexture);
  70301. /**
  70302. * Disposes each of the internal effects for a given camera.
  70303. * @param camera The camera to dispose the effect on.
  70304. */
  70305. disposeEffects(camera: Camera): void;
  70306. /**
  70307. * @hidden Internal
  70308. */
  70309. _updateEffects(): void;
  70310. /**
  70311. * Internal
  70312. * @returns if all the contained post processes are ready.
  70313. * @hidden
  70314. */
  70315. _isReady(): boolean;
  70316. }
  70317. }
  70318. declare module BABYLON {
  70319. /** @hidden */
  70320. export var displayPassPixelShader: {
  70321. name: string;
  70322. shader: string;
  70323. };
  70324. }
  70325. declare module BABYLON {
  70326. /**
  70327. * DisplayPassPostProcess which produces an output the same as it's input
  70328. */
  70329. export class DisplayPassPostProcess extends PostProcess {
  70330. /**
  70331. * Gets a string identifying the name of the class
  70332. * @returns "DisplayPassPostProcess" string
  70333. */
  70334. getClassName(): string;
  70335. /**
  70336. * Creates the DisplayPassPostProcess
  70337. * @param name The name of the effect.
  70338. * @param options The required width/height ratio to downsize to before computing the render pass.
  70339. * @param camera The camera to apply the render pass to.
  70340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70341. * @param engine The engine which the post process will be applied. (default: current engine)
  70342. * @param reusable If the post process can be reused on the same frame. (default: false)
  70343. */
  70344. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70345. /** @hidden */
  70346. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70347. }
  70348. }
  70349. declare module BABYLON {
  70350. /** @hidden */
  70351. export var filterPixelShader: {
  70352. name: string;
  70353. shader: string;
  70354. };
  70355. }
  70356. declare module BABYLON {
  70357. /**
  70358. * Applies a kernel filter to the image
  70359. */
  70360. export class FilterPostProcess extends PostProcess {
  70361. /** The matrix to be applied to the image */
  70362. kernelMatrix: Matrix;
  70363. /**
  70364. * Gets a string identifying the name of the class
  70365. * @returns "FilterPostProcess" string
  70366. */
  70367. getClassName(): string;
  70368. /**
  70369. *
  70370. * @param name The name of the effect.
  70371. * @param kernelMatrix The matrix to be applied to the image
  70372. * @param options The required width/height ratio to downsize to before computing the render pass.
  70373. * @param camera The camera to apply the render pass to.
  70374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70375. * @param engine The engine which the post process will be applied. (default: current engine)
  70376. * @param reusable If the post process can be reused on the same frame. (default: false)
  70377. */
  70378. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70379. /** @hidden */
  70380. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70381. }
  70382. }
  70383. declare module BABYLON {
  70384. /** @hidden */
  70385. export var fxaaPixelShader: {
  70386. name: string;
  70387. shader: string;
  70388. };
  70389. }
  70390. declare module BABYLON {
  70391. /** @hidden */
  70392. export var fxaaVertexShader: {
  70393. name: string;
  70394. shader: string;
  70395. };
  70396. }
  70397. declare module BABYLON {
  70398. /**
  70399. * Fxaa post process
  70400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70401. */
  70402. export class FxaaPostProcess extends PostProcess {
  70403. /**
  70404. * Gets a string identifying the name of the class
  70405. * @returns "FxaaPostProcess" string
  70406. */
  70407. getClassName(): string;
  70408. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70409. private _getDefines;
  70410. /** @hidden */
  70411. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70412. }
  70413. }
  70414. declare module BABYLON {
  70415. /** @hidden */
  70416. export var grainPixelShader: {
  70417. name: string;
  70418. shader: string;
  70419. };
  70420. }
  70421. declare module BABYLON {
  70422. /**
  70423. * The GrainPostProcess adds noise to the image at mid luminance levels
  70424. */
  70425. export class GrainPostProcess extends PostProcess {
  70426. /**
  70427. * The intensity of the grain added (default: 30)
  70428. */
  70429. intensity: number;
  70430. /**
  70431. * If the grain should be randomized on every frame
  70432. */
  70433. animated: boolean;
  70434. /**
  70435. * Gets a string identifying the name of the class
  70436. * @returns "GrainPostProcess" string
  70437. */
  70438. getClassName(): string;
  70439. /**
  70440. * Creates a new instance of @see GrainPostProcess
  70441. * @param name The name of the effect.
  70442. * @param options The required width/height ratio to downsize to before computing the render pass.
  70443. * @param camera The camera to apply the render pass to.
  70444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70445. * @param engine The engine which the post process will be applied. (default: current engine)
  70446. * @param reusable If the post process can be reused on the same frame. (default: false)
  70447. * @param textureType Type of textures used when performing the post process. (default: 0)
  70448. * @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)
  70449. */
  70450. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70451. /** @hidden */
  70452. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70453. }
  70454. }
  70455. declare module BABYLON {
  70456. /** @hidden */
  70457. export var highlightsPixelShader: {
  70458. name: string;
  70459. shader: string;
  70460. };
  70461. }
  70462. declare module BABYLON {
  70463. /**
  70464. * Extracts highlights from the image
  70465. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70466. */
  70467. export class HighlightsPostProcess extends PostProcess {
  70468. /**
  70469. * Gets a string identifying the name of the class
  70470. * @returns "HighlightsPostProcess" string
  70471. */
  70472. getClassName(): string;
  70473. /**
  70474. * Extracts highlights from the image
  70475. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70476. * @param name The name of the effect.
  70477. * @param options The required width/height ratio to downsize to before computing the render pass.
  70478. * @param camera The camera to apply the render pass to.
  70479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70480. * @param engine The engine which the post process will be applied. (default: current engine)
  70481. * @param reusable If the post process can be reused on the same frame. (default: false)
  70482. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70483. */
  70484. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70485. }
  70486. }
  70487. declare module BABYLON {
  70488. /**
  70489. * Contains all parameters needed for the prepass to perform
  70490. * motion blur
  70491. */
  70492. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70493. /**
  70494. * Is motion blur enabled
  70495. */
  70496. enabled: boolean;
  70497. /**
  70498. * Name of the configuration
  70499. */
  70500. name: string;
  70501. /**
  70502. * Textures that should be present in the MRT for this effect to work
  70503. */
  70504. readonly texturesRequired: number[];
  70505. }
  70506. }
  70507. declare module BABYLON {
  70508. interface Scene {
  70509. /** @hidden (Backing field) */
  70510. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70511. /**
  70512. * Gets or Sets the current geometry buffer associated to the scene.
  70513. */
  70514. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70515. /**
  70516. * Enables a GeometryBufferRender and associates it with the scene
  70517. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70518. * @returns the GeometryBufferRenderer
  70519. */
  70520. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70521. /**
  70522. * Disables the GeometryBufferRender associated with the scene
  70523. */
  70524. disableGeometryBufferRenderer(): void;
  70525. }
  70526. /**
  70527. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70528. * in several rendering techniques.
  70529. */
  70530. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70531. /**
  70532. * The component name helpful to identify the component in the list of scene components.
  70533. */
  70534. readonly name: string;
  70535. /**
  70536. * The scene the component belongs to.
  70537. */
  70538. scene: Scene;
  70539. /**
  70540. * Creates a new instance of the component for the given scene
  70541. * @param scene Defines the scene to register the component in
  70542. */
  70543. constructor(scene: Scene);
  70544. /**
  70545. * Registers the component in a given scene
  70546. */
  70547. register(): void;
  70548. /**
  70549. * Rebuilds the elements related to this component in case of
  70550. * context lost for instance.
  70551. */
  70552. rebuild(): void;
  70553. /**
  70554. * Disposes the component and the associated ressources
  70555. */
  70556. dispose(): void;
  70557. private _gatherRenderTargets;
  70558. }
  70559. }
  70560. declare module BABYLON {
  70561. /** @hidden */
  70562. export var motionBlurPixelShader: {
  70563. name: string;
  70564. shader: string;
  70565. };
  70566. }
  70567. declare module BABYLON {
  70568. /**
  70569. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70570. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70571. * As an example, all you have to do is to create the post-process:
  70572. * var mb = new BABYLON.MotionBlurPostProcess(
  70573. * 'mb', // The name of the effect.
  70574. * scene, // The scene containing the objects to blur according to their velocity.
  70575. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70576. * camera // The camera to apply the render pass to.
  70577. * );
  70578. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70579. */
  70580. export class MotionBlurPostProcess extends PostProcess {
  70581. /**
  70582. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70583. */
  70584. motionStrength: number;
  70585. /**
  70586. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70587. */
  70588. get motionBlurSamples(): number;
  70589. /**
  70590. * Sets the number of iterations to be used for motion blur quality
  70591. */
  70592. set motionBlurSamples(samples: number);
  70593. private _motionBlurSamples;
  70594. private _forceGeometryBuffer;
  70595. private _geometryBufferRenderer;
  70596. private _prePassRenderer;
  70597. /**
  70598. * Gets a string identifying the name of the class
  70599. * @returns "MotionBlurPostProcess" string
  70600. */
  70601. getClassName(): string;
  70602. /**
  70603. * Creates a new instance MotionBlurPostProcess
  70604. * @param name The name of the effect.
  70605. * @param scene The scene containing the objects to blur according to their velocity.
  70606. * @param options The required width/height ratio to downsize to before computing the render pass.
  70607. * @param camera The camera to apply the render pass to.
  70608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70609. * @param engine The engine which the post process will be applied. (default: current engine)
  70610. * @param reusable If the post process can be reused on the same frame. (default: false)
  70611. * @param textureType Type of textures used when performing the post process. (default: 0)
  70612. * @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)
  70613. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70614. */
  70615. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70616. /**
  70617. * Excludes the given skinned mesh from computing bones velocities.
  70618. * 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.
  70619. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70620. */
  70621. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70622. /**
  70623. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70624. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70625. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70626. */
  70627. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70628. /**
  70629. * Disposes the post process.
  70630. * @param camera The camera to dispose the post process on.
  70631. */
  70632. dispose(camera?: Camera): void;
  70633. /** @hidden */
  70634. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70635. }
  70636. }
  70637. declare module BABYLON {
  70638. /** @hidden */
  70639. export var refractionPixelShader: {
  70640. name: string;
  70641. shader: string;
  70642. };
  70643. }
  70644. declare module BABYLON {
  70645. /**
  70646. * Post process which applies a refractin texture
  70647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70648. */
  70649. export class RefractionPostProcess extends PostProcess {
  70650. private _refTexture;
  70651. private _ownRefractionTexture;
  70652. /** the base color of the refraction (used to taint the rendering) */
  70653. color: Color3;
  70654. /** simulated refraction depth */
  70655. depth: number;
  70656. /** the coefficient of the base color (0 to remove base color tainting) */
  70657. colorLevel: number;
  70658. /** Gets the url used to load the refraction texture */
  70659. refractionTextureUrl: string;
  70660. /**
  70661. * Gets or sets the refraction texture
  70662. * Please note that you are responsible for disposing the texture if you set it manually
  70663. */
  70664. get refractionTexture(): Texture;
  70665. set refractionTexture(value: Texture);
  70666. /**
  70667. * Gets a string identifying the name of the class
  70668. * @returns "RefractionPostProcess" string
  70669. */
  70670. getClassName(): string;
  70671. /**
  70672. * Initializes the RefractionPostProcess
  70673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70674. * @param name The name of the effect.
  70675. * @param refractionTextureUrl Url of the refraction texture to use
  70676. * @param color the base color of the refraction (used to taint the rendering)
  70677. * @param depth simulated refraction depth
  70678. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70679. * @param camera The camera to apply the render pass to.
  70680. * @param options The required width/height ratio to downsize to before computing the render pass.
  70681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70682. * @param engine The engine which the post process will be applied. (default: current engine)
  70683. * @param reusable If the post process can be reused on the same frame. (default: false)
  70684. */
  70685. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70686. /**
  70687. * Disposes of the post process
  70688. * @param camera Camera to dispose post process on
  70689. */
  70690. dispose(camera: Camera): void;
  70691. /** @hidden */
  70692. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70693. }
  70694. }
  70695. declare module BABYLON {
  70696. /** @hidden */
  70697. export var sharpenPixelShader: {
  70698. name: string;
  70699. shader: string;
  70700. };
  70701. }
  70702. declare module BABYLON {
  70703. /**
  70704. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70705. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70706. */
  70707. export class SharpenPostProcess extends PostProcess {
  70708. /**
  70709. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70710. */
  70711. colorAmount: number;
  70712. /**
  70713. * How much sharpness should be applied (default: 0.3)
  70714. */
  70715. edgeAmount: number;
  70716. /**
  70717. * Gets a string identifying the name of the class
  70718. * @returns "SharpenPostProcess" string
  70719. */
  70720. getClassName(): string;
  70721. /**
  70722. * Creates a new instance ConvolutionPostProcess
  70723. * @param name The name of the effect.
  70724. * @param options The required width/height ratio to downsize to before computing the render pass.
  70725. * @param camera The camera to apply the render pass to.
  70726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70727. * @param engine The engine which the post process will be applied. (default: current engine)
  70728. * @param reusable If the post process can be reused on the same frame. (default: false)
  70729. * @param textureType Type of textures used when performing the post process. (default: 0)
  70730. * @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)
  70731. */
  70732. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70733. /** @hidden */
  70734. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70735. }
  70736. }
  70737. declare module BABYLON {
  70738. /**
  70739. * PostProcessRenderPipeline
  70740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70741. */
  70742. export class PostProcessRenderPipeline {
  70743. private engine;
  70744. private _renderEffects;
  70745. private _renderEffectsForIsolatedPass;
  70746. /**
  70747. * List of inspectable custom properties (used by the Inspector)
  70748. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70749. */
  70750. inspectableCustomProperties: IInspectable[];
  70751. /**
  70752. * @hidden
  70753. */
  70754. protected _cameras: Camera[];
  70755. /** @hidden */
  70756. _name: string;
  70757. /**
  70758. * Gets pipeline name
  70759. */
  70760. get name(): string;
  70761. /** Gets the list of attached cameras */
  70762. get cameras(): Camera[];
  70763. /**
  70764. * Initializes a PostProcessRenderPipeline
  70765. * @param engine engine to add the pipeline to
  70766. * @param name name of the pipeline
  70767. */
  70768. constructor(engine: Engine, name: string);
  70769. /**
  70770. * Gets the class name
  70771. * @returns "PostProcessRenderPipeline"
  70772. */
  70773. getClassName(): string;
  70774. /**
  70775. * If all the render effects in the pipeline are supported
  70776. */
  70777. get isSupported(): boolean;
  70778. /**
  70779. * Adds an effect to the pipeline
  70780. * @param renderEffect the effect to add
  70781. */
  70782. addEffect(renderEffect: PostProcessRenderEffect): void;
  70783. /** @hidden */
  70784. _rebuild(): void;
  70785. /** @hidden */
  70786. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70787. /** @hidden */
  70788. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70789. /** @hidden */
  70790. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70791. /** @hidden */
  70792. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70793. /** @hidden */
  70794. _attachCameras(cameras: Camera, unique: boolean): void;
  70795. /** @hidden */
  70796. _attachCameras(cameras: Camera[], unique: boolean): void;
  70797. /** @hidden */
  70798. _detachCameras(cameras: Camera): void;
  70799. /** @hidden */
  70800. _detachCameras(cameras: Nullable<Camera[]>): void;
  70801. /** @hidden */
  70802. _update(): void;
  70803. /** @hidden */
  70804. _reset(): void;
  70805. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70806. /**
  70807. * Sets the required values to the prepass renderer.
  70808. * @param prePassRenderer defines the prepass renderer to setup.
  70809. * @returns true if the pre pass is needed.
  70810. */
  70811. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70812. /**
  70813. * Disposes of the pipeline
  70814. */
  70815. dispose(): void;
  70816. }
  70817. }
  70818. declare module BABYLON {
  70819. /**
  70820. * PostProcessRenderPipelineManager class
  70821. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70822. */
  70823. export class PostProcessRenderPipelineManager {
  70824. private _renderPipelines;
  70825. /**
  70826. * Initializes a PostProcessRenderPipelineManager
  70827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70828. */
  70829. constructor();
  70830. /**
  70831. * Gets the list of supported render pipelines
  70832. */
  70833. get supportedPipelines(): PostProcessRenderPipeline[];
  70834. /**
  70835. * Adds a pipeline to the manager
  70836. * @param renderPipeline The pipeline to add
  70837. */
  70838. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70839. /**
  70840. * Attaches a camera to the pipeline
  70841. * @param renderPipelineName The name of the pipeline to attach to
  70842. * @param cameras the camera to attach
  70843. * @param unique if the camera can be attached multiple times to the pipeline
  70844. */
  70845. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70846. /**
  70847. * Detaches a camera from the pipeline
  70848. * @param renderPipelineName The name of the pipeline to detach from
  70849. * @param cameras the camera to detach
  70850. */
  70851. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70852. /**
  70853. * Enables an effect by name on a pipeline
  70854. * @param renderPipelineName the name of the pipeline to enable the effect in
  70855. * @param renderEffectName the name of the effect to enable
  70856. * @param cameras the cameras that the effect should be enabled on
  70857. */
  70858. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70859. /**
  70860. * Disables an effect by name on a pipeline
  70861. * @param renderPipelineName the name of the pipeline to disable the effect in
  70862. * @param renderEffectName the name of the effect to disable
  70863. * @param cameras the cameras that the effect should be disabled on
  70864. */
  70865. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70866. /**
  70867. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70868. */
  70869. update(): void;
  70870. /** @hidden */
  70871. _rebuild(): void;
  70872. /**
  70873. * Disposes of the manager and pipelines
  70874. */
  70875. dispose(): void;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. interface Scene {
  70880. /** @hidden (Backing field) */
  70881. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70882. /**
  70883. * Gets the postprocess render pipeline manager
  70884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70885. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70886. */
  70887. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70888. }
  70889. /**
  70890. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70891. */
  70892. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70893. /**
  70894. * The component name helpfull to identify the component in the list of scene components.
  70895. */
  70896. readonly name: string;
  70897. /**
  70898. * The scene the component belongs to.
  70899. */
  70900. scene: Scene;
  70901. /**
  70902. * Creates a new instance of the component for the given scene
  70903. * @param scene Defines the scene to register the component in
  70904. */
  70905. constructor(scene: Scene);
  70906. /**
  70907. * Registers the component in a given scene
  70908. */
  70909. register(): void;
  70910. /**
  70911. * Rebuilds the elements related to this component in case of
  70912. * context lost for instance.
  70913. */
  70914. rebuild(): void;
  70915. /**
  70916. * Disposes the component and the associated ressources
  70917. */
  70918. dispose(): void;
  70919. private _gatherRenderTargets;
  70920. }
  70921. }
  70922. declare module BABYLON {
  70923. /**
  70924. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70925. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70926. */
  70927. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70928. private _scene;
  70929. private _camerasToBeAttached;
  70930. /**
  70931. * ID of the sharpen post process,
  70932. */
  70933. private readonly SharpenPostProcessId;
  70934. /**
  70935. * @ignore
  70936. * ID of the image processing post process;
  70937. */
  70938. readonly ImageProcessingPostProcessId: string;
  70939. /**
  70940. * @ignore
  70941. * ID of the Fast Approximate Anti-Aliasing post process;
  70942. */
  70943. readonly FxaaPostProcessId: string;
  70944. /**
  70945. * ID of the chromatic aberration post process,
  70946. */
  70947. private readonly ChromaticAberrationPostProcessId;
  70948. /**
  70949. * ID of the grain post process
  70950. */
  70951. private readonly GrainPostProcessId;
  70952. /**
  70953. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70954. */
  70955. sharpen: SharpenPostProcess;
  70956. private _sharpenEffect;
  70957. private bloom;
  70958. /**
  70959. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70960. */
  70961. depthOfField: DepthOfFieldEffect;
  70962. /**
  70963. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70964. */
  70965. fxaa: FxaaPostProcess;
  70966. /**
  70967. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70968. */
  70969. imageProcessing: ImageProcessingPostProcess;
  70970. /**
  70971. * Chromatic aberration post process which will shift rgb colors in the image
  70972. */
  70973. chromaticAberration: ChromaticAberrationPostProcess;
  70974. private _chromaticAberrationEffect;
  70975. /**
  70976. * Grain post process which add noise to the image
  70977. */
  70978. grain: GrainPostProcess;
  70979. private _grainEffect;
  70980. /**
  70981. * Glow post process which adds a glow to emissive areas of the image
  70982. */
  70983. private _glowLayer;
  70984. /**
  70985. * Animations which can be used to tweak settings over a period of time
  70986. */
  70987. animations: Animation[];
  70988. private _imageProcessingConfigurationObserver;
  70989. private _sharpenEnabled;
  70990. private _bloomEnabled;
  70991. private _depthOfFieldEnabled;
  70992. private _depthOfFieldBlurLevel;
  70993. private _fxaaEnabled;
  70994. private _imageProcessingEnabled;
  70995. private _defaultPipelineTextureType;
  70996. private _bloomScale;
  70997. private _chromaticAberrationEnabled;
  70998. private _grainEnabled;
  70999. private _buildAllowed;
  71000. /**
  71001. * Gets active scene
  71002. */
  71003. get scene(): Scene;
  71004. /**
  71005. * Enable or disable the sharpen process from the pipeline
  71006. */
  71007. set sharpenEnabled(enabled: boolean);
  71008. get sharpenEnabled(): boolean;
  71009. private _resizeObserver;
  71010. private _hardwareScaleLevel;
  71011. private _bloomKernel;
  71012. /**
  71013. * Specifies the size of the bloom blur kernel, relative to the final output size
  71014. */
  71015. get bloomKernel(): number;
  71016. set bloomKernel(value: number);
  71017. /**
  71018. * Specifies the weight of the bloom in the final rendering
  71019. */
  71020. private _bloomWeight;
  71021. /**
  71022. * Specifies the luma threshold for the area that will be blurred by the bloom
  71023. */
  71024. private _bloomThreshold;
  71025. private _hdr;
  71026. /**
  71027. * The strength of the bloom.
  71028. */
  71029. set bloomWeight(value: number);
  71030. get bloomWeight(): number;
  71031. /**
  71032. * The strength of the bloom.
  71033. */
  71034. set bloomThreshold(value: number);
  71035. get bloomThreshold(): number;
  71036. /**
  71037. * The scale of the bloom, lower value will provide better performance.
  71038. */
  71039. set bloomScale(value: number);
  71040. get bloomScale(): number;
  71041. /**
  71042. * Enable or disable the bloom from the pipeline
  71043. */
  71044. set bloomEnabled(enabled: boolean);
  71045. get bloomEnabled(): boolean;
  71046. private _rebuildBloom;
  71047. /**
  71048. * If the depth of field is enabled.
  71049. */
  71050. get depthOfFieldEnabled(): boolean;
  71051. set depthOfFieldEnabled(enabled: boolean);
  71052. /**
  71053. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71054. */
  71055. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71056. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71057. /**
  71058. * If the anti aliasing is enabled.
  71059. */
  71060. set fxaaEnabled(enabled: boolean);
  71061. get fxaaEnabled(): boolean;
  71062. private _samples;
  71063. /**
  71064. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71065. */
  71066. set samples(sampleCount: number);
  71067. get samples(): number;
  71068. /**
  71069. * If image processing is enabled.
  71070. */
  71071. set imageProcessingEnabled(enabled: boolean);
  71072. get imageProcessingEnabled(): boolean;
  71073. /**
  71074. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71075. */
  71076. set glowLayerEnabled(enabled: boolean);
  71077. get glowLayerEnabled(): boolean;
  71078. /**
  71079. * Gets the glow layer (or null if not defined)
  71080. */
  71081. get glowLayer(): Nullable<GlowLayer>;
  71082. /**
  71083. * Enable or disable the chromaticAberration process from the pipeline
  71084. */
  71085. set chromaticAberrationEnabled(enabled: boolean);
  71086. get chromaticAberrationEnabled(): boolean;
  71087. /**
  71088. * Enable or disable the grain process from the pipeline
  71089. */
  71090. set grainEnabled(enabled: boolean);
  71091. get grainEnabled(): boolean;
  71092. /**
  71093. * @constructor
  71094. * @param name - The rendering pipeline name (default: "")
  71095. * @param hdr - If high dynamic range textures should be used (default: true)
  71096. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71097. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71098. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71099. */
  71100. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71101. /**
  71102. * Get the class name
  71103. * @returns "DefaultRenderingPipeline"
  71104. */
  71105. getClassName(): string;
  71106. /**
  71107. * Force the compilation of the entire pipeline.
  71108. */
  71109. prepare(): void;
  71110. private _hasCleared;
  71111. private _prevPostProcess;
  71112. private _prevPrevPostProcess;
  71113. private _setAutoClearAndTextureSharing;
  71114. private _depthOfFieldSceneObserver;
  71115. private _buildPipeline;
  71116. private _disposePostProcesses;
  71117. /**
  71118. * Adds a camera to the pipeline
  71119. * @param camera the camera to be added
  71120. */
  71121. addCamera(camera: Camera): void;
  71122. /**
  71123. * Removes a camera from the pipeline
  71124. * @param camera the camera to remove
  71125. */
  71126. removeCamera(camera: Camera): void;
  71127. /**
  71128. * Dispose of the pipeline and stop all post processes
  71129. */
  71130. dispose(): void;
  71131. /**
  71132. * Serialize the rendering pipeline (Used when exporting)
  71133. * @returns the serialized object
  71134. */
  71135. serialize(): any;
  71136. /**
  71137. * Parse the serialized pipeline
  71138. * @param source Source pipeline.
  71139. * @param scene The scene to load the pipeline to.
  71140. * @param rootUrl The URL of the serialized pipeline.
  71141. * @returns An instantiated pipeline from the serialized object.
  71142. */
  71143. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71144. }
  71145. }
  71146. declare module BABYLON {
  71147. /** @hidden */
  71148. export var lensHighlightsPixelShader: {
  71149. name: string;
  71150. shader: string;
  71151. };
  71152. }
  71153. declare module BABYLON {
  71154. /** @hidden */
  71155. export var depthOfFieldPixelShader: {
  71156. name: string;
  71157. shader: string;
  71158. };
  71159. }
  71160. declare module BABYLON {
  71161. /**
  71162. * BABYLON.JS Chromatic Aberration GLSL Shader
  71163. * Author: Olivier Guyot
  71164. * Separates very slightly R, G and B colors on the edges of the screen
  71165. * Inspired by Francois Tarlier & Martins Upitis
  71166. */
  71167. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71168. /**
  71169. * @ignore
  71170. * The chromatic aberration PostProcess id in the pipeline
  71171. */
  71172. LensChromaticAberrationEffect: string;
  71173. /**
  71174. * @ignore
  71175. * The highlights enhancing PostProcess id in the pipeline
  71176. */
  71177. HighlightsEnhancingEffect: string;
  71178. /**
  71179. * @ignore
  71180. * The depth-of-field PostProcess id in the pipeline
  71181. */
  71182. LensDepthOfFieldEffect: string;
  71183. private _scene;
  71184. private _depthTexture;
  71185. private _grainTexture;
  71186. private _chromaticAberrationPostProcess;
  71187. private _highlightsPostProcess;
  71188. private _depthOfFieldPostProcess;
  71189. private _edgeBlur;
  71190. private _grainAmount;
  71191. private _chromaticAberration;
  71192. private _distortion;
  71193. private _highlightsGain;
  71194. private _highlightsThreshold;
  71195. private _dofDistance;
  71196. private _dofAperture;
  71197. private _dofDarken;
  71198. private _dofPentagon;
  71199. private _blurNoise;
  71200. /**
  71201. * @constructor
  71202. *
  71203. * Effect parameters are as follow:
  71204. * {
  71205. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71206. * edge_blur: number; // from 0 to x (1 for realism)
  71207. * distortion: number; // from 0 to x (1 for realism)
  71208. * grain_amount: number; // from 0 to 1
  71209. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71210. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71211. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71212. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71213. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71214. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71215. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71216. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71217. * }
  71218. * Note: if an effect parameter is unset, effect is disabled
  71219. *
  71220. * @param name The rendering pipeline name
  71221. * @param parameters - An object containing all parameters (see above)
  71222. * @param scene The scene linked to this pipeline
  71223. * @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)
  71224. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71225. */
  71226. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71227. /**
  71228. * Get the class name
  71229. * @returns "LensRenderingPipeline"
  71230. */
  71231. getClassName(): string;
  71232. /**
  71233. * Gets associated scene
  71234. */
  71235. get scene(): Scene;
  71236. /**
  71237. * Gets or sets the edge blur
  71238. */
  71239. get edgeBlur(): number;
  71240. set edgeBlur(value: number);
  71241. /**
  71242. * Gets or sets the grain amount
  71243. */
  71244. get grainAmount(): number;
  71245. set grainAmount(value: number);
  71246. /**
  71247. * Gets or sets the chromatic aberration amount
  71248. */
  71249. get chromaticAberration(): number;
  71250. set chromaticAberration(value: number);
  71251. /**
  71252. * Gets or sets the depth of field aperture
  71253. */
  71254. get dofAperture(): number;
  71255. set dofAperture(value: number);
  71256. /**
  71257. * Gets or sets the edge distortion
  71258. */
  71259. get edgeDistortion(): number;
  71260. set edgeDistortion(value: number);
  71261. /**
  71262. * Gets or sets the depth of field distortion
  71263. */
  71264. get dofDistortion(): number;
  71265. set dofDistortion(value: number);
  71266. /**
  71267. * Gets or sets the darken out of focus amount
  71268. */
  71269. get darkenOutOfFocus(): number;
  71270. set darkenOutOfFocus(value: number);
  71271. /**
  71272. * Gets or sets a boolean indicating if blur noise is enabled
  71273. */
  71274. get blurNoise(): boolean;
  71275. set blurNoise(value: boolean);
  71276. /**
  71277. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71278. */
  71279. get pentagonBokeh(): boolean;
  71280. set pentagonBokeh(value: boolean);
  71281. /**
  71282. * Gets or sets the highlight grain amount
  71283. */
  71284. get highlightsGain(): number;
  71285. set highlightsGain(value: number);
  71286. /**
  71287. * Gets or sets the highlight threshold
  71288. */
  71289. get highlightsThreshold(): number;
  71290. set highlightsThreshold(value: number);
  71291. /**
  71292. * Sets the amount of blur at the edges
  71293. * @param amount blur amount
  71294. */
  71295. setEdgeBlur(amount: number): void;
  71296. /**
  71297. * Sets edge blur to 0
  71298. */
  71299. disableEdgeBlur(): void;
  71300. /**
  71301. * Sets the amout of grain
  71302. * @param amount Amount of grain
  71303. */
  71304. setGrainAmount(amount: number): void;
  71305. /**
  71306. * Set grain amount to 0
  71307. */
  71308. disableGrain(): void;
  71309. /**
  71310. * Sets the chromatic aberration amount
  71311. * @param amount amount of chromatic aberration
  71312. */
  71313. setChromaticAberration(amount: number): void;
  71314. /**
  71315. * Sets chromatic aberration amount to 0
  71316. */
  71317. disableChromaticAberration(): void;
  71318. /**
  71319. * Sets the EdgeDistortion amount
  71320. * @param amount amount of EdgeDistortion
  71321. */
  71322. setEdgeDistortion(amount: number): void;
  71323. /**
  71324. * Sets edge distortion to 0
  71325. */
  71326. disableEdgeDistortion(): void;
  71327. /**
  71328. * Sets the FocusDistance amount
  71329. * @param amount amount of FocusDistance
  71330. */
  71331. setFocusDistance(amount: number): void;
  71332. /**
  71333. * Disables depth of field
  71334. */
  71335. disableDepthOfField(): void;
  71336. /**
  71337. * Sets the Aperture amount
  71338. * @param amount amount of Aperture
  71339. */
  71340. setAperture(amount: number): void;
  71341. /**
  71342. * Sets the DarkenOutOfFocus amount
  71343. * @param amount amount of DarkenOutOfFocus
  71344. */
  71345. setDarkenOutOfFocus(amount: number): void;
  71346. private _pentagonBokehIsEnabled;
  71347. /**
  71348. * Creates a pentagon bokeh effect
  71349. */
  71350. enablePentagonBokeh(): void;
  71351. /**
  71352. * Disables the pentagon bokeh effect
  71353. */
  71354. disablePentagonBokeh(): void;
  71355. /**
  71356. * Enables noise blur
  71357. */
  71358. enableNoiseBlur(): void;
  71359. /**
  71360. * Disables noise blur
  71361. */
  71362. disableNoiseBlur(): void;
  71363. /**
  71364. * Sets the HighlightsGain amount
  71365. * @param amount amount of HighlightsGain
  71366. */
  71367. setHighlightsGain(amount: number): void;
  71368. /**
  71369. * Sets the HighlightsThreshold amount
  71370. * @param amount amount of HighlightsThreshold
  71371. */
  71372. setHighlightsThreshold(amount: number): void;
  71373. /**
  71374. * Disables highlights
  71375. */
  71376. disableHighlights(): void;
  71377. /**
  71378. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71379. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71380. */
  71381. dispose(disableDepthRender?: boolean): void;
  71382. private _createChromaticAberrationPostProcess;
  71383. private _createHighlightsPostProcess;
  71384. private _createDepthOfFieldPostProcess;
  71385. private _createGrainTexture;
  71386. }
  71387. }
  71388. declare module BABYLON {
  71389. /**
  71390. * Contains all parameters needed for the prepass to perform
  71391. * screen space subsurface scattering
  71392. */
  71393. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71394. /**
  71395. * Is subsurface enabled
  71396. */
  71397. enabled: boolean;
  71398. /**
  71399. * Name of the configuration
  71400. */
  71401. name: string;
  71402. /**
  71403. * Textures that should be present in the MRT for this effect to work
  71404. */
  71405. readonly texturesRequired: number[];
  71406. }
  71407. }
  71408. declare module BABYLON {
  71409. /** @hidden */
  71410. export var ssao2PixelShader: {
  71411. name: string;
  71412. shader: string;
  71413. };
  71414. }
  71415. declare module BABYLON {
  71416. /** @hidden */
  71417. export var ssaoCombinePixelShader: {
  71418. name: string;
  71419. shader: string;
  71420. };
  71421. }
  71422. declare module BABYLON {
  71423. /**
  71424. * Render pipeline to produce ssao effect
  71425. */
  71426. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71427. /**
  71428. * @ignore
  71429. * The PassPostProcess id in the pipeline that contains the original scene color
  71430. */
  71431. SSAOOriginalSceneColorEffect: string;
  71432. /**
  71433. * @ignore
  71434. * The SSAO PostProcess id in the pipeline
  71435. */
  71436. SSAORenderEffect: string;
  71437. /**
  71438. * @ignore
  71439. * The horizontal blur PostProcess id in the pipeline
  71440. */
  71441. SSAOBlurHRenderEffect: string;
  71442. /**
  71443. * @ignore
  71444. * The vertical blur PostProcess id in the pipeline
  71445. */
  71446. SSAOBlurVRenderEffect: string;
  71447. /**
  71448. * @ignore
  71449. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71450. */
  71451. SSAOCombineRenderEffect: string;
  71452. /**
  71453. * The output strength of the SSAO post-process. Default value is 1.0.
  71454. */
  71455. totalStrength: number;
  71456. /**
  71457. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71458. */
  71459. maxZ: number;
  71460. /**
  71461. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71462. */
  71463. minZAspect: number;
  71464. private _samples;
  71465. /**
  71466. * Number of samples used for the SSAO calculations. Default value is 8
  71467. */
  71468. set samples(n: number);
  71469. get samples(): number;
  71470. private _textureSamples;
  71471. /**
  71472. * Number of samples to use for antialiasing
  71473. */
  71474. set textureSamples(n: number);
  71475. get textureSamples(): number;
  71476. /**
  71477. * Force rendering the geometry through geometry buffer
  71478. */
  71479. private _forceGeometryBuffer;
  71480. /**
  71481. * Ratio object used for SSAO ratio and blur ratio
  71482. */
  71483. private _ratio;
  71484. /**
  71485. * Dynamically generated sphere sampler.
  71486. */
  71487. private _sampleSphere;
  71488. /**
  71489. * Blur filter offsets
  71490. */
  71491. private _samplerOffsets;
  71492. private _expensiveBlur;
  71493. /**
  71494. * If bilateral blur should be used
  71495. */
  71496. set expensiveBlur(b: boolean);
  71497. get expensiveBlur(): boolean;
  71498. /**
  71499. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71500. */
  71501. radius: number;
  71502. /**
  71503. * The base color of the SSAO post-process
  71504. * The final result is "base + ssao" between [0, 1]
  71505. */
  71506. base: number;
  71507. /**
  71508. * Support test.
  71509. */
  71510. static get IsSupported(): boolean;
  71511. private _scene;
  71512. private _randomTexture;
  71513. private _originalColorPostProcess;
  71514. private _ssaoPostProcess;
  71515. private _blurHPostProcess;
  71516. private _blurVPostProcess;
  71517. private _ssaoCombinePostProcess;
  71518. private _prePassRenderer;
  71519. /**
  71520. * Gets active scene
  71521. */
  71522. get scene(): Scene;
  71523. /**
  71524. * @constructor
  71525. * @param name The rendering pipeline name
  71526. * @param scene The scene linked to this pipeline
  71527. * @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 }
  71528. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71529. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71530. */
  71531. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71532. /**
  71533. * Get the class name
  71534. * @returns "SSAO2RenderingPipeline"
  71535. */
  71536. getClassName(): string;
  71537. /**
  71538. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71539. */
  71540. dispose(disableGeometryBufferRenderer?: boolean): void;
  71541. private _createBlurPostProcess;
  71542. /** @hidden */
  71543. _rebuild(): void;
  71544. private _bits;
  71545. private _radicalInverse_VdC;
  71546. private _hammersley;
  71547. private _hemisphereSample_uniform;
  71548. private _generateHemisphere;
  71549. private _getDefinesForSSAO;
  71550. private _createSSAOPostProcess;
  71551. private _createSSAOCombinePostProcess;
  71552. private _createRandomTexture;
  71553. /**
  71554. * Serialize the rendering pipeline (Used when exporting)
  71555. * @returns the serialized object
  71556. */
  71557. serialize(): any;
  71558. /**
  71559. * Parse the serialized pipeline
  71560. * @param source Source pipeline.
  71561. * @param scene The scene to load the pipeline to.
  71562. * @param rootUrl The URL of the serialized pipeline.
  71563. * @returns An instantiated pipeline from the serialized object.
  71564. */
  71565. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71566. }
  71567. }
  71568. declare module BABYLON {
  71569. /** @hidden */
  71570. export var ssaoPixelShader: {
  71571. name: string;
  71572. shader: string;
  71573. };
  71574. }
  71575. declare module BABYLON {
  71576. /**
  71577. * Render pipeline to produce ssao effect
  71578. */
  71579. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71580. /**
  71581. * @ignore
  71582. * The PassPostProcess id in the pipeline that contains the original scene color
  71583. */
  71584. SSAOOriginalSceneColorEffect: string;
  71585. /**
  71586. * @ignore
  71587. * The SSAO PostProcess id in the pipeline
  71588. */
  71589. SSAORenderEffect: string;
  71590. /**
  71591. * @ignore
  71592. * The horizontal blur PostProcess id in the pipeline
  71593. */
  71594. SSAOBlurHRenderEffect: string;
  71595. /**
  71596. * @ignore
  71597. * The vertical blur PostProcess id in the pipeline
  71598. */
  71599. SSAOBlurVRenderEffect: string;
  71600. /**
  71601. * @ignore
  71602. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71603. */
  71604. SSAOCombineRenderEffect: string;
  71605. /**
  71606. * The output strength of the SSAO post-process. Default value is 1.0.
  71607. */
  71608. totalStrength: number;
  71609. /**
  71610. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71611. */
  71612. radius: number;
  71613. /**
  71614. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71615. * Must not be equal to fallOff and superior to fallOff.
  71616. * Default value is 0.0075
  71617. */
  71618. area: number;
  71619. /**
  71620. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71621. * Must not be equal to area and inferior to area.
  71622. * Default value is 0.000001
  71623. */
  71624. fallOff: number;
  71625. /**
  71626. * The base color of the SSAO post-process
  71627. * The final result is "base + ssao" between [0, 1]
  71628. */
  71629. base: number;
  71630. private _scene;
  71631. private _depthTexture;
  71632. private _randomTexture;
  71633. private _originalColorPostProcess;
  71634. private _ssaoPostProcess;
  71635. private _blurHPostProcess;
  71636. private _blurVPostProcess;
  71637. private _ssaoCombinePostProcess;
  71638. private _firstUpdate;
  71639. /**
  71640. * Gets active scene
  71641. */
  71642. get scene(): Scene;
  71643. /**
  71644. * @constructor
  71645. * @param name - The rendering pipeline name
  71646. * @param scene - The scene linked to this pipeline
  71647. * @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 }
  71648. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71649. */
  71650. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71651. /**
  71652. * Get the class name
  71653. * @returns "SSAORenderingPipeline"
  71654. */
  71655. getClassName(): string;
  71656. /**
  71657. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71658. */
  71659. dispose(disableDepthRender?: boolean): void;
  71660. private _createBlurPostProcess;
  71661. /** @hidden */
  71662. _rebuild(): void;
  71663. private _createSSAOPostProcess;
  71664. private _createSSAOCombinePostProcess;
  71665. private _createRandomTexture;
  71666. }
  71667. }
  71668. declare module BABYLON {
  71669. /**
  71670. * Contains all parameters needed for the prepass to perform
  71671. * screen space reflections
  71672. */
  71673. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71674. /**
  71675. * Is ssr enabled
  71676. */
  71677. enabled: boolean;
  71678. /**
  71679. * Name of the configuration
  71680. */
  71681. name: string;
  71682. /**
  71683. * Textures that should be present in the MRT for this effect to work
  71684. */
  71685. readonly texturesRequired: number[];
  71686. }
  71687. }
  71688. declare module BABYLON {
  71689. /** @hidden */
  71690. export var screenSpaceReflectionPixelShader: {
  71691. name: string;
  71692. shader: string;
  71693. };
  71694. }
  71695. declare module BABYLON {
  71696. /**
  71697. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71698. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71699. */
  71700. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71701. /**
  71702. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71703. */
  71704. threshold: number;
  71705. /**
  71706. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71707. */
  71708. strength: number;
  71709. /**
  71710. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71711. */
  71712. reflectionSpecularFalloffExponent: number;
  71713. /**
  71714. * 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]
  71715. */
  71716. step: number;
  71717. /**
  71718. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71719. */
  71720. roughnessFactor: number;
  71721. private _forceGeometryBuffer;
  71722. private _geometryBufferRenderer;
  71723. private _prePassRenderer;
  71724. private _enableSmoothReflections;
  71725. private _reflectionSamples;
  71726. private _smoothSteps;
  71727. /**
  71728. * Gets a string identifying the name of the class
  71729. * @returns "ScreenSpaceReflectionPostProcess" string
  71730. */
  71731. getClassName(): string;
  71732. /**
  71733. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71734. * @param name The name of the effect.
  71735. * @param scene The scene containing the objects to calculate reflections.
  71736. * @param options The required width/height ratio to downsize to before computing the render pass.
  71737. * @param camera The camera to apply the render pass to.
  71738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71739. * @param engine The engine which the post process will be applied. (default: current engine)
  71740. * @param reusable If the post process can be reused on the same frame. (default: false)
  71741. * @param textureType Type of textures used when performing the post process. (default: 0)
  71742. * @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)
  71743. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71744. */
  71745. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71746. /**
  71747. * Gets wether or not smoothing reflections is enabled.
  71748. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71749. */
  71750. get enableSmoothReflections(): boolean;
  71751. /**
  71752. * Sets wether or not smoothing reflections is enabled.
  71753. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71754. */
  71755. set enableSmoothReflections(enabled: boolean);
  71756. /**
  71757. * Gets the number of samples taken while computing reflections. More samples count is high,
  71758. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71759. */
  71760. get reflectionSamples(): number;
  71761. /**
  71762. * Sets the number of samples taken while computing reflections. More samples count is high,
  71763. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71764. */
  71765. set reflectionSamples(samples: number);
  71766. /**
  71767. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71768. * more the post-process will require GPU power and can generate a drop in FPS.
  71769. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71770. */
  71771. get smoothSteps(): number;
  71772. set smoothSteps(steps: number);
  71773. private _updateEffectDefines;
  71774. /** @hidden */
  71775. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71776. }
  71777. }
  71778. declare module BABYLON {
  71779. /** @hidden */
  71780. export var standardPixelShader: {
  71781. name: string;
  71782. shader: string;
  71783. };
  71784. }
  71785. declare module BABYLON {
  71786. /**
  71787. * Standard rendering pipeline
  71788. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71789. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71790. */
  71791. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71792. /**
  71793. * Public members
  71794. */
  71795. /**
  71796. * Post-process which contains the original scene color before the pipeline applies all the effects
  71797. */
  71798. originalPostProcess: Nullable<PostProcess>;
  71799. /**
  71800. * Post-process used to down scale an image x4
  71801. */
  71802. downSampleX4PostProcess: Nullable<PostProcess>;
  71803. /**
  71804. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71805. */
  71806. brightPassPostProcess: Nullable<PostProcess>;
  71807. /**
  71808. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71809. */
  71810. blurHPostProcesses: PostProcess[];
  71811. /**
  71812. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71813. */
  71814. blurVPostProcesses: PostProcess[];
  71815. /**
  71816. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71817. */
  71818. textureAdderPostProcess: Nullable<PostProcess>;
  71819. /**
  71820. * Post-process used to create volumetric lighting effect
  71821. */
  71822. volumetricLightPostProcess: Nullable<PostProcess>;
  71823. /**
  71824. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71825. */
  71826. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71827. /**
  71828. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71829. */
  71830. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71831. /**
  71832. * Post-process used to merge the volumetric light effect and the real scene color
  71833. */
  71834. volumetricLightMergePostProces: Nullable<PostProcess>;
  71835. /**
  71836. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71837. */
  71838. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71839. /**
  71840. * Base post-process used to calculate the average luminance of the final image for HDR
  71841. */
  71842. luminancePostProcess: Nullable<PostProcess>;
  71843. /**
  71844. * Post-processes used to create down sample post-processes in order to get
  71845. * the average luminance of the final image for HDR
  71846. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71847. */
  71848. luminanceDownSamplePostProcesses: PostProcess[];
  71849. /**
  71850. * Post-process used to create a HDR effect (light adaptation)
  71851. */
  71852. hdrPostProcess: Nullable<PostProcess>;
  71853. /**
  71854. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71855. */
  71856. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71857. /**
  71858. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71859. */
  71860. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71861. /**
  71862. * Post-process used to merge the final HDR post-process and the real scene color
  71863. */
  71864. hdrFinalPostProcess: Nullable<PostProcess>;
  71865. /**
  71866. * Post-process used to create a lens flare effect
  71867. */
  71868. lensFlarePostProcess: Nullable<PostProcess>;
  71869. /**
  71870. * Post-process that merges the result of the lens flare post-process and the real scene color
  71871. */
  71872. lensFlareComposePostProcess: Nullable<PostProcess>;
  71873. /**
  71874. * Post-process used to create a motion blur effect
  71875. */
  71876. motionBlurPostProcess: Nullable<PostProcess>;
  71877. /**
  71878. * Post-process used to create a depth of field effect
  71879. */
  71880. depthOfFieldPostProcess: Nullable<PostProcess>;
  71881. /**
  71882. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71883. */
  71884. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71885. /**
  71886. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71887. */
  71888. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71889. /**
  71890. * Represents the brightness threshold in order to configure the illuminated surfaces
  71891. */
  71892. brightThreshold: number;
  71893. /**
  71894. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71895. */
  71896. blurWidth: number;
  71897. /**
  71898. * Sets if the blur for highlighted surfaces must be only horizontal
  71899. */
  71900. horizontalBlur: boolean;
  71901. /**
  71902. * Gets the overall exposure used by the pipeline
  71903. */
  71904. get exposure(): number;
  71905. /**
  71906. * Sets the overall exposure used by the pipeline
  71907. */
  71908. set exposure(value: number);
  71909. /**
  71910. * Texture used typically to simulate "dirty" on camera lens
  71911. */
  71912. lensTexture: Nullable<Texture>;
  71913. /**
  71914. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71915. */
  71916. volumetricLightCoefficient: number;
  71917. /**
  71918. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71919. */
  71920. volumetricLightPower: number;
  71921. /**
  71922. * Used the set the blur intensity to smooth the volumetric lights
  71923. */
  71924. volumetricLightBlurScale: number;
  71925. /**
  71926. * Light (spot or directional) used to generate the volumetric lights rays
  71927. * The source light must have a shadow generate so the pipeline can get its
  71928. * depth map
  71929. */
  71930. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71931. /**
  71932. * For eye adaptation, represents the minimum luminance the eye can see
  71933. */
  71934. hdrMinimumLuminance: number;
  71935. /**
  71936. * For eye adaptation, represents the decrease luminance speed
  71937. */
  71938. hdrDecreaseRate: number;
  71939. /**
  71940. * For eye adaptation, represents the increase luminance speed
  71941. */
  71942. hdrIncreaseRate: number;
  71943. /**
  71944. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71945. */
  71946. get hdrAutoExposure(): boolean;
  71947. /**
  71948. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71949. */
  71950. set hdrAutoExposure(value: boolean);
  71951. /**
  71952. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71953. */
  71954. lensColorTexture: Nullable<Texture>;
  71955. /**
  71956. * The overall strengh for the lens flare effect
  71957. */
  71958. lensFlareStrength: number;
  71959. /**
  71960. * Dispersion coefficient for lens flare ghosts
  71961. */
  71962. lensFlareGhostDispersal: number;
  71963. /**
  71964. * Main lens flare halo width
  71965. */
  71966. lensFlareHaloWidth: number;
  71967. /**
  71968. * Based on the lens distortion effect, defines how much the lens flare result
  71969. * is distorted
  71970. */
  71971. lensFlareDistortionStrength: number;
  71972. /**
  71973. * Configures the blur intensity used for for lens flare (halo)
  71974. */
  71975. lensFlareBlurWidth: number;
  71976. /**
  71977. * Lens star texture must be used to simulate rays on the flares and is available
  71978. * in the documentation
  71979. */
  71980. lensStarTexture: Nullable<Texture>;
  71981. /**
  71982. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71983. * flare effect by taking account of the dirt texture
  71984. */
  71985. lensFlareDirtTexture: Nullable<Texture>;
  71986. /**
  71987. * Represents the focal length for the depth of field effect
  71988. */
  71989. depthOfFieldDistance: number;
  71990. /**
  71991. * Represents the blur intensity for the blurred part of the depth of field effect
  71992. */
  71993. depthOfFieldBlurWidth: number;
  71994. /**
  71995. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71996. */
  71997. get motionStrength(): number;
  71998. /**
  71999. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72000. */
  72001. set motionStrength(strength: number);
  72002. /**
  72003. * Gets wether or not the motion blur post-process is object based or screen based.
  72004. */
  72005. get objectBasedMotionBlur(): boolean;
  72006. /**
  72007. * Sets wether or not the motion blur post-process should be object based or screen based
  72008. */
  72009. set objectBasedMotionBlur(value: boolean);
  72010. /**
  72011. * List of animations for the pipeline (IAnimatable implementation)
  72012. */
  72013. animations: Animation[];
  72014. /**
  72015. * Private members
  72016. */
  72017. private _scene;
  72018. private _currentDepthOfFieldSource;
  72019. private _basePostProcess;
  72020. private _fixedExposure;
  72021. private _currentExposure;
  72022. private _hdrAutoExposure;
  72023. private _hdrCurrentLuminance;
  72024. private _motionStrength;
  72025. private _isObjectBasedMotionBlur;
  72026. private _floatTextureType;
  72027. private _camerasToBeAttached;
  72028. private _ratio;
  72029. private _bloomEnabled;
  72030. private _depthOfFieldEnabled;
  72031. private _vlsEnabled;
  72032. private _lensFlareEnabled;
  72033. private _hdrEnabled;
  72034. private _motionBlurEnabled;
  72035. private _fxaaEnabled;
  72036. private _screenSpaceReflectionsEnabled;
  72037. private _motionBlurSamples;
  72038. private _volumetricLightStepsCount;
  72039. private _samples;
  72040. /**
  72041. * @ignore
  72042. * Specifies if the bloom pipeline is enabled
  72043. */
  72044. get BloomEnabled(): boolean;
  72045. set BloomEnabled(enabled: boolean);
  72046. /**
  72047. * @ignore
  72048. * Specifies if the depth of field pipeline is enabed
  72049. */
  72050. get DepthOfFieldEnabled(): boolean;
  72051. set DepthOfFieldEnabled(enabled: boolean);
  72052. /**
  72053. * @ignore
  72054. * Specifies if the lens flare pipeline is enabed
  72055. */
  72056. get LensFlareEnabled(): boolean;
  72057. set LensFlareEnabled(enabled: boolean);
  72058. /**
  72059. * @ignore
  72060. * Specifies if the HDR pipeline is enabled
  72061. */
  72062. get HDREnabled(): boolean;
  72063. set HDREnabled(enabled: boolean);
  72064. /**
  72065. * @ignore
  72066. * Specifies if the volumetric lights scattering effect is enabled
  72067. */
  72068. get VLSEnabled(): boolean;
  72069. set VLSEnabled(enabled: boolean);
  72070. /**
  72071. * @ignore
  72072. * Specifies if the motion blur effect is enabled
  72073. */
  72074. get MotionBlurEnabled(): boolean;
  72075. set MotionBlurEnabled(enabled: boolean);
  72076. /**
  72077. * Specifies if anti-aliasing is enabled
  72078. */
  72079. get fxaaEnabled(): boolean;
  72080. set fxaaEnabled(enabled: boolean);
  72081. /**
  72082. * Specifies if screen space reflections are enabled.
  72083. */
  72084. get screenSpaceReflectionsEnabled(): boolean;
  72085. set screenSpaceReflectionsEnabled(enabled: boolean);
  72086. /**
  72087. * Specifies the number of steps used to calculate the volumetric lights
  72088. * Typically in interval [50, 200]
  72089. */
  72090. get volumetricLightStepsCount(): number;
  72091. set volumetricLightStepsCount(count: number);
  72092. /**
  72093. * Specifies the number of samples used for the motion blur effect
  72094. * Typically in interval [16, 64]
  72095. */
  72096. get motionBlurSamples(): number;
  72097. set motionBlurSamples(samples: number);
  72098. /**
  72099. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72100. */
  72101. get samples(): number;
  72102. set samples(sampleCount: number);
  72103. /**
  72104. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72105. * @constructor
  72106. * @param name The rendering pipeline name
  72107. * @param scene The scene linked to this pipeline
  72108. * @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)
  72109. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72110. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72111. */
  72112. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72113. private _buildPipeline;
  72114. private _createDownSampleX4PostProcess;
  72115. private _createBrightPassPostProcess;
  72116. private _createBlurPostProcesses;
  72117. private _createTextureAdderPostProcess;
  72118. private _createVolumetricLightPostProcess;
  72119. private _createLuminancePostProcesses;
  72120. private _createHdrPostProcess;
  72121. private _createLensFlarePostProcess;
  72122. private _createDepthOfFieldPostProcess;
  72123. private _createMotionBlurPostProcess;
  72124. private _getDepthTexture;
  72125. private _disposePostProcesses;
  72126. /**
  72127. * Dispose of the pipeline and stop all post processes
  72128. */
  72129. dispose(): void;
  72130. /**
  72131. * Serialize the rendering pipeline (Used when exporting)
  72132. * @returns the serialized object
  72133. */
  72134. serialize(): any;
  72135. /**
  72136. * Parse the serialized pipeline
  72137. * @param source Source pipeline.
  72138. * @param scene The scene to load the pipeline to.
  72139. * @param rootUrl The URL of the serialized pipeline.
  72140. * @returns An instantiated pipeline from the serialized object.
  72141. */
  72142. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72143. /**
  72144. * Luminance steps
  72145. */
  72146. static LuminanceSteps: number;
  72147. }
  72148. }
  72149. declare module BABYLON {
  72150. /** @hidden */
  72151. export var stereoscopicInterlacePixelShader: {
  72152. name: string;
  72153. shader: string;
  72154. };
  72155. }
  72156. declare module BABYLON {
  72157. /**
  72158. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72159. */
  72160. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72161. private _stepSize;
  72162. private _passedProcess;
  72163. /**
  72164. * Gets a string identifying the name of the class
  72165. * @returns "StereoscopicInterlacePostProcessI" string
  72166. */
  72167. getClassName(): string;
  72168. /**
  72169. * Initializes a StereoscopicInterlacePostProcessI
  72170. * @param name The name of the effect.
  72171. * @param rigCameras The rig cameras to be appled to the post process
  72172. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72173. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72175. * @param engine The engine which the post process will be applied. (default: current engine)
  72176. * @param reusable If the post process can be reused on the same frame. (default: false)
  72177. */
  72178. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72179. }
  72180. /**
  72181. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72182. */
  72183. export class StereoscopicInterlacePostProcess extends PostProcess {
  72184. private _stepSize;
  72185. private _passedProcess;
  72186. /**
  72187. * Gets a string identifying the name of the class
  72188. * @returns "StereoscopicInterlacePostProcess" string
  72189. */
  72190. getClassName(): string;
  72191. /**
  72192. * Initializes a StereoscopicInterlacePostProcess
  72193. * @param name The name of the effect.
  72194. * @param rigCameras The rig cameras to be appled to the post process
  72195. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72197. * @param engine The engine which the post process will be applied. (default: current engine)
  72198. * @param reusable If the post process can be reused on the same frame. (default: false)
  72199. */
  72200. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72201. }
  72202. }
  72203. declare module BABYLON {
  72204. /** @hidden */
  72205. export var tonemapPixelShader: {
  72206. name: string;
  72207. shader: string;
  72208. };
  72209. }
  72210. declare module BABYLON {
  72211. /** Defines operator used for tonemapping */
  72212. export enum TonemappingOperator {
  72213. /** Hable */
  72214. Hable = 0,
  72215. /** Reinhard */
  72216. Reinhard = 1,
  72217. /** HejiDawson */
  72218. HejiDawson = 2,
  72219. /** Photographic */
  72220. Photographic = 3
  72221. }
  72222. /**
  72223. * Defines a post process to apply tone mapping
  72224. */
  72225. export class TonemapPostProcess extends PostProcess {
  72226. private _operator;
  72227. /** Defines the required exposure adjustement */
  72228. exposureAdjustment: number;
  72229. /**
  72230. * Gets a string identifying the name of the class
  72231. * @returns "TonemapPostProcess" string
  72232. */
  72233. getClassName(): string;
  72234. /**
  72235. * Creates a new TonemapPostProcess
  72236. * @param name defines the name of the postprocess
  72237. * @param _operator defines the operator to use
  72238. * @param exposureAdjustment defines the required exposure adjustement
  72239. * @param camera defines the camera to use (can be null)
  72240. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72241. * @param engine defines the hosting engine (can be ignore if camera is set)
  72242. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72243. */
  72244. constructor(name: string, _operator: TonemappingOperator,
  72245. /** Defines the required exposure adjustement */
  72246. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72247. }
  72248. }
  72249. declare module BABYLON {
  72250. /** @hidden */
  72251. export var volumetricLightScatteringPixelShader: {
  72252. name: string;
  72253. shader: string;
  72254. };
  72255. }
  72256. declare module BABYLON {
  72257. /** @hidden */
  72258. export var volumetricLightScatteringPassVertexShader: {
  72259. name: string;
  72260. shader: string;
  72261. };
  72262. }
  72263. declare module BABYLON {
  72264. /** @hidden */
  72265. export var volumetricLightScatteringPassPixelShader: {
  72266. name: string;
  72267. shader: string;
  72268. };
  72269. }
  72270. declare module BABYLON {
  72271. /**
  72272. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72273. */
  72274. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72275. private _volumetricLightScatteringPass;
  72276. private _volumetricLightScatteringRTT;
  72277. private _viewPort;
  72278. private _screenCoordinates;
  72279. private _cachedDefines;
  72280. /**
  72281. * If not undefined, the mesh position is computed from the attached node position
  72282. */
  72283. attachedNode: {
  72284. position: Vector3;
  72285. };
  72286. /**
  72287. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72288. */
  72289. customMeshPosition: Vector3;
  72290. /**
  72291. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72292. */
  72293. useCustomMeshPosition: boolean;
  72294. /**
  72295. * If the post-process should inverse the light scattering direction
  72296. */
  72297. invert: boolean;
  72298. /**
  72299. * The internal mesh used by the post-process
  72300. */
  72301. mesh: Mesh;
  72302. /**
  72303. * @hidden
  72304. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72305. */
  72306. get useDiffuseColor(): boolean;
  72307. set useDiffuseColor(useDiffuseColor: boolean);
  72308. /**
  72309. * Array containing the excluded meshes not rendered in the internal pass
  72310. */
  72311. excludedMeshes: AbstractMesh[];
  72312. /**
  72313. * Controls the overall intensity of the post-process
  72314. */
  72315. exposure: number;
  72316. /**
  72317. * Dissipates each sample's contribution in range [0, 1]
  72318. */
  72319. decay: number;
  72320. /**
  72321. * Controls the overall intensity of each sample
  72322. */
  72323. weight: number;
  72324. /**
  72325. * Controls the density of each sample
  72326. */
  72327. density: number;
  72328. /**
  72329. * @constructor
  72330. * @param name The post-process name
  72331. * @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)
  72332. * @param camera The camera that the post-process will be attached to
  72333. * @param mesh The mesh used to create the light scattering
  72334. * @param samples The post-process quality, default 100
  72335. * @param samplingModeThe post-process filtering mode
  72336. * @param engine The babylon engine
  72337. * @param reusable If the post-process is reusable
  72338. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72339. */
  72340. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72341. /**
  72342. * Returns the string "VolumetricLightScatteringPostProcess"
  72343. * @returns "VolumetricLightScatteringPostProcess"
  72344. */
  72345. getClassName(): string;
  72346. private _isReady;
  72347. /**
  72348. * Sets the new light position for light scattering effect
  72349. * @param position The new custom light position
  72350. */
  72351. setCustomMeshPosition(position: Vector3): void;
  72352. /**
  72353. * Returns the light position for light scattering effect
  72354. * @return Vector3 The custom light position
  72355. */
  72356. getCustomMeshPosition(): Vector3;
  72357. /**
  72358. * Disposes the internal assets and detaches the post-process from the camera
  72359. */
  72360. dispose(camera: Camera): void;
  72361. /**
  72362. * Returns the render target texture used by the post-process
  72363. * @return the render target texture used by the post-process
  72364. */
  72365. getPass(): RenderTargetTexture;
  72366. private _meshExcluded;
  72367. private _createPass;
  72368. private _updateMeshScreenCoordinates;
  72369. /**
  72370. * Creates a default mesh for the Volumeric Light Scattering post-process
  72371. * @param name The mesh name
  72372. * @param scene The scene where to create the mesh
  72373. * @return the default mesh
  72374. */
  72375. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72376. }
  72377. }
  72378. declare module BABYLON {
  72379. /** @hidden */
  72380. export var screenSpaceCurvaturePixelShader: {
  72381. name: string;
  72382. shader: string;
  72383. };
  72384. }
  72385. declare module BABYLON {
  72386. /**
  72387. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72388. */
  72389. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72390. /**
  72391. * Defines how much ridge the curvature effect displays.
  72392. */
  72393. ridge: number;
  72394. /**
  72395. * Defines how much valley the curvature effect displays.
  72396. */
  72397. valley: number;
  72398. private _geometryBufferRenderer;
  72399. /**
  72400. * Gets a string identifying the name of the class
  72401. * @returns "ScreenSpaceCurvaturePostProcess" string
  72402. */
  72403. getClassName(): string;
  72404. /**
  72405. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72406. * @param name The name of the effect.
  72407. * @param scene The scene containing the objects to blur according to their velocity.
  72408. * @param options The required width/height ratio to downsize to before computing the render pass.
  72409. * @param camera The camera to apply the render pass to.
  72410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72411. * @param engine The engine which the post process will be applied. (default: current engine)
  72412. * @param reusable If the post process can be reused on the same frame. (default: false)
  72413. * @param textureType Type of textures used when performing the post process. (default: 0)
  72414. * @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)
  72415. */
  72416. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72417. /**
  72418. * Support test.
  72419. */
  72420. static get IsSupported(): boolean;
  72421. /** @hidden */
  72422. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72423. }
  72424. }
  72425. declare module BABYLON {
  72426. interface Scene {
  72427. /** @hidden (Backing field) */
  72428. _boundingBoxRenderer: BoundingBoxRenderer;
  72429. /** @hidden (Backing field) */
  72430. _forceShowBoundingBoxes: boolean;
  72431. /**
  72432. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72433. */
  72434. forceShowBoundingBoxes: boolean;
  72435. /**
  72436. * Gets the bounding box renderer associated with the scene
  72437. * @returns a BoundingBoxRenderer
  72438. */
  72439. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72440. }
  72441. interface AbstractMesh {
  72442. /** @hidden (Backing field) */
  72443. _showBoundingBox: boolean;
  72444. /**
  72445. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72446. */
  72447. showBoundingBox: boolean;
  72448. }
  72449. /**
  72450. * Component responsible of rendering the bounding box of the meshes in a scene.
  72451. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72452. */
  72453. export class BoundingBoxRenderer implements ISceneComponent {
  72454. /**
  72455. * The component name helpfull to identify the component in the list of scene components.
  72456. */
  72457. readonly name: string;
  72458. /**
  72459. * The scene the component belongs to.
  72460. */
  72461. scene: Scene;
  72462. /**
  72463. * Color of the bounding box lines placed in front of an object
  72464. */
  72465. frontColor: Color3;
  72466. /**
  72467. * Color of the bounding box lines placed behind an object
  72468. */
  72469. backColor: Color3;
  72470. /**
  72471. * Defines if the renderer should show the back lines or not
  72472. */
  72473. showBackLines: boolean;
  72474. /**
  72475. * Observable raised before rendering a bounding box
  72476. */
  72477. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72478. /**
  72479. * Observable raised after rendering a bounding box
  72480. */
  72481. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72482. /**
  72483. * @hidden
  72484. */
  72485. renderList: SmartArray<BoundingBox>;
  72486. private _colorShader;
  72487. private _vertexBuffers;
  72488. private _indexBuffer;
  72489. private _fillIndexBuffer;
  72490. private _fillIndexData;
  72491. /**
  72492. * Instantiates a new bounding box renderer in a scene.
  72493. * @param scene the scene the renderer renders in
  72494. */
  72495. constructor(scene: Scene);
  72496. /**
  72497. * Registers the component in a given scene
  72498. */
  72499. register(): void;
  72500. private _evaluateSubMesh;
  72501. private _activeMesh;
  72502. private _prepareRessources;
  72503. private _createIndexBuffer;
  72504. /**
  72505. * Rebuilds the elements related to this component in case of
  72506. * context lost for instance.
  72507. */
  72508. rebuild(): void;
  72509. /**
  72510. * @hidden
  72511. */
  72512. reset(): void;
  72513. /**
  72514. * Render the bounding boxes of a specific rendering group
  72515. * @param renderingGroupId defines the rendering group to render
  72516. */
  72517. render(renderingGroupId: number): void;
  72518. /**
  72519. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72520. * @param mesh Define the mesh to render the occlusion bounding box for
  72521. */
  72522. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72523. /**
  72524. * Dispose and release the resources attached to this renderer.
  72525. */
  72526. dispose(): void;
  72527. }
  72528. }
  72529. declare module BABYLON {
  72530. interface Scene {
  72531. /** @hidden (Backing field) */
  72532. _depthRenderer: {
  72533. [id: string]: DepthRenderer;
  72534. };
  72535. /**
  72536. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72537. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72538. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72539. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72540. * @returns the created depth renderer
  72541. */
  72542. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72543. /**
  72544. * Disables a depth renderer for a given camera
  72545. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72546. */
  72547. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72548. }
  72549. /**
  72550. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72551. * in several rendering techniques.
  72552. */
  72553. export class DepthRendererSceneComponent implements ISceneComponent {
  72554. /**
  72555. * The component name helpfull to identify the component in the list of scene components.
  72556. */
  72557. readonly name: string;
  72558. /**
  72559. * The scene the component belongs to.
  72560. */
  72561. scene: Scene;
  72562. /**
  72563. * Creates a new instance of the component for the given scene
  72564. * @param scene Defines the scene to register the component in
  72565. */
  72566. constructor(scene: Scene);
  72567. /**
  72568. * Registers the component in a given scene
  72569. */
  72570. register(): void;
  72571. /**
  72572. * Rebuilds the elements related to this component in case of
  72573. * context lost for instance.
  72574. */
  72575. rebuild(): void;
  72576. /**
  72577. * Disposes the component and the associated ressources
  72578. */
  72579. dispose(): void;
  72580. private _gatherRenderTargets;
  72581. private _gatherActiveCameraRenderTargets;
  72582. }
  72583. }
  72584. declare module BABYLON {
  72585. interface AbstractScene {
  72586. /** @hidden (Backing field) */
  72587. _prePassRenderer: Nullable<PrePassRenderer>;
  72588. /**
  72589. * Gets or Sets the current prepass renderer associated to the scene.
  72590. */
  72591. prePassRenderer: Nullable<PrePassRenderer>;
  72592. /**
  72593. * Enables the prepass and associates it with the scene
  72594. * @returns the PrePassRenderer
  72595. */
  72596. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72597. /**
  72598. * Disables the prepass associated with the scene
  72599. */
  72600. disablePrePassRenderer(): void;
  72601. }
  72602. /**
  72603. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72604. * in several rendering techniques.
  72605. */
  72606. export class PrePassRendererSceneComponent implements ISceneComponent {
  72607. /**
  72608. * The component name helpful to identify the component in the list of scene components.
  72609. */
  72610. readonly name: string;
  72611. /**
  72612. * The scene the component belongs to.
  72613. */
  72614. scene: Scene;
  72615. /**
  72616. * Creates a new instance of the component for the given scene
  72617. * @param scene Defines the scene to register the component in
  72618. */
  72619. constructor(scene: Scene);
  72620. /**
  72621. * Registers the component in a given scene
  72622. */
  72623. register(): void;
  72624. private _beforeCameraDraw;
  72625. private _afterCameraDraw;
  72626. private _beforeClearStage;
  72627. /**
  72628. * Rebuilds the elements related to this component in case of
  72629. * context lost for instance.
  72630. */
  72631. rebuild(): void;
  72632. /**
  72633. * Disposes the component and the associated ressources
  72634. */
  72635. dispose(): void;
  72636. }
  72637. }
  72638. declare module BABYLON {
  72639. /** @hidden */
  72640. export var fibonacci: {
  72641. name: string;
  72642. shader: string;
  72643. };
  72644. }
  72645. declare module BABYLON {
  72646. /** @hidden */
  72647. export var diffusionProfile: {
  72648. name: string;
  72649. shader: string;
  72650. };
  72651. }
  72652. declare module BABYLON {
  72653. /** @hidden */
  72654. export var subSurfaceScatteringPixelShader: {
  72655. name: string;
  72656. shader: string;
  72657. };
  72658. }
  72659. declare module BABYLON {
  72660. /**
  72661. * Sub surface scattering post process
  72662. */
  72663. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72664. /**
  72665. * Gets a string identifying the name of the class
  72666. * @returns "SubSurfaceScatteringPostProcess" string
  72667. */
  72668. getClassName(): string;
  72669. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72670. }
  72671. }
  72672. declare module BABYLON {
  72673. /**
  72674. * Contains all parameters needed for the prepass to perform
  72675. * screen space subsurface scattering
  72676. */
  72677. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72678. /** @hidden */
  72679. static _SceneComponentInitialization: (scene: Scene) => void;
  72680. private _ssDiffusionS;
  72681. private _ssFilterRadii;
  72682. private _ssDiffusionD;
  72683. /**
  72684. * Post process to attach for screen space subsurface scattering
  72685. */
  72686. postProcess: SubSurfaceScatteringPostProcess;
  72687. /**
  72688. * Diffusion profile color for subsurface scattering
  72689. */
  72690. get ssDiffusionS(): number[];
  72691. /**
  72692. * Diffusion profile max color channel value for subsurface scattering
  72693. */
  72694. get ssDiffusionD(): number[];
  72695. /**
  72696. * Diffusion profile filter radius for subsurface scattering
  72697. */
  72698. get ssFilterRadii(): number[];
  72699. /**
  72700. * Is subsurface enabled
  72701. */
  72702. enabled: boolean;
  72703. /**
  72704. * Name of the configuration
  72705. */
  72706. name: string;
  72707. /**
  72708. * Diffusion profile colors for subsurface scattering
  72709. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72710. * See ...
  72711. * Note that you can only store up to 5 of them
  72712. */
  72713. ssDiffusionProfileColors: Color3[];
  72714. /**
  72715. * Defines the ratio real world => scene units.
  72716. * Used for subsurface scattering
  72717. */
  72718. metersPerUnit: number;
  72719. /**
  72720. * Textures that should be present in the MRT for this effect to work
  72721. */
  72722. readonly texturesRequired: number[];
  72723. private _scene;
  72724. /**
  72725. * Builds a subsurface configuration object
  72726. * @param scene The scene
  72727. */
  72728. constructor(scene: Scene);
  72729. /**
  72730. * Adds a new diffusion profile.
  72731. * Useful for more realistic subsurface scattering on diverse materials.
  72732. * @param color The color of the diffusion profile. Should be the average color of the material.
  72733. * @return The index of the diffusion profile for the material subsurface configuration
  72734. */
  72735. addDiffusionProfile(color: Color3): number;
  72736. /**
  72737. * Creates the sss post process
  72738. * @return The created post process
  72739. */
  72740. createPostProcess(): SubSurfaceScatteringPostProcess;
  72741. /**
  72742. * Deletes all diffusion profiles.
  72743. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72744. */
  72745. clearAllDiffusionProfiles(): void;
  72746. /**
  72747. * Disposes this object
  72748. */
  72749. dispose(): void;
  72750. /**
  72751. * @hidden
  72752. * https://zero-radiance.github.io/post/sampling-diffusion/
  72753. *
  72754. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72755. * ------------------------------------------------------------------------------------
  72756. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72757. * PDF[r, phi, s] = r * R[r, phi, s]
  72758. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72759. * ------------------------------------------------------------------------------------
  72760. * We importance sample the color channel with the widest scattering distance.
  72761. */
  72762. getDiffusionProfileParameters(color: Color3): number;
  72763. /**
  72764. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72765. * 'u' is the random number (the value of the CDF): [0, 1).
  72766. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72767. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72768. */
  72769. private _sampleBurleyDiffusionProfile;
  72770. }
  72771. }
  72772. declare module BABYLON {
  72773. interface AbstractScene {
  72774. /** @hidden (Backing field) */
  72775. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72776. /**
  72777. * Gets or Sets the current prepass renderer associated to the scene.
  72778. */
  72779. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72780. /**
  72781. * Enables the subsurface effect for prepass
  72782. * @returns the SubSurfaceConfiguration
  72783. */
  72784. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72785. /**
  72786. * Disables the subsurface effect for prepass
  72787. */
  72788. disableSubSurfaceForPrePass(): void;
  72789. }
  72790. /**
  72791. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72792. * in several rendering techniques.
  72793. */
  72794. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72795. /**
  72796. * The component name helpful to identify the component in the list of scene components.
  72797. */
  72798. readonly name: string;
  72799. /**
  72800. * The scene the component belongs to.
  72801. */
  72802. scene: Scene;
  72803. /**
  72804. * Creates a new instance of the component for the given scene
  72805. * @param scene Defines the scene to register the component in
  72806. */
  72807. constructor(scene: Scene);
  72808. /**
  72809. * Registers the component in a given scene
  72810. */
  72811. register(): void;
  72812. /**
  72813. * Serializes the component data to the specified json object
  72814. * @param serializationObject The object to serialize to
  72815. */
  72816. serialize(serializationObject: any): void;
  72817. /**
  72818. * Adds all the elements from the container to the scene
  72819. * @param container the container holding the elements
  72820. */
  72821. addFromContainer(container: AbstractScene): void;
  72822. /**
  72823. * Removes all the elements in the container from the scene
  72824. * @param container contains the elements to remove
  72825. * @param dispose if the removed element should be disposed (default: false)
  72826. */
  72827. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72828. /**
  72829. * Rebuilds the elements related to this component in case of
  72830. * context lost for instance.
  72831. */
  72832. rebuild(): void;
  72833. /**
  72834. * Disposes the component and the associated ressources
  72835. */
  72836. dispose(): void;
  72837. }
  72838. }
  72839. declare module BABYLON {
  72840. /** @hidden */
  72841. export var outlinePixelShader: {
  72842. name: string;
  72843. shader: string;
  72844. };
  72845. }
  72846. declare module BABYLON {
  72847. /** @hidden */
  72848. export var outlineVertexShader: {
  72849. name: string;
  72850. shader: string;
  72851. };
  72852. }
  72853. declare module BABYLON {
  72854. interface Scene {
  72855. /** @hidden */
  72856. _outlineRenderer: OutlineRenderer;
  72857. /**
  72858. * Gets the outline renderer associated with the scene
  72859. * @returns a OutlineRenderer
  72860. */
  72861. getOutlineRenderer(): OutlineRenderer;
  72862. }
  72863. interface AbstractMesh {
  72864. /** @hidden (Backing field) */
  72865. _renderOutline: boolean;
  72866. /**
  72867. * Gets or sets a boolean indicating if the outline must be rendered as well
  72868. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72869. */
  72870. renderOutline: boolean;
  72871. /** @hidden (Backing field) */
  72872. _renderOverlay: boolean;
  72873. /**
  72874. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72875. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72876. */
  72877. renderOverlay: boolean;
  72878. }
  72879. /**
  72880. * This class is responsible to draw bothe outline/overlay of meshes.
  72881. * It should not be used directly but through the available method on mesh.
  72882. */
  72883. export class OutlineRenderer implements ISceneComponent {
  72884. /**
  72885. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72886. */
  72887. private static _StencilReference;
  72888. /**
  72889. * The name of the component. Each component must have a unique name.
  72890. */
  72891. name: string;
  72892. /**
  72893. * The scene the component belongs to.
  72894. */
  72895. scene: Scene;
  72896. /**
  72897. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72898. */
  72899. zOffset: number;
  72900. private _engine;
  72901. private _effect;
  72902. private _cachedDefines;
  72903. private _savedDepthWrite;
  72904. /**
  72905. * Instantiates a new outline renderer. (There could be only one per scene).
  72906. * @param scene Defines the scene it belongs to
  72907. */
  72908. constructor(scene: Scene);
  72909. /**
  72910. * Register the component to one instance of a scene.
  72911. */
  72912. register(): void;
  72913. /**
  72914. * Rebuilds the elements related to this component in case of
  72915. * context lost for instance.
  72916. */
  72917. rebuild(): void;
  72918. /**
  72919. * Disposes the component and the associated ressources.
  72920. */
  72921. dispose(): void;
  72922. /**
  72923. * Renders the outline in the canvas.
  72924. * @param subMesh Defines the sumesh to render
  72925. * @param batch Defines the batch of meshes in case of instances
  72926. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72927. */
  72928. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72929. /**
  72930. * Returns whether or not the outline renderer is ready for a given submesh.
  72931. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72932. * @param subMesh Defines the submesh to check readyness for
  72933. * @param useInstances Defines wheter wee are trying to render instances or not
  72934. * @returns true if ready otherwise false
  72935. */
  72936. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72937. private _beforeRenderingMesh;
  72938. private _afterRenderingMesh;
  72939. }
  72940. }
  72941. declare module BABYLON {
  72942. /**
  72943. * Defines the basic options interface of a Sprite Frame Source Size.
  72944. */
  72945. export interface ISpriteJSONSpriteSourceSize {
  72946. /**
  72947. * number of the original width of the Frame
  72948. */
  72949. w: number;
  72950. /**
  72951. * number of the original height of the Frame
  72952. */
  72953. h: number;
  72954. }
  72955. /**
  72956. * Defines the basic options interface of a Sprite Frame Data.
  72957. */
  72958. export interface ISpriteJSONSpriteFrameData {
  72959. /**
  72960. * number of the x offset of the Frame
  72961. */
  72962. x: number;
  72963. /**
  72964. * number of the y offset of the Frame
  72965. */
  72966. y: number;
  72967. /**
  72968. * number of the width of the Frame
  72969. */
  72970. w: number;
  72971. /**
  72972. * number of the height of the Frame
  72973. */
  72974. h: number;
  72975. }
  72976. /**
  72977. * Defines the basic options interface of a JSON Sprite.
  72978. */
  72979. export interface ISpriteJSONSprite {
  72980. /**
  72981. * string name of the Frame
  72982. */
  72983. filename: string;
  72984. /**
  72985. * ISpriteJSONSpriteFrame basic object of the frame data
  72986. */
  72987. frame: ISpriteJSONSpriteFrameData;
  72988. /**
  72989. * boolean to flag is the frame was rotated.
  72990. */
  72991. rotated: boolean;
  72992. /**
  72993. * boolean to flag is the frame was trimmed.
  72994. */
  72995. trimmed: boolean;
  72996. /**
  72997. * ISpriteJSONSpriteFrame basic object of the source data
  72998. */
  72999. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73000. /**
  73001. * ISpriteJSONSpriteFrame basic object of the source data
  73002. */
  73003. sourceSize: ISpriteJSONSpriteSourceSize;
  73004. }
  73005. /**
  73006. * Defines the basic options interface of a JSON atlas.
  73007. */
  73008. export interface ISpriteJSONAtlas {
  73009. /**
  73010. * Array of objects that contain the frame data.
  73011. */
  73012. frames: Array<ISpriteJSONSprite>;
  73013. /**
  73014. * object basic object containing the sprite meta data.
  73015. */
  73016. meta?: object;
  73017. }
  73018. }
  73019. declare module BABYLON {
  73020. /** @hidden */
  73021. export var spriteMapPixelShader: {
  73022. name: string;
  73023. shader: string;
  73024. };
  73025. }
  73026. declare module BABYLON {
  73027. /** @hidden */
  73028. export var spriteMapVertexShader: {
  73029. name: string;
  73030. shader: string;
  73031. };
  73032. }
  73033. declare module BABYLON {
  73034. /**
  73035. * Defines the basic options interface of a SpriteMap
  73036. */
  73037. export interface ISpriteMapOptions {
  73038. /**
  73039. * Vector2 of the number of cells in the grid.
  73040. */
  73041. stageSize?: Vector2;
  73042. /**
  73043. * Vector2 of the size of the output plane in World Units.
  73044. */
  73045. outputSize?: Vector2;
  73046. /**
  73047. * Vector3 of the position of the output plane in World Units.
  73048. */
  73049. outputPosition?: Vector3;
  73050. /**
  73051. * Vector3 of the rotation of the output plane.
  73052. */
  73053. outputRotation?: Vector3;
  73054. /**
  73055. * number of layers that the system will reserve in resources.
  73056. */
  73057. layerCount?: number;
  73058. /**
  73059. * number of max animation frames a single cell will reserve in resources.
  73060. */
  73061. maxAnimationFrames?: number;
  73062. /**
  73063. * number cell index of the base tile when the system compiles.
  73064. */
  73065. baseTile?: number;
  73066. /**
  73067. * boolean flip the sprite after its been repositioned by the framing data.
  73068. */
  73069. flipU?: boolean;
  73070. /**
  73071. * Vector3 scalar of the global RGB values of the SpriteMap.
  73072. */
  73073. colorMultiply?: Vector3;
  73074. }
  73075. /**
  73076. * Defines the IDisposable interface in order to be cleanable from resources.
  73077. */
  73078. export interface ISpriteMap extends IDisposable {
  73079. /**
  73080. * String name of the SpriteMap.
  73081. */
  73082. name: string;
  73083. /**
  73084. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73085. */
  73086. atlasJSON: ISpriteJSONAtlas;
  73087. /**
  73088. * Texture of the SpriteMap.
  73089. */
  73090. spriteSheet: Texture;
  73091. /**
  73092. * The parameters to initialize the SpriteMap with.
  73093. */
  73094. options: ISpriteMapOptions;
  73095. }
  73096. /**
  73097. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73098. */
  73099. export class SpriteMap implements ISpriteMap {
  73100. /** The Name of the spriteMap */
  73101. name: string;
  73102. /** The JSON file with the frame and meta data */
  73103. atlasJSON: ISpriteJSONAtlas;
  73104. /** The systems Sprite Sheet Texture */
  73105. spriteSheet: Texture;
  73106. /** Arguments passed with the Constructor */
  73107. options: ISpriteMapOptions;
  73108. /** Public Sprite Storage array, parsed from atlasJSON */
  73109. sprites: Array<ISpriteJSONSprite>;
  73110. /** Returns the Number of Sprites in the System */
  73111. get spriteCount(): number;
  73112. /** Returns the Position of Output Plane*/
  73113. get position(): Vector3;
  73114. /** Returns the Position of Output Plane*/
  73115. set position(v: Vector3);
  73116. /** Returns the Rotation of Output Plane*/
  73117. get rotation(): Vector3;
  73118. /** Returns the Rotation of Output Plane*/
  73119. set rotation(v: Vector3);
  73120. /** Sets the AnimationMap*/
  73121. get animationMap(): RawTexture;
  73122. /** Sets the AnimationMap*/
  73123. set animationMap(v: RawTexture);
  73124. /** Scene that the SpriteMap was created in */
  73125. private _scene;
  73126. /** Texture Buffer of Float32 that holds tile frame data*/
  73127. private _frameMap;
  73128. /** Texture Buffers of Float32 that holds tileMap data*/
  73129. private _tileMaps;
  73130. /** Texture Buffer of Float32 that holds Animation Data*/
  73131. private _animationMap;
  73132. /** Custom ShaderMaterial Central to the System*/
  73133. private _material;
  73134. /** Custom ShaderMaterial Central to the System*/
  73135. private _output;
  73136. /** Systems Time Ticker*/
  73137. private _time;
  73138. /**
  73139. * Creates a new SpriteMap
  73140. * @param name defines the SpriteMaps Name
  73141. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73142. * @param spriteSheet is the Texture that the Sprites are on.
  73143. * @param options a basic deployment configuration
  73144. * @param scene The Scene that the map is deployed on
  73145. */
  73146. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73147. /**
  73148. * Returns tileID location
  73149. * @returns Vector2 the cell position ID
  73150. */
  73151. getTileID(): Vector2;
  73152. /**
  73153. * Gets the UV location of the mouse over the SpriteMap.
  73154. * @returns Vector2 the UV position of the mouse interaction
  73155. */
  73156. getMousePosition(): Vector2;
  73157. /**
  73158. * Creates the "frame" texture Buffer
  73159. * -------------------------------------
  73160. * Structure of frames
  73161. * "filename": "Falling-Water-2.png",
  73162. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73163. * "rotated": true,
  73164. * "trimmed": true,
  73165. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73166. * "sourceSize": {"w":32,"h":32}
  73167. * @returns RawTexture of the frameMap
  73168. */
  73169. private _createFrameBuffer;
  73170. /**
  73171. * Creates the tileMap texture Buffer
  73172. * @param buffer normally and array of numbers, or a false to generate from scratch
  73173. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73174. * @returns RawTexture of the tileMap
  73175. */
  73176. private _createTileBuffer;
  73177. /**
  73178. * Modifies the data of the tileMaps
  73179. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73180. * @param pos is the iVector2 Coordinates of the Tile
  73181. * @param tile The SpriteIndex of the new Tile
  73182. */
  73183. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73184. /**
  73185. * Creates the animationMap texture Buffer
  73186. * @param buffer normally and array of numbers, or a false to generate from scratch
  73187. * @returns RawTexture of the animationMap
  73188. */
  73189. private _createTileAnimationBuffer;
  73190. /**
  73191. * Modifies the data of the animationMap
  73192. * @param cellID is the Index of the Sprite
  73193. * @param _frame is the target Animation frame
  73194. * @param toCell is the Target Index of the next frame of the animation
  73195. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73196. * @param speed is a global scalar of the time variable on the map.
  73197. */
  73198. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73199. /**
  73200. * Exports the .tilemaps file
  73201. */
  73202. saveTileMaps(): void;
  73203. /**
  73204. * Imports the .tilemaps file
  73205. * @param url of the .tilemaps file
  73206. */
  73207. loadTileMaps(url: string): void;
  73208. /**
  73209. * Release associated resources
  73210. */
  73211. dispose(): void;
  73212. }
  73213. }
  73214. declare module BABYLON {
  73215. /**
  73216. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73217. * @see https://doc.babylonjs.com/babylon101/sprites
  73218. */
  73219. export class SpritePackedManager extends SpriteManager {
  73220. /** defines the packed manager's name */
  73221. name: string;
  73222. /**
  73223. * Creates a new sprite manager from a packed sprite sheet
  73224. * @param name defines the manager's name
  73225. * @param imgUrl defines the sprite sheet url
  73226. * @param capacity defines the maximum allowed number of sprites
  73227. * @param scene defines the hosting scene
  73228. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73229. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73230. * @param samplingMode defines the smapling mode to use with spritesheet
  73231. * @param fromPacked set to true; do not alter
  73232. */
  73233. constructor(
  73234. /** defines the packed manager's name */
  73235. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73236. }
  73237. }
  73238. declare module BABYLON {
  73239. /**
  73240. * Defines the list of states available for a task inside a AssetsManager
  73241. */
  73242. export enum AssetTaskState {
  73243. /**
  73244. * Initialization
  73245. */
  73246. INIT = 0,
  73247. /**
  73248. * Running
  73249. */
  73250. RUNNING = 1,
  73251. /**
  73252. * Done
  73253. */
  73254. DONE = 2,
  73255. /**
  73256. * Error
  73257. */
  73258. ERROR = 3
  73259. }
  73260. /**
  73261. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73262. */
  73263. export abstract class AbstractAssetTask {
  73264. /**
  73265. * Task name
  73266. */ name: string;
  73267. /**
  73268. * Callback called when the task is successful
  73269. */
  73270. onSuccess: (task: any) => void;
  73271. /**
  73272. * Callback called when the task is not successful
  73273. */
  73274. onError: (task: any, message?: string, exception?: any) => void;
  73275. /**
  73276. * Creates a new AssetsManager
  73277. * @param name defines the name of the task
  73278. */
  73279. constructor(
  73280. /**
  73281. * Task name
  73282. */ name: string);
  73283. private _isCompleted;
  73284. private _taskState;
  73285. private _errorObject;
  73286. /**
  73287. * Get if the task is completed
  73288. */
  73289. get isCompleted(): boolean;
  73290. /**
  73291. * Gets the current state of the task
  73292. */
  73293. get taskState(): AssetTaskState;
  73294. /**
  73295. * Gets the current error object (if task is in error)
  73296. */
  73297. get errorObject(): {
  73298. message?: string;
  73299. exception?: any;
  73300. };
  73301. /**
  73302. * Internal only
  73303. * @hidden
  73304. */
  73305. _setErrorObject(message?: string, exception?: any): void;
  73306. /**
  73307. * Execute the current task
  73308. * @param scene defines the scene where you want your assets to be loaded
  73309. * @param onSuccess is a callback called when the task is successfully executed
  73310. * @param onError is a callback called if an error occurs
  73311. */
  73312. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73313. /**
  73314. * Execute the current task
  73315. * @param scene defines the scene where you want your assets to be loaded
  73316. * @param onSuccess is a callback called when the task is successfully executed
  73317. * @param onError is a callback called if an error occurs
  73318. */
  73319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73320. /**
  73321. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73322. * This can be used with failed tasks that have the reason for failure fixed.
  73323. */
  73324. reset(): void;
  73325. private onErrorCallback;
  73326. private onDoneCallback;
  73327. }
  73328. /**
  73329. * Define the interface used by progress events raised during assets loading
  73330. */
  73331. export interface IAssetsProgressEvent {
  73332. /**
  73333. * Defines the number of remaining tasks to process
  73334. */
  73335. remainingCount: number;
  73336. /**
  73337. * Defines the total number of tasks
  73338. */
  73339. totalCount: number;
  73340. /**
  73341. * Defines the task that was just processed
  73342. */
  73343. task: AbstractAssetTask;
  73344. }
  73345. /**
  73346. * Class used to share progress information about assets loading
  73347. */
  73348. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73349. /**
  73350. * Defines the number of remaining tasks to process
  73351. */
  73352. remainingCount: number;
  73353. /**
  73354. * Defines the total number of tasks
  73355. */
  73356. totalCount: number;
  73357. /**
  73358. * Defines the task that was just processed
  73359. */
  73360. task: AbstractAssetTask;
  73361. /**
  73362. * Creates a AssetsProgressEvent
  73363. * @param remainingCount defines the number of remaining tasks to process
  73364. * @param totalCount defines the total number of tasks
  73365. * @param task defines the task that was just processed
  73366. */
  73367. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73368. }
  73369. /**
  73370. * Define a task used by AssetsManager to load assets into a container
  73371. */
  73372. export class ContainerAssetTask extends AbstractAssetTask {
  73373. /**
  73374. * Defines the name of the task
  73375. */
  73376. name: string;
  73377. /**
  73378. * Defines the list of mesh's names you want to load
  73379. */
  73380. meshesNames: any;
  73381. /**
  73382. * Defines the root url to use as a base to load your meshes and associated resources
  73383. */
  73384. rootUrl: string;
  73385. /**
  73386. * Defines the filename or File of the scene to load from
  73387. */
  73388. sceneFilename: string | File;
  73389. /**
  73390. * Get the loaded asset container
  73391. */
  73392. loadedContainer: AssetContainer;
  73393. /**
  73394. * Gets the list of loaded meshes
  73395. */
  73396. loadedMeshes: Array<AbstractMesh>;
  73397. /**
  73398. * Gets the list of loaded particle systems
  73399. */
  73400. loadedParticleSystems: Array<IParticleSystem>;
  73401. /**
  73402. * Gets the list of loaded skeletons
  73403. */
  73404. loadedSkeletons: Array<Skeleton>;
  73405. /**
  73406. * Gets the list of loaded animation groups
  73407. */
  73408. loadedAnimationGroups: Array<AnimationGroup>;
  73409. /**
  73410. * Callback called when the task is successful
  73411. */
  73412. onSuccess: (task: ContainerAssetTask) => void;
  73413. /**
  73414. * Callback called when the task is successful
  73415. */
  73416. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73417. /**
  73418. * Creates a new ContainerAssetTask
  73419. * @param name defines the name of the task
  73420. * @param meshesNames defines the list of mesh's names you want to load
  73421. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73422. * @param sceneFilename defines the filename or File of the scene to load from
  73423. */
  73424. constructor(
  73425. /**
  73426. * Defines the name of the task
  73427. */
  73428. name: string,
  73429. /**
  73430. * Defines the list of mesh's names you want to load
  73431. */
  73432. meshesNames: any,
  73433. /**
  73434. * Defines the root url to use as a base to load your meshes and associated resources
  73435. */
  73436. rootUrl: string,
  73437. /**
  73438. * Defines the filename or File of the scene to load from
  73439. */
  73440. sceneFilename: string | File);
  73441. /**
  73442. * Execute the current task
  73443. * @param scene defines the scene where you want your assets to be loaded
  73444. * @param onSuccess is a callback called when the task is successfully executed
  73445. * @param onError is a callback called if an error occurs
  73446. */
  73447. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73448. }
  73449. /**
  73450. * Define a task used by AssetsManager to load meshes
  73451. */
  73452. export class MeshAssetTask extends AbstractAssetTask {
  73453. /**
  73454. * Defines the name of the task
  73455. */
  73456. name: string;
  73457. /**
  73458. * Defines the list of mesh's names you want to load
  73459. */
  73460. meshesNames: any;
  73461. /**
  73462. * Defines the root url to use as a base to load your meshes and associated resources
  73463. */
  73464. rootUrl: string;
  73465. /**
  73466. * Defines the filename or File of the scene to load from
  73467. */
  73468. sceneFilename: string | File;
  73469. /**
  73470. * Gets the list of loaded meshes
  73471. */
  73472. loadedMeshes: Array<AbstractMesh>;
  73473. /**
  73474. * Gets the list of loaded particle systems
  73475. */
  73476. loadedParticleSystems: Array<IParticleSystem>;
  73477. /**
  73478. * Gets the list of loaded skeletons
  73479. */
  73480. loadedSkeletons: Array<Skeleton>;
  73481. /**
  73482. * Gets the list of loaded animation groups
  73483. */
  73484. loadedAnimationGroups: Array<AnimationGroup>;
  73485. /**
  73486. * Callback called when the task is successful
  73487. */
  73488. onSuccess: (task: MeshAssetTask) => void;
  73489. /**
  73490. * Callback called when the task is successful
  73491. */
  73492. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73493. /**
  73494. * Creates a new MeshAssetTask
  73495. * @param name defines the name of the task
  73496. * @param meshesNames defines the list of mesh's names you want to load
  73497. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73498. * @param sceneFilename defines the filename or File of the scene to load from
  73499. */
  73500. constructor(
  73501. /**
  73502. * Defines the name of the task
  73503. */
  73504. name: string,
  73505. /**
  73506. * Defines the list of mesh's names you want to load
  73507. */
  73508. meshesNames: any,
  73509. /**
  73510. * Defines the root url to use as a base to load your meshes and associated resources
  73511. */
  73512. rootUrl: string,
  73513. /**
  73514. * Defines the filename or File of the scene to load from
  73515. */
  73516. sceneFilename: string | File);
  73517. /**
  73518. * Execute the current task
  73519. * @param scene defines the scene where you want your assets to be loaded
  73520. * @param onSuccess is a callback called when the task is successfully executed
  73521. * @param onError is a callback called if an error occurs
  73522. */
  73523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73524. }
  73525. /**
  73526. * Define a task used by AssetsManager to load text content
  73527. */
  73528. export class TextFileAssetTask extends AbstractAssetTask {
  73529. /**
  73530. * Defines the name of the task
  73531. */
  73532. name: string;
  73533. /**
  73534. * Defines the location of the file to load
  73535. */
  73536. url: string;
  73537. /**
  73538. * Gets the loaded text string
  73539. */
  73540. text: string;
  73541. /**
  73542. * Callback called when the task is successful
  73543. */
  73544. onSuccess: (task: TextFileAssetTask) => void;
  73545. /**
  73546. * Callback called when the task is successful
  73547. */
  73548. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73549. /**
  73550. * Creates a new TextFileAssetTask object
  73551. * @param name defines the name of the task
  73552. * @param url defines the location of the file to load
  73553. */
  73554. constructor(
  73555. /**
  73556. * Defines the name of the task
  73557. */
  73558. name: string,
  73559. /**
  73560. * Defines the location of the file to load
  73561. */
  73562. url: string);
  73563. /**
  73564. * Execute the current task
  73565. * @param scene defines the scene where you want your assets to be loaded
  73566. * @param onSuccess is a callback called when the task is successfully executed
  73567. * @param onError is a callback called if an error occurs
  73568. */
  73569. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73570. }
  73571. /**
  73572. * Define a task used by AssetsManager to load binary data
  73573. */
  73574. export class BinaryFileAssetTask extends AbstractAssetTask {
  73575. /**
  73576. * Defines the name of the task
  73577. */
  73578. name: string;
  73579. /**
  73580. * Defines the location of the file to load
  73581. */
  73582. url: string;
  73583. /**
  73584. * Gets the lodaded data (as an array buffer)
  73585. */
  73586. data: ArrayBuffer;
  73587. /**
  73588. * Callback called when the task is successful
  73589. */
  73590. onSuccess: (task: BinaryFileAssetTask) => void;
  73591. /**
  73592. * Callback called when the task is successful
  73593. */
  73594. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73595. /**
  73596. * Creates a new BinaryFileAssetTask object
  73597. * @param name defines the name of the new task
  73598. * @param url defines the location of the file to load
  73599. */
  73600. constructor(
  73601. /**
  73602. * Defines the name of the task
  73603. */
  73604. name: string,
  73605. /**
  73606. * Defines the location of the file to load
  73607. */
  73608. url: string);
  73609. /**
  73610. * Execute the current task
  73611. * @param scene defines the scene where you want your assets to be loaded
  73612. * @param onSuccess is a callback called when the task is successfully executed
  73613. * @param onError is a callback called if an error occurs
  73614. */
  73615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73616. }
  73617. /**
  73618. * Define a task used by AssetsManager to load images
  73619. */
  73620. export class ImageAssetTask extends AbstractAssetTask {
  73621. /**
  73622. * Defines the name of the task
  73623. */
  73624. name: string;
  73625. /**
  73626. * Defines the location of the image to load
  73627. */
  73628. url: string;
  73629. /**
  73630. * Gets the loaded images
  73631. */
  73632. image: HTMLImageElement;
  73633. /**
  73634. * Callback called when the task is successful
  73635. */
  73636. onSuccess: (task: ImageAssetTask) => void;
  73637. /**
  73638. * Callback called when the task is successful
  73639. */
  73640. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73641. /**
  73642. * Creates a new ImageAssetTask
  73643. * @param name defines the name of the task
  73644. * @param url defines the location of the image to load
  73645. */
  73646. constructor(
  73647. /**
  73648. * Defines the name of the task
  73649. */
  73650. name: string,
  73651. /**
  73652. * Defines the location of the image to load
  73653. */
  73654. url: string);
  73655. /**
  73656. * Execute the current task
  73657. * @param scene defines the scene where you want your assets to be loaded
  73658. * @param onSuccess is a callback called when the task is successfully executed
  73659. * @param onError is a callback called if an error occurs
  73660. */
  73661. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73662. }
  73663. /**
  73664. * Defines the interface used by texture loading tasks
  73665. */
  73666. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73667. /**
  73668. * Gets the loaded texture
  73669. */
  73670. texture: TEX;
  73671. }
  73672. /**
  73673. * Define a task used by AssetsManager to load 2D textures
  73674. */
  73675. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73676. /**
  73677. * Defines the name of the task
  73678. */
  73679. name: string;
  73680. /**
  73681. * Defines the location of the file to load
  73682. */
  73683. url: string;
  73684. /**
  73685. * Defines if mipmap should not be generated (default is false)
  73686. */
  73687. noMipmap?: boolean | undefined;
  73688. /**
  73689. * Defines if texture must be inverted on Y axis (default is true)
  73690. */
  73691. invertY: boolean;
  73692. /**
  73693. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73694. */
  73695. samplingMode: number;
  73696. /**
  73697. * Gets the loaded texture
  73698. */
  73699. texture: Texture;
  73700. /**
  73701. * Callback called when the task is successful
  73702. */
  73703. onSuccess: (task: TextureAssetTask) => void;
  73704. /**
  73705. * Callback called when the task is successful
  73706. */
  73707. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73708. /**
  73709. * Creates a new TextureAssetTask object
  73710. * @param name defines the name of the task
  73711. * @param url defines the location of the file to load
  73712. * @param noMipmap defines if mipmap should not be generated (default is false)
  73713. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73714. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73715. */
  73716. constructor(
  73717. /**
  73718. * Defines the name of the task
  73719. */
  73720. name: string,
  73721. /**
  73722. * Defines the location of the file to load
  73723. */
  73724. url: string,
  73725. /**
  73726. * Defines if mipmap should not be generated (default is false)
  73727. */
  73728. noMipmap?: boolean | undefined,
  73729. /**
  73730. * Defines if texture must be inverted on Y axis (default is true)
  73731. */
  73732. invertY?: boolean,
  73733. /**
  73734. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73735. */
  73736. samplingMode?: number);
  73737. /**
  73738. * Execute the current task
  73739. * @param scene defines the scene where you want your assets to be loaded
  73740. * @param onSuccess is a callback called when the task is successfully executed
  73741. * @param onError is a callback called if an error occurs
  73742. */
  73743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73744. }
  73745. /**
  73746. * Define a task used by AssetsManager to load cube textures
  73747. */
  73748. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73749. /**
  73750. * Defines the name of the task
  73751. */
  73752. name: string;
  73753. /**
  73754. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73755. */
  73756. url: string;
  73757. /**
  73758. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73759. */
  73760. extensions?: string[] | undefined;
  73761. /**
  73762. * Defines if mipmaps should not be generated (default is false)
  73763. */
  73764. noMipmap?: boolean | undefined;
  73765. /**
  73766. * Defines the explicit list of files (undefined by default)
  73767. */
  73768. files?: string[] | undefined;
  73769. /**
  73770. * Gets the loaded texture
  73771. */
  73772. texture: CubeTexture;
  73773. /**
  73774. * Callback called when the task is successful
  73775. */
  73776. onSuccess: (task: CubeTextureAssetTask) => void;
  73777. /**
  73778. * Callback called when the task is successful
  73779. */
  73780. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73781. /**
  73782. * Creates a new CubeTextureAssetTask
  73783. * @param name defines the name of the task
  73784. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73785. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73787. * @param files defines the explicit list of files (undefined by default)
  73788. */
  73789. constructor(
  73790. /**
  73791. * Defines the name of the task
  73792. */
  73793. name: string,
  73794. /**
  73795. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73796. */
  73797. url: string,
  73798. /**
  73799. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73800. */
  73801. extensions?: string[] | undefined,
  73802. /**
  73803. * Defines if mipmaps should not be generated (default is false)
  73804. */
  73805. noMipmap?: boolean | undefined,
  73806. /**
  73807. * Defines the explicit list of files (undefined by default)
  73808. */
  73809. files?: string[] | undefined);
  73810. /**
  73811. * Execute the current task
  73812. * @param scene defines the scene where you want your assets to be loaded
  73813. * @param onSuccess is a callback called when the task is successfully executed
  73814. * @param onError is a callback called if an error occurs
  73815. */
  73816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73817. }
  73818. /**
  73819. * Define a task used by AssetsManager to load HDR cube textures
  73820. */
  73821. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73822. /**
  73823. * Defines the name of the task
  73824. */
  73825. name: string;
  73826. /**
  73827. * Defines the location of the file to load
  73828. */
  73829. url: string;
  73830. /**
  73831. * Defines the desired size (the more it increases the longer the generation will be)
  73832. */
  73833. size: number;
  73834. /**
  73835. * Defines if mipmaps should not be generated (default is false)
  73836. */
  73837. noMipmap: boolean;
  73838. /**
  73839. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73840. */
  73841. generateHarmonics: boolean;
  73842. /**
  73843. * 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)
  73844. */
  73845. gammaSpace: boolean;
  73846. /**
  73847. * Internal Use Only
  73848. */
  73849. reserved: boolean;
  73850. /**
  73851. * Gets the loaded texture
  73852. */
  73853. texture: HDRCubeTexture;
  73854. /**
  73855. * Callback called when the task is successful
  73856. */
  73857. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73858. /**
  73859. * Callback called when the task is successful
  73860. */
  73861. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73862. /**
  73863. * Creates a new HDRCubeTextureAssetTask object
  73864. * @param name defines the name of the task
  73865. * @param url defines the location of the file to load
  73866. * @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.
  73867. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73868. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73869. * @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)
  73870. * @param reserved Internal use only
  73871. */
  73872. constructor(
  73873. /**
  73874. * Defines the name of the task
  73875. */
  73876. name: string,
  73877. /**
  73878. * Defines the location of the file to load
  73879. */
  73880. url: string,
  73881. /**
  73882. * Defines the desired size (the more it increases the longer the generation will be)
  73883. */
  73884. size: number,
  73885. /**
  73886. * Defines if mipmaps should not be generated (default is false)
  73887. */
  73888. noMipmap?: boolean,
  73889. /**
  73890. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73891. */
  73892. generateHarmonics?: boolean,
  73893. /**
  73894. * 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)
  73895. */
  73896. gammaSpace?: boolean,
  73897. /**
  73898. * Internal Use Only
  73899. */
  73900. reserved?: boolean);
  73901. /**
  73902. * Execute the current task
  73903. * @param scene defines the scene where you want your assets to be loaded
  73904. * @param onSuccess is a callback called when the task is successfully executed
  73905. * @param onError is a callback called if an error occurs
  73906. */
  73907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73908. }
  73909. /**
  73910. * Define a task used by AssetsManager to load Equirectangular cube textures
  73911. */
  73912. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73913. /**
  73914. * Defines the name of the task
  73915. */
  73916. name: string;
  73917. /**
  73918. * Defines the location of the file to load
  73919. */
  73920. url: string;
  73921. /**
  73922. * Defines the desired size (the more it increases the longer the generation will be)
  73923. */
  73924. size: number;
  73925. /**
  73926. * Defines if mipmaps should not be generated (default is false)
  73927. */
  73928. noMipmap: boolean;
  73929. /**
  73930. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73931. * but the standard material would require them in Gamma space) (default is true)
  73932. */
  73933. gammaSpace: boolean;
  73934. /**
  73935. * Gets the loaded texture
  73936. */
  73937. texture: EquiRectangularCubeTexture;
  73938. /**
  73939. * Callback called when the task is successful
  73940. */
  73941. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73942. /**
  73943. * Callback called when the task is successful
  73944. */
  73945. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73946. /**
  73947. * Creates a new EquiRectangularCubeTextureAssetTask object
  73948. * @param name defines the name of the task
  73949. * @param url defines the location of the file to load
  73950. * @param size defines the desired size (the more it increases the longer the generation will be)
  73951. * If the size is omitted this implies you are using a preprocessed cubemap.
  73952. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73953. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73954. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73955. * (default is true)
  73956. */
  73957. constructor(
  73958. /**
  73959. * Defines the name of the task
  73960. */
  73961. name: string,
  73962. /**
  73963. * Defines the location of the file to load
  73964. */
  73965. url: string,
  73966. /**
  73967. * Defines the desired size (the more it increases the longer the generation will be)
  73968. */
  73969. size: number,
  73970. /**
  73971. * Defines if mipmaps should not be generated (default is false)
  73972. */
  73973. noMipmap?: boolean,
  73974. /**
  73975. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73976. * but the standard material would require them in Gamma space) (default is true)
  73977. */
  73978. gammaSpace?: boolean);
  73979. /**
  73980. * Execute the current task
  73981. * @param scene defines the scene where you want your assets to be loaded
  73982. * @param onSuccess is a callback called when the task is successfully executed
  73983. * @param onError is a callback called if an error occurs
  73984. */
  73985. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73986. }
  73987. /**
  73988. * This class can be used to easily import assets into a scene
  73989. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73990. */
  73991. export class AssetsManager {
  73992. private _scene;
  73993. private _isLoading;
  73994. protected _tasks: AbstractAssetTask[];
  73995. protected _waitingTasksCount: number;
  73996. protected _totalTasksCount: number;
  73997. /**
  73998. * Callback called when all tasks are processed
  73999. */
  74000. onFinish: (tasks: AbstractAssetTask[]) => void;
  74001. /**
  74002. * Callback called when a task is successful
  74003. */
  74004. onTaskSuccess: (task: AbstractAssetTask) => void;
  74005. /**
  74006. * Callback called when a task had an error
  74007. */
  74008. onTaskError: (task: AbstractAssetTask) => void;
  74009. /**
  74010. * Callback called when a task is done (whatever the result is)
  74011. */
  74012. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74013. /**
  74014. * Observable called when all tasks are processed
  74015. */
  74016. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74017. /**
  74018. * Observable called when a task had an error
  74019. */
  74020. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74021. /**
  74022. * Observable called when all tasks were executed
  74023. */
  74024. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74025. /**
  74026. * Observable called when a task is done (whatever the result is)
  74027. */
  74028. onProgressObservable: Observable<IAssetsProgressEvent>;
  74029. /**
  74030. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74031. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74032. */
  74033. useDefaultLoadingScreen: boolean;
  74034. /**
  74035. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74036. * when all assets have been downloaded.
  74037. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74038. */
  74039. autoHideLoadingUI: boolean;
  74040. /**
  74041. * Creates a new AssetsManager
  74042. * @param scene defines the scene to work on
  74043. */
  74044. constructor(scene: Scene);
  74045. /**
  74046. * Add a ContainerAssetTask to the list of active tasks
  74047. * @param taskName defines the name of the new task
  74048. * @param meshesNames defines the name of meshes to load
  74049. * @param rootUrl defines the root url to use to locate files
  74050. * @param sceneFilename defines the filename of the scene file
  74051. * @returns a new ContainerAssetTask object
  74052. */
  74053. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74054. /**
  74055. * Add a MeshAssetTask to the list of active tasks
  74056. * @param taskName defines the name of the new task
  74057. * @param meshesNames defines the name of meshes to load
  74058. * @param rootUrl defines the root url to use to locate files
  74059. * @param sceneFilename defines the filename of the scene file
  74060. * @returns a new MeshAssetTask object
  74061. */
  74062. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74063. /**
  74064. * Add a TextFileAssetTask to the list of active tasks
  74065. * @param taskName defines the name of the new task
  74066. * @param url defines the url of the file to load
  74067. * @returns a new TextFileAssetTask object
  74068. */
  74069. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74070. /**
  74071. * Add a BinaryFileAssetTask to the list of active tasks
  74072. * @param taskName defines the name of the new task
  74073. * @param url defines the url of the file to load
  74074. * @returns a new BinaryFileAssetTask object
  74075. */
  74076. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74077. /**
  74078. * Add a ImageAssetTask to the list of active tasks
  74079. * @param taskName defines the name of the new task
  74080. * @param url defines the url of the file to load
  74081. * @returns a new ImageAssetTask object
  74082. */
  74083. addImageTask(taskName: string, url: string): ImageAssetTask;
  74084. /**
  74085. * Add a TextureAssetTask to the list of active tasks
  74086. * @param taskName defines the name of the new task
  74087. * @param url defines the url of the file to load
  74088. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74089. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74090. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74091. * @returns a new TextureAssetTask object
  74092. */
  74093. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74094. /**
  74095. * Add a CubeTextureAssetTask to the list of active tasks
  74096. * @param taskName defines the name of the new task
  74097. * @param url defines the url of the file to load
  74098. * @param extensions defines the extension to use to load the cube map (can be null)
  74099. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74100. * @param files defines the list of files to load (can be null)
  74101. * @returns a new CubeTextureAssetTask object
  74102. */
  74103. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74104. /**
  74105. *
  74106. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74107. * @param taskName defines the name of the new task
  74108. * @param url defines the url of the file to load
  74109. * @param size defines the size you want for the cubemap (can be null)
  74110. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74111. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74112. * @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)
  74113. * @param reserved Internal use only
  74114. * @returns a new HDRCubeTextureAssetTask object
  74115. */
  74116. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74117. /**
  74118. *
  74119. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74120. * @param taskName defines the name of the new task
  74121. * @param url defines the url of the file to load
  74122. * @param size defines the size you want for the cubemap (can be null)
  74123. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74124. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74125. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74126. * @returns a new EquiRectangularCubeTextureAssetTask object
  74127. */
  74128. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74129. /**
  74130. * Remove a task from the assets manager.
  74131. * @param task the task to remove
  74132. */
  74133. removeTask(task: AbstractAssetTask): void;
  74134. private _decreaseWaitingTasksCount;
  74135. private _runTask;
  74136. /**
  74137. * Reset the AssetsManager and remove all tasks
  74138. * @return the current instance of the AssetsManager
  74139. */
  74140. reset(): AssetsManager;
  74141. /**
  74142. * Start the loading process
  74143. * @return the current instance of the AssetsManager
  74144. */
  74145. load(): AssetsManager;
  74146. /**
  74147. * Start the loading process as an async operation
  74148. * @return a promise returning the list of failed tasks
  74149. */
  74150. loadAsync(): Promise<void>;
  74151. }
  74152. }
  74153. declare module BABYLON {
  74154. /**
  74155. * Wrapper class for promise with external resolve and reject.
  74156. */
  74157. export class Deferred<T> {
  74158. /**
  74159. * The promise associated with this deferred object.
  74160. */
  74161. readonly promise: Promise<T>;
  74162. private _resolve;
  74163. private _reject;
  74164. /**
  74165. * The resolve method of the promise associated with this deferred object.
  74166. */
  74167. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74168. /**
  74169. * The reject method of the promise associated with this deferred object.
  74170. */
  74171. get reject(): (reason?: any) => void;
  74172. /**
  74173. * Constructor for this deferred object.
  74174. */
  74175. constructor();
  74176. }
  74177. }
  74178. declare module BABYLON {
  74179. /**
  74180. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74181. */
  74182. export class MeshExploder {
  74183. private _centerMesh;
  74184. private _meshes;
  74185. private _meshesOrigins;
  74186. private _toCenterVectors;
  74187. private _scaledDirection;
  74188. private _newPosition;
  74189. private _centerPosition;
  74190. /**
  74191. * Explodes meshes from a center mesh.
  74192. * @param meshes The meshes to explode.
  74193. * @param centerMesh The mesh to be center of explosion.
  74194. */
  74195. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74196. private _setCenterMesh;
  74197. /**
  74198. * Get class name
  74199. * @returns "MeshExploder"
  74200. */
  74201. getClassName(): string;
  74202. /**
  74203. * "Exploded meshes"
  74204. * @returns Array of meshes with the centerMesh at index 0.
  74205. */
  74206. getMeshes(): Array<Mesh>;
  74207. /**
  74208. * Explodes meshes giving a specific direction
  74209. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74210. */
  74211. explode(direction?: number): void;
  74212. }
  74213. }
  74214. declare module BABYLON {
  74215. /**
  74216. * Class used to help managing file picking and drag'n'drop
  74217. */
  74218. export class FilesInput {
  74219. /**
  74220. * List of files ready to be loaded
  74221. */
  74222. static get FilesToLoad(): {
  74223. [key: string]: File;
  74224. };
  74225. /**
  74226. * Callback called when a file is processed
  74227. */
  74228. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74229. private _engine;
  74230. private _currentScene;
  74231. private _sceneLoadedCallback;
  74232. private _progressCallback;
  74233. private _additionalRenderLoopLogicCallback;
  74234. private _textureLoadingCallback;
  74235. private _startingProcessingFilesCallback;
  74236. private _onReloadCallback;
  74237. private _errorCallback;
  74238. private _elementToMonitor;
  74239. private _sceneFileToLoad;
  74240. private _filesToLoad;
  74241. /**
  74242. * Creates a new FilesInput
  74243. * @param engine defines the rendering engine
  74244. * @param scene defines the hosting scene
  74245. * @param sceneLoadedCallback callback called when scene is loaded
  74246. * @param progressCallback callback called to track progress
  74247. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74248. * @param textureLoadingCallback callback called when a texture is loading
  74249. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74250. * @param onReloadCallback callback called when a reload is requested
  74251. * @param errorCallback callback call if an error occurs
  74252. */
  74253. 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>);
  74254. private _dragEnterHandler;
  74255. private _dragOverHandler;
  74256. private _dropHandler;
  74257. /**
  74258. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74259. * @param elementToMonitor defines the DOM element to track
  74260. */
  74261. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74262. /** Gets the current list of files to load */
  74263. get filesToLoad(): File[];
  74264. /**
  74265. * Release all associated resources
  74266. */
  74267. dispose(): void;
  74268. private renderFunction;
  74269. private drag;
  74270. private drop;
  74271. private _traverseFolder;
  74272. private _processFiles;
  74273. /**
  74274. * Load files from a drop event
  74275. * @param event defines the drop event to use as source
  74276. */
  74277. loadFiles(event: any): void;
  74278. private _processReload;
  74279. /**
  74280. * Reload the current scene from the loaded files
  74281. */
  74282. reload(): void;
  74283. }
  74284. }
  74285. declare module BABYLON {
  74286. /**
  74287. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74288. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74289. */
  74290. export class SceneOptimization {
  74291. /**
  74292. * Defines the priority of this optimization (0 by default which means first in the list)
  74293. */
  74294. priority: number;
  74295. /**
  74296. * Gets a string describing the action executed by the current optimization
  74297. * @returns description string
  74298. */
  74299. getDescription(): string;
  74300. /**
  74301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74302. * @param scene defines the current scene where to apply this optimization
  74303. * @param optimizer defines the current optimizer
  74304. * @returns true if everything that can be done was applied
  74305. */
  74306. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74307. /**
  74308. * Creates the SceneOptimization object
  74309. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74310. * @param desc defines the description associated with the optimization
  74311. */
  74312. constructor(
  74313. /**
  74314. * Defines the priority of this optimization (0 by default which means first in the list)
  74315. */
  74316. priority?: number);
  74317. }
  74318. /**
  74319. * Defines an optimization used to reduce the size of render target textures
  74320. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74321. */
  74322. export class TextureOptimization extends SceneOptimization {
  74323. /**
  74324. * Defines the priority of this optimization (0 by default which means first in the list)
  74325. */
  74326. priority: number;
  74327. /**
  74328. * 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
  74329. */
  74330. maximumSize: number;
  74331. /**
  74332. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74333. */
  74334. step: number;
  74335. /**
  74336. * Gets a string describing the action executed by the current optimization
  74337. * @returns description string
  74338. */
  74339. getDescription(): string;
  74340. /**
  74341. * Creates the TextureOptimization object
  74342. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74343. * @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
  74344. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74345. */
  74346. constructor(
  74347. /**
  74348. * Defines the priority of this optimization (0 by default which means first in the list)
  74349. */
  74350. priority?: number,
  74351. /**
  74352. * 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
  74353. */
  74354. maximumSize?: number,
  74355. /**
  74356. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74357. */
  74358. step?: number);
  74359. /**
  74360. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74361. * @param scene defines the current scene where to apply this optimization
  74362. * @param optimizer defines the current optimizer
  74363. * @returns true if everything that can be done was applied
  74364. */
  74365. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74366. }
  74367. /**
  74368. * Defines an optimization used to increase or decrease the rendering resolution
  74369. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74370. */
  74371. export class HardwareScalingOptimization extends SceneOptimization {
  74372. /**
  74373. * Defines the priority of this optimization (0 by default which means first in the list)
  74374. */
  74375. priority: number;
  74376. /**
  74377. * Defines the maximum scale to use (2 by default)
  74378. */
  74379. maximumScale: number;
  74380. /**
  74381. * Defines the step to use between two passes (0.5 by default)
  74382. */
  74383. step: number;
  74384. private _currentScale;
  74385. private _directionOffset;
  74386. /**
  74387. * Gets a string describing the action executed by the current optimization
  74388. * @return description string
  74389. */
  74390. getDescription(): string;
  74391. /**
  74392. * Creates the HardwareScalingOptimization object
  74393. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74394. * @param maximumScale defines the maximum scale to use (2 by default)
  74395. * @param step defines the step to use between two passes (0.5 by default)
  74396. */
  74397. constructor(
  74398. /**
  74399. * Defines the priority of this optimization (0 by default which means first in the list)
  74400. */
  74401. priority?: number,
  74402. /**
  74403. * Defines the maximum scale to use (2 by default)
  74404. */
  74405. maximumScale?: number,
  74406. /**
  74407. * Defines the step to use between two passes (0.5 by default)
  74408. */
  74409. step?: number);
  74410. /**
  74411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74412. * @param scene defines the current scene where to apply this optimization
  74413. * @param optimizer defines the current optimizer
  74414. * @returns true if everything that can be done was applied
  74415. */
  74416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74417. }
  74418. /**
  74419. * Defines an optimization used to remove shadows
  74420. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74421. */
  74422. export class ShadowsOptimization extends SceneOptimization {
  74423. /**
  74424. * Gets a string describing the action executed by the current optimization
  74425. * @return description string
  74426. */
  74427. getDescription(): string;
  74428. /**
  74429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74430. * @param scene defines the current scene where to apply this optimization
  74431. * @param optimizer defines the current optimizer
  74432. * @returns true if everything that can be done was applied
  74433. */
  74434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74435. }
  74436. /**
  74437. * Defines an optimization used to turn post-processes off
  74438. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74439. */
  74440. export class PostProcessesOptimization extends SceneOptimization {
  74441. /**
  74442. * Gets a string describing the action executed by the current optimization
  74443. * @return description string
  74444. */
  74445. getDescription(): string;
  74446. /**
  74447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74448. * @param scene defines the current scene where to apply this optimization
  74449. * @param optimizer defines the current optimizer
  74450. * @returns true if everything that can be done was applied
  74451. */
  74452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74453. }
  74454. /**
  74455. * Defines an optimization used to turn lens flares off
  74456. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74457. */
  74458. export class LensFlaresOptimization extends SceneOptimization {
  74459. /**
  74460. * Gets a string describing the action executed by the current optimization
  74461. * @return description string
  74462. */
  74463. getDescription(): string;
  74464. /**
  74465. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74466. * @param scene defines the current scene where to apply this optimization
  74467. * @param optimizer defines the current optimizer
  74468. * @returns true if everything that can be done was applied
  74469. */
  74470. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74471. }
  74472. /**
  74473. * Defines an optimization based on user defined callback.
  74474. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74475. */
  74476. export class CustomOptimization extends SceneOptimization {
  74477. /**
  74478. * Callback called to apply the custom optimization.
  74479. */
  74480. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74481. /**
  74482. * Callback called to get custom description
  74483. */
  74484. onGetDescription: () => string;
  74485. /**
  74486. * Gets a string describing the action executed by the current optimization
  74487. * @returns description string
  74488. */
  74489. getDescription(): string;
  74490. /**
  74491. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74492. * @param scene defines the current scene where to apply this optimization
  74493. * @param optimizer defines the current optimizer
  74494. * @returns true if everything that can be done was applied
  74495. */
  74496. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74497. }
  74498. /**
  74499. * Defines an optimization used to turn particles off
  74500. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74501. */
  74502. export class ParticlesOptimization extends SceneOptimization {
  74503. /**
  74504. * Gets a string describing the action executed by the current optimization
  74505. * @return description string
  74506. */
  74507. getDescription(): string;
  74508. /**
  74509. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74510. * @param scene defines the current scene where to apply this optimization
  74511. * @param optimizer defines the current optimizer
  74512. * @returns true if everything that can be done was applied
  74513. */
  74514. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74515. }
  74516. /**
  74517. * Defines an optimization used to turn render targets off
  74518. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74519. */
  74520. export class RenderTargetsOptimization extends SceneOptimization {
  74521. /**
  74522. * Gets a string describing the action executed by the current optimization
  74523. * @return description string
  74524. */
  74525. getDescription(): string;
  74526. /**
  74527. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74528. * @param scene defines the current scene where to apply this optimization
  74529. * @param optimizer defines the current optimizer
  74530. * @returns true if everything that can be done was applied
  74531. */
  74532. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74533. }
  74534. /**
  74535. * Defines an optimization used to merge meshes with compatible materials
  74536. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74537. */
  74538. export class MergeMeshesOptimization extends SceneOptimization {
  74539. private static _UpdateSelectionTree;
  74540. /**
  74541. * Gets or sets a boolean which defines if optimization octree has to be updated
  74542. */
  74543. static get UpdateSelectionTree(): boolean;
  74544. /**
  74545. * Gets or sets a boolean which defines if optimization octree has to be updated
  74546. */
  74547. static set UpdateSelectionTree(value: boolean);
  74548. /**
  74549. * Gets a string describing the action executed by the current optimization
  74550. * @return description string
  74551. */
  74552. getDescription(): string;
  74553. private _canBeMerged;
  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. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74559. * @returns true if everything that can be done was applied
  74560. */
  74561. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74562. }
  74563. /**
  74564. * Defines a list of options used by SceneOptimizer
  74565. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74566. */
  74567. export class SceneOptimizerOptions {
  74568. /**
  74569. * Defines the target frame rate to reach (60 by default)
  74570. */
  74571. targetFrameRate: number;
  74572. /**
  74573. * Defines the interval between two checkes (2000ms by default)
  74574. */
  74575. trackerDuration: number;
  74576. /**
  74577. * Gets the list of optimizations to apply
  74578. */
  74579. optimizations: SceneOptimization[];
  74580. /**
  74581. * Creates a new list of options used by SceneOptimizer
  74582. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74583. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74584. */
  74585. constructor(
  74586. /**
  74587. * Defines the target frame rate to reach (60 by default)
  74588. */
  74589. targetFrameRate?: number,
  74590. /**
  74591. * Defines the interval between two checkes (2000ms by default)
  74592. */
  74593. trackerDuration?: number);
  74594. /**
  74595. * Add a new optimization
  74596. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74597. * @returns the current SceneOptimizerOptions
  74598. */
  74599. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74600. /**
  74601. * Add a new custom optimization
  74602. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74603. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74604. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74605. * @returns the current SceneOptimizerOptions
  74606. */
  74607. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74608. /**
  74609. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74610. * @param targetFrameRate defines the target frame rate (60 by default)
  74611. * @returns a SceneOptimizerOptions object
  74612. */
  74613. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74614. /**
  74615. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74616. * @param targetFrameRate defines the target frame rate (60 by default)
  74617. * @returns a SceneOptimizerOptions object
  74618. */
  74619. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74620. /**
  74621. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74622. * @param targetFrameRate defines the target frame rate (60 by default)
  74623. * @returns a SceneOptimizerOptions object
  74624. */
  74625. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74626. }
  74627. /**
  74628. * Class used to run optimizations in order to reach a target frame rate
  74629. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74630. */
  74631. export class SceneOptimizer implements IDisposable {
  74632. private _isRunning;
  74633. private _options;
  74634. private _scene;
  74635. private _currentPriorityLevel;
  74636. private _targetFrameRate;
  74637. private _trackerDuration;
  74638. private _currentFrameRate;
  74639. private _sceneDisposeObserver;
  74640. private _improvementMode;
  74641. /**
  74642. * Defines an observable called when the optimizer reaches the target frame rate
  74643. */
  74644. onSuccessObservable: Observable<SceneOptimizer>;
  74645. /**
  74646. * Defines an observable called when the optimizer enables an optimization
  74647. */
  74648. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74649. /**
  74650. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74651. */
  74652. onFailureObservable: Observable<SceneOptimizer>;
  74653. /**
  74654. * Gets a boolean indicating if the optimizer is in improvement mode
  74655. */
  74656. get isInImprovementMode(): boolean;
  74657. /**
  74658. * Gets the current priority level (0 at start)
  74659. */
  74660. get currentPriorityLevel(): number;
  74661. /**
  74662. * Gets the current frame rate checked by the SceneOptimizer
  74663. */
  74664. get currentFrameRate(): number;
  74665. /**
  74666. * Gets or sets the current target frame rate (60 by default)
  74667. */
  74668. get targetFrameRate(): number;
  74669. /**
  74670. * Gets or sets the current target frame rate (60 by default)
  74671. */
  74672. set targetFrameRate(value: number);
  74673. /**
  74674. * Gets or sets the current interval between two checks (every 2000ms by default)
  74675. */
  74676. get trackerDuration(): number;
  74677. /**
  74678. * Gets or sets the current interval between two checks (every 2000ms by default)
  74679. */
  74680. set trackerDuration(value: number);
  74681. /**
  74682. * Gets the list of active optimizations
  74683. */
  74684. get optimizations(): SceneOptimization[];
  74685. /**
  74686. * Creates a new SceneOptimizer
  74687. * @param scene defines the scene to work on
  74688. * @param options defines the options to use with the SceneOptimizer
  74689. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74690. * @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)
  74691. */
  74692. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74693. /**
  74694. * Stops the current optimizer
  74695. */
  74696. stop(): void;
  74697. /**
  74698. * Reset the optimizer to initial step (current priority level = 0)
  74699. */
  74700. reset(): void;
  74701. /**
  74702. * Start the optimizer. By default it will try to reach a specific framerate
  74703. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74704. */
  74705. start(): void;
  74706. private _checkCurrentState;
  74707. /**
  74708. * Release all resources
  74709. */
  74710. dispose(): void;
  74711. /**
  74712. * Helper function to create a SceneOptimizer with one single line of code
  74713. * @param scene defines the scene to work on
  74714. * @param options defines the options to use with the SceneOptimizer
  74715. * @param onSuccess defines a callback to call on success
  74716. * @param onFailure defines a callback to call on failure
  74717. * @returns the new SceneOptimizer object
  74718. */
  74719. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74720. }
  74721. }
  74722. declare module BABYLON {
  74723. /**
  74724. * Class used to serialize a scene into a string
  74725. */
  74726. export class SceneSerializer {
  74727. /**
  74728. * Clear cache used by a previous serialization
  74729. */
  74730. static ClearCache(): void;
  74731. /**
  74732. * Serialize a scene into a JSON compatible object
  74733. * @param scene defines the scene to serialize
  74734. * @returns a JSON compatible object
  74735. */
  74736. static Serialize(scene: Scene): any;
  74737. /**
  74738. * Serialize a mesh into a JSON compatible object
  74739. * @param toSerialize defines the mesh to serialize
  74740. * @param withParents defines if parents must be serialized as well
  74741. * @param withChildren defines if children must be serialized as well
  74742. * @returns a JSON compatible object
  74743. */
  74744. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74745. }
  74746. }
  74747. declare module BABYLON {
  74748. /**
  74749. * Class used to host texture specific utilities
  74750. */
  74751. export class TextureTools {
  74752. /**
  74753. * Uses the GPU to create a copy texture rescaled at a given size
  74754. * @param texture Texture to copy from
  74755. * @param width defines the desired width
  74756. * @param height defines the desired height
  74757. * @param useBilinearMode defines if bilinear mode has to be used
  74758. * @return the generated texture
  74759. */
  74760. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74761. }
  74762. }
  74763. declare module BABYLON {
  74764. /**
  74765. * This represents the different options available for the video capture.
  74766. */
  74767. export interface VideoRecorderOptions {
  74768. /** Defines the mime type of the video. */
  74769. mimeType: string;
  74770. /** Defines the FPS the video should be recorded at. */
  74771. fps: number;
  74772. /** Defines the chunk size for the recording data. */
  74773. recordChunckSize: number;
  74774. /** The audio tracks to attach to the recording. */
  74775. audioTracks?: MediaStreamTrack[];
  74776. }
  74777. /**
  74778. * This can help with recording videos from BabylonJS.
  74779. * This is based on the available WebRTC functionalities of the browser.
  74780. *
  74781. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74782. */
  74783. export class VideoRecorder {
  74784. private static readonly _defaultOptions;
  74785. /**
  74786. * Returns whether or not the VideoRecorder is available in your browser.
  74787. * @param engine Defines the Babylon Engine.
  74788. * @returns true if supported otherwise false.
  74789. */
  74790. static IsSupported(engine: Engine): boolean;
  74791. private readonly _options;
  74792. private _canvas;
  74793. private _mediaRecorder;
  74794. private _recordedChunks;
  74795. private _fileName;
  74796. private _resolve;
  74797. private _reject;
  74798. /**
  74799. * True when a recording is already in progress.
  74800. */
  74801. get isRecording(): boolean;
  74802. /**
  74803. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74804. * @param engine Defines the BabylonJS Engine you wish to record.
  74805. * @param options Defines options that can be used to customize the capture.
  74806. */
  74807. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74808. /**
  74809. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74810. */
  74811. stopRecording(): void;
  74812. /**
  74813. * Starts recording the canvas for a max duration specified in parameters.
  74814. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74815. * If null no automatic download will start and you can rely on the promise to get the data back.
  74816. * @param maxDuration Defines the maximum recording time in seconds.
  74817. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74818. * @return A promise callback at the end of the recording with the video data in Blob.
  74819. */
  74820. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74821. /**
  74822. * Releases internal resources used during the recording.
  74823. */
  74824. dispose(): void;
  74825. private _handleDataAvailable;
  74826. private _handleError;
  74827. private _handleStop;
  74828. }
  74829. }
  74830. declare module BABYLON {
  74831. /**
  74832. * Class containing a set of static utilities functions for screenshots
  74833. */
  74834. export class ScreenshotTools {
  74835. /**
  74836. * Captures a screenshot of the current rendering
  74837. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74838. * @param engine defines the rendering engine
  74839. * @param camera defines the source camera
  74840. * @param size This parameter can be set to a single number or to an object with the
  74841. * following (optional) properties: precision, width, height. If a single number is passed,
  74842. * it will be used for both width and height. If an object is passed, the screenshot size
  74843. * will be derived from the parameters. The precision property is a multiplier allowing
  74844. * rendering at a higher or lower resolution
  74845. * @param successCallback defines the callback receives a single parameter which contains the
  74846. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74847. * src parameter of an <img> to display it
  74848. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74849. * Check your browser for supported MIME types
  74850. */
  74851. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74852. /**
  74853. * Captures a screenshot of the current rendering
  74854. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74855. * @param engine defines the rendering engine
  74856. * @param camera defines the source camera
  74857. * @param size This parameter can be set to a single number or to an object with the
  74858. * following (optional) properties: precision, width, height. If a single number is passed,
  74859. * it will be used for both width and height. If an object is passed, the screenshot size
  74860. * will be derived from the parameters. The precision property is a multiplier allowing
  74861. * rendering at a higher or lower resolution
  74862. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74863. * Check your browser for supported MIME types
  74864. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74865. * to the src parameter of an <img> to display it
  74866. */
  74867. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74868. /**
  74869. * Generates an image screenshot from the specified camera.
  74870. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74871. * @param engine The engine to use for rendering
  74872. * @param camera The camera to use for rendering
  74873. * @param size This parameter can be set to a single number or to an object with the
  74874. * following (optional) properties: precision, width, height. If a single number is passed,
  74875. * it will be used for both width and height. If an object is passed, the screenshot size
  74876. * will be derived from the parameters. The precision property is a multiplier allowing
  74877. * rendering at a higher or lower resolution
  74878. * @param successCallback The callback receives a single parameter which contains the
  74879. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74880. * src parameter of an <img> to display it
  74881. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74882. * Check your browser for supported MIME types
  74883. * @param samples Texture samples (default: 1)
  74884. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74885. * @param fileName A name for for the downloaded file.
  74886. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74887. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74888. */
  74889. 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;
  74890. /**
  74891. * Generates an image screenshot from the specified camera.
  74892. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74893. * @param engine The engine to use for rendering
  74894. * @param camera The camera to use for rendering
  74895. * @param size This parameter can be set to a single number or to an object with the
  74896. * following (optional) properties: precision, width, height. If a single number is passed,
  74897. * it will be used for both width and height. If an object is passed, the screenshot size
  74898. * will be derived from the parameters. The precision property is a multiplier allowing
  74899. * rendering at a higher or lower resolution
  74900. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74901. * Check your browser for supported MIME types
  74902. * @param samples Texture samples (default: 1)
  74903. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74904. * @param fileName A name for for the downloaded file.
  74905. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74906. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74907. * to the src parameter of an <img> to display it
  74908. */
  74909. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74910. /**
  74911. * Gets height and width for screenshot size
  74912. * @private
  74913. */
  74914. private static _getScreenshotSize;
  74915. }
  74916. }
  74917. declare module BABYLON {
  74918. /**
  74919. * Interface for a data buffer
  74920. */
  74921. export interface IDataBuffer {
  74922. /**
  74923. * Reads bytes from the data buffer.
  74924. * @param byteOffset The byte offset to read
  74925. * @param byteLength The byte length to read
  74926. * @returns A promise that resolves when the bytes are read
  74927. */
  74928. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74929. /**
  74930. * The byte length of the buffer.
  74931. */
  74932. readonly byteLength: number;
  74933. }
  74934. /**
  74935. * Utility class for reading from a data buffer
  74936. */
  74937. export class DataReader {
  74938. /**
  74939. * The data buffer associated with this data reader.
  74940. */
  74941. readonly buffer: IDataBuffer;
  74942. /**
  74943. * The current byte offset from the beginning of the data buffer.
  74944. */
  74945. byteOffset: number;
  74946. private _dataView;
  74947. private _dataByteOffset;
  74948. /**
  74949. * Constructor
  74950. * @param buffer The buffer to read
  74951. */
  74952. constructor(buffer: IDataBuffer);
  74953. /**
  74954. * Loads the given byte length.
  74955. * @param byteLength The byte length to load
  74956. * @returns A promise that resolves when the load is complete
  74957. */
  74958. loadAsync(byteLength: number): Promise<void>;
  74959. /**
  74960. * Read a unsigned 32-bit integer from the currently loaded data range.
  74961. * @returns The 32-bit integer read
  74962. */
  74963. readUint32(): number;
  74964. /**
  74965. * Read a byte array from the currently loaded data range.
  74966. * @param byteLength The byte length to read
  74967. * @returns The byte array read
  74968. */
  74969. readUint8Array(byteLength: number): Uint8Array;
  74970. /**
  74971. * Read a string from the currently loaded data range.
  74972. * @param byteLength The byte length to read
  74973. * @returns The string read
  74974. */
  74975. readString(byteLength: number): string;
  74976. /**
  74977. * Skips the given byte length the currently loaded data range.
  74978. * @param byteLength The byte length to skip
  74979. */
  74980. skipBytes(byteLength: number): void;
  74981. }
  74982. }
  74983. declare module BABYLON {
  74984. /**
  74985. * Class for storing data to local storage if available or in-memory storage otherwise
  74986. */
  74987. export class DataStorage {
  74988. private static _Storage;
  74989. private static _GetStorage;
  74990. /**
  74991. * Reads a string from the data storage
  74992. * @param key The key to read
  74993. * @param defaultValue The value if the key doesn't exist
  74994. * @returns The string value
  74995. */
  74996. static ReadString(key: string, defaultValue: string): string;
  74997. /**
  74998. * Writes a string to the data storage
  74999. * @param key The key to write
  75000. * @param value The value to write
  75001. */
  75002. static WriteString(key: string, value: string): void;
  75003. /**
  75004. * Reads a boolean from the data storage
  75005. * @param key The key to read
  75006. * @param defaultValue The value if the key doesn't exist
  75007. * @returns The boolean value
  75008. */
  75009. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75010. /**
  75011. * Writes a boolean to the data storage
  75012. * @param key The key to write
  75013. * @param value The value to write
  75014. */
  75015. static WriteBoolean(key: string, value: boolean): void;
  75016. /**
  75017. * Reads a number from the data storage
  75018. * @param key The key to read
  75019. * @param defaultValue The value if the key doesn't exist
  75020. * @returns The number value
  75021. */
  75022. static ReadNumber(key: string, defaultValue: number): number;
  75023. /**
  75024. * Writes a number to the data storage
  75025. * @param key The key to write
  75026. * @param value The value to write
  75027. */
  75028. static WriteNumber(key: string, value: number): void;
  75029. }
  75030. }
  75031. declare module BABYLON {
  75032. /**
  75033. * Class used to record delta files between 2 scene states
  75034. */
  75035. export class SceneRecorder {
  75036. private _trackedScene;
  75037. private _savedJSON;
  75038. /**
  75039. * Track a given scene. This means the current scene state will be considered the original state
  75040. * @param scene defines the scene to track
  75041. */
  75042. track(scene: Scene): void;
  75043. /**
  75044. * Get the delta between current state and original state
  75045. * @returns a string containing the delta
  75046. */
  75047. getDelta(): any;
  75048. private _compareArray;
  75049. private _compareObjects;
  75050. private _compareCollections;
  75051. private static GetShadowGeneratorById;
  75052. /**
  75053. * Apply a given delta to a given scene
  75054. * @param deltaJSON defines the JSON containing the delta
  75055. * @param scene defines the scene to apply the delta to
  75056. */
  75057. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75058. private static _ApplyPropertiesToEntity;
  75059. private static _ApplyDeltaForEntity;
  75060. }
  75061. }
  75062. declare module BABYLON {
  75063. /**
  75064. * A 3D trajectory consisting of an order list of vectors describing a
  75065. * path of motion through 3D space.
  75066. */
  75067. export class Trajectory {
  75068. private _points;
  75069. private readonly _segmentLength;
  75070. /**
  75071. * Serialize to JSON.
  75072. * @returns serialized JSON string
  75073. */
  75074. serialize(): string;
  75075. /**
  75076. * Deserialize from JSON.
  75077. * @param json serialized JSON string
  75078. * @returns deserialized Trajectory
  75079. */
  75080. static Deserialize(json: string): Trajectory;
  75081. /**
  75082. * Create a new empty Trajectory.
  75083. * @param segmentLength radius of discretization for Trajectory points
  75084. */
  75085. constructor(segmentLength?: number);
  75086. /**
  75087. * Get the length of the Trajectory.
  75088. * @returns length of the Trajectory
  75089. */
  75090. getLength(): number;
  75091. /**
  75092. * Append a new point to the Trajectory.
  75093. * NOTE: This implementation has many allocations.
  75094. * @param point point to append to the Trajectory
  75095. */
  75096. add(point: DeepImmutable<Vector3>): void;
  75097. /**
  75098. * Create a new Trajectory with a segment length chosen to make it
  75099. * probable that the new Trajectory will have a specified number of
  75100. * segments. This operation is imprecise.
  75101. * @param targetResolution number of segments desired
  75102. * @returns new Trajectory with approximately the requested number of segments
  75103. */
  75104. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75105. /**
  75106. * Convert Trajectory segments into tokenized representation. This
  75107. * representation is an array of numbers where each nth number is the
  75108. * index of the token which is most similar to the nth segment of the
  75109. * Trajectory.
  75110. * @param tokens list of vectors which serve as discrete tokens
  75111. * @returns list of indices of most similar token per segment
  75112. */
  75113. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75114. private static _forwardDir;
  75115. private static _inverseFromVec;
  75116. private static _upDir;
  75117. private static _fromToVec;
  75118. private static _lookMatrix;
  75119. /**
  75120. * Transform the rotation (i.e., direction) of a segment to isolate
  75121. * the relative transformation represented by the segment. This operation
  75122. * may or may not succeed due to singularities in the equations that define
  75123. * motion relativity in this context.
  75124. * @param priorVec the origin of the prior segment
  75125. * @param fromVec the origin of the current segment
  75126. * @param toVec the destination of the current segment
  75127. * @param result reference to output variable
  75128. * @returns whether or not transformation was successful
  75129. */
  75130. private static _transformSegmentDirToRef;
  75131. private static _bestMatch;
  75132. private static _score;
  75133. private static _bestScore;
  75134. /**
  75135. * Determine which token vector is most similar to the
  75136. * segment vector.
  75137. * @param segment segment vector
  75138. * @param tokens token vector list
  75139. * @returns index of the most similar token to the segment
  75140. */
  75141. private static _tokenizeSegment;
  75142. }
  75143. /**
  75144. * Class representing a set of known, named trajectories to which Trajectories can be
  75145. * added and using which Trajectories can be recognized.
  75146. */
  75147. export class TrajectoryClassifier {
  75148. private _maximumAllowableMatchCost;
  75149. private _vector3Alphabet;
  75150. private _levenshteinAlphabet;
  75151. private _nameToDescribedTrajectory;
  75152. /**
  75153. * Serialize to JSON.
  75154. * @returns JSON serialization
  75155. */
  75156. serialize(): string;
  75157. /**
  75158. * Deserialize from JSON.
  75159. * @param json JSON serialization
  75160. * @returns deserialized TrajectorySet
  75161. */
  75162. static Deserialize(json: string): TrajectoryClassifier;
  75163. /**
  75164. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75165. * VERY naive, need to be generating these things from known
  75166. * sets. Better version later, probably eliminating this one.
  75167. * @returns auto-generated TrajectorySet
  75168. */
  75169. static Generate(): TrajectoryClassifier;
  75170. private constructor();
  75171. /**
  75172. * Add a new Trajectory to the set with a given name.
  75173. * @param trajectory new Trajectory to be added
  75174. * @param classification name to which to add the Trajectory
  75175. */
  75176. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75177. /**
  75178. * Remove a known named trajectory and all Trajectories associated with it.
  75179. * @param classification name to remove
  75180. * @returns whether anything was removed
  75181. */
  75182. deleteClassification(classification: string): boolean;
  75183. /**
  75184. * Attempt to recognize a Trajectory from among all the classifications
  75185. * already known to the classifier.
  75186. * @param trajectory Trajectory to be recognized
  75187. * @returns classification of Trajectory if recognized, null otherwise
  75188. */
  75189. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75190. }
  75191. }
  75192. declare module BABYLON {
  75193. /**
  75194. * An interface for all Hit test features
  75195. */
  75196. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75197. /**
  75198. * Triggered when new babylon (transformed) hit test results are available
  75199. */
  75200. onHitTestResultObservable: Observable<T[]>;
  75201. }
  75202. /**
  75203. * Options used for hit testing
  75204. */
  75205. export interface IWebXRLegacyHitTestOptions {
  75206. /**
  75207. * Only test when user interacted with the scene. Default - hit test every frame
  75208. */
  75209. testOnPointerDownOnly?: boolean;
  75210. /**
  75211. * The node to use to transform the local results to world coordinates
  75212. */
  75213. worldParentNode?: TransformNode;
  75214. }
  75215. /**
  75216. * Interface defining the babylon result of raycasting/hit-test
  75217. */
  75218. export interface IWebXRLegacyHitResult {
  75219. /**
  75220. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75221. */
  75222. transformationMatrix: Matrix;
  75223. /**
  75224. * The native hit test result
  75225. */
  75226. xrHitResult: XRHitResult | XRHitTestResult;
  75227. }
  75228. /**
  75229. * The currently-working hit-test module.
  75230. * Hit test (or Ray-casting) is used to interact with the real world.
  75231. * For further information read here - https://github.com/immersive-web/hit-test
  75232. */
  75233. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75234. /**
  75235. * options to use when constructing this feature
  75236. */
  75237. readonly options: IWebXRLegacyHitTestOptions;
  75238. private _direction;
  75239. private _mat;
  75240. private _onSelectEnabled;
  75241. private _origin;
  75242. /**
  75243. * The module's name
  75244. */
  75245. static readonly Name: string;
  75246. /**
  75247. * The (Babylon) version of this module.
  75248. * This is an integer representing the implementation version.
  75249. * This number does not correspond to the WebXR specs version
  75250. */
  75251. static readonly Version: number;
  75252. /**
  75253. * Populated with the last native XR Hit Results
  75254. */
  75255. lastNativeXRHitResults: XRHitResult[];
  75256. /**
  75257. * Triggered when new babylon (transformed) hit test results are available
  75258. */
  75259. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75260. /**
  75261. * Creates a new instance of the (legacy version) hit test feature
  75262. * @param _xrSessionManager an instance of WebXRSessionManager
  75263. * @param options options to use when constructing this feature
  75264. */
  75265. constructor(_xrSessionManager: WebXRSessionManager,
  75266. /**
  75267. * options to use when constructing this feature
  75268. */
  75269. options?: IWebXRLegacyHitTestOptions);
  75270. /**
  75271. * execute a hit test with an XR Ray
  75272. *
  75273. * @param xrSession a native xrSession that will execute this hit test
  75274. * @param xrRay the ray (position and direction) to use for ray-casting
  75275. * @param referenceSpace native XR reference space to use for the hit-test
  75276. * @param filter filter function that will filter the results
  75277. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75278. */
  75279. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75280. /**
  75281. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75282. * @param event the (select) event to use to select with
  75283. * @param referenceSpace the reference space to use for this hit test
  75284. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75285. */
  75286. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75287. /**
  75288. * attach this feature
  75289. * Will usually be called by the features manager
  75290. *
  75291. * @returns true if successful.
  75292. */
  75293. attach(): boolean;
  75294. /**
  75295. * detach this feature.
  75296. * Will usually be called by the features manager
  75297. *
  75298. * @returns true if successful.
  75299. */
  75300. detach(): boolean;
  75301. /**
  75302. * Dispose this feature and all of the resources attached
  75303. */
  75304. dispose(): void;
  75305. protected _onXRFrame(frame: XRFrame): void;
  75306. private _onHitTestResults;
  75307. private _onSelect;
  75308. }
  75309. }
  75310. declare module BABYLON {
  75311. /**
  75312. * Options used for hit testing (version 2)
  75313. */
  75314. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75315. /**
  75316. * Do not create a permanent hit test. Will usually be used when only
  75317. * transient inputs are needed.
  75318. */
  75319. disablePermanentHitTest?: boolean;
  75320. /**
  75321. * Enable transient (for example touch-based) hit test inspections
  75322. */
  75323. enableTransientHitTest?: boolean;
  75324. /**
  75325. * Offset ray for the permanent hit test
  75326. */
  75327. offsetRay?: Vector3;
  75328. /**
  75329. * Offset ray for the transient hit test
  75330. */
  75331. transientOffsetRay?: Vector3;
  75332. /**
  75333. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75334. */
  75335. useReferenceSpace?: boolean;
  75336. /**
  75337. * Override the default entity type(s) of the hit-test result
  75338. */
  75339. entityTypes?: XRHitTestTrackableType[];
  75340. }
  75341. /**
  75342. * Interface defining the babylon result of hit-test
  75343. */
  75344. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75345. /**
  75346. * The input source that generated this hit test (if transient)
  75347. */
  75348. inputSource?: XRInputSource;
  75349. /**
  75350. * Is this a transient hit test
  75351. */
  75352. isTransient?: boolean;
  75353. /**
  75354. * Position of the hit test result
  75355. */
  75356. position: Vector3;
  75357. /**
  75358. * Rotation of the hit test result
  75359. */
  75360. rotationQuaternion: Quaternion;
  75361. /**
  75362. * The native hit test result
  75363. */
  75364. xrHitResult: XRHitTestResult;
  75365. }
  75366. /**
  75367. * The currently-working hit-test module.
  75368. * Hit test (or Ray-casting) is used to interact with the real world.
  75369. * For further information read here - https://github.com/immersive-web/hit-test
  75370. *
  75371. * Tested on chrome (mobile) 80.
  75372. */
  75373. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75374. /**
  75375. * options to use when constructing this feature
  75376. */
  75377. readonly options: IWebXRHitTestOptions;
  75378. private _tmpMat;
  75379. private _tmpPos;
  75380. private _tmpQuat;
  75381. private _transientXrHitTestSource;
  75382. private _xrHitTestSource;
  75383. private initHitTestSource;
  75384. /**
  75385. * The module's name
  75386. */
  75387. static readonly Name: string;
  75388. /**
  75389. * The (Babylon) version of this module.
  75390. * This is an integer representing the implementation version.
  75391. * This number does not correspond to the WebXR specs version
  75392. */
  75393. static readonly Version: number;
  75394. /**
  75395. * When set to true, each hit test will have its own position/rotation objects
  75396. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75397. * the developers will clone them or copy them as they see fit.
  75398. */
  75399. autoCloneTransformation: boolean;
  75400. /**
  75401. * Triggered when new babylon (transformed) hit test results are available
  75402. * Note - this will be called when results come back from the device. It can be an empty array!!
  75403. */
  75404. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75405. /**
  75406. * Use this to temporarily pause hit test checks.
  75407. */
  75408. paused: boolean;
  75409. /**
  75410. * Creates a new instance of the hit test feature
  75411. * @param _xrSessionManager an instance of WebXRSessionManager
  75412. * @param options options to use when constructing this feature
  75413. */
  75414. constructor(_xrSessionManager: WebXRSessionManager,
  75415. /**
  75416. * options to use when constructing this feature
  75417. */
  75418. options?: IWebXRHitTestOptions);
  75419. /**
  75420. * attach this feature
  75421. * Will usually be called by the features manager
  75422. *
  75423. * @returns true if successful.
  75424. */
  75425. attach(): boolean;
  75426. /**
  75427. * detach this feature.
  75428. * Will usually be called by the features manager
  75429. *
  75430. * @returns true if successful.
  75431. */
  75432. detach(): boolean;
  75433. /**
  75434. * Dispose this feature and all of the resources attached
  75435. */
  75436. dispose(): void;
  75437. protected _onXRFrame(frame: XRFrame): void;
  75438. private _processWebXRHitTestResult;
  75439. }
  75440. }
  75441. declare module BABYLON {
  75442. /**
  75443. * Configuration options of the anchor system
  75444. */
  75445. export interface IWebXRAnchorSystemOptions {
  75446. /**
  75447. * a node that will be used to convert local to world coordinates
  75448. */
  75449. worldParentNode?: TransformNode;
  75450. /**
  75451. * If set to true a reference of the created anchors will be kept until the next session starts
  75452. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75453. */
  75454. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75455. }
  75456. /**
  75457. * A babylon container for an XR Anchor
  75458. */
  75459. export interface IWebXRAnchor {
  75460. /**
  75461. * A babylon-assigned ID for this anchor
  75462. */
  75463. id: number;
  75464. /**
  75465. * Transformation matrix to apply to an object attached to this anchor
  75466. */
  75467. transformationMatrix: Matrix;
  75468. /**
  75469. * The native anchor object
  75470. */
  75471. xrAnchor: XRAnchor;
  75472. /**
  75473. * if defined, this object will be constantly updated by the anchor's position and rotation
  75474. */
  75475. attachedNode?: TransformNode;
  75476. }
  75477. /**
  75478. * An implementation of the anchor system for WebXR.
  75479. * For further information see https://github.com/immersive-web/anchors/
  75480. */
  75481. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75482. private _options;
  75483. private _lastFrameDetected;
  75484. private _trackedAnchors;
  75485. private _referenceSpaceForFrameAnchors;
  75486. private _futureAnchors;
  75487. /**
  75488. * The module's name
  75489. */
  75490. static readonly Name: string;
  75491. /**
  75492. * The (Babylon) version of this module.
  75493. * This is an integer representing the implementation version.
  75494. * This number does not correspond to the WebXR specs version
  75495. */
  75496. static readonly Version: number;
  75497. /**
  75498. * Observers registered here will be executed when a new anchor was added to the session
  75499. */
  75500. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75501. /**
  75502. * Observers registered here will be executed when an anchor was removed from the session
  75503. */
  75504. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75505. /**
  75506. * Observers registered here will be executed when an existing anchor updates
  75507. * This can execute N times every frame
  75508. */
  75509. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75510. /**
  75511. * Set the reference space to use for anchor creation, when not using a hit test.
  75512. * Will default to the session's reference space if not defined
  75513. */
  75514. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75515. /**
  75516. * constructs a new anchor system
  75517. * @param _xrSessionManager an instance of WebXRSessionManager
  75518. * @param _options configuration object for this feature
  75519. */
  75520. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75521. private _tmpVector;
  75522. private _tmpQuaternion;
  75523. private _populateTmpTransformation;
  75524. /**
  75525. * Create a new anchor point using a hit test result at a specific point in the scene
  75526. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75527. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75528. *
  75529. * @param hitTestResult The hit test result to use for this anchor creation
  75530. * @param position an optional position offset for this anchor
  75531. * @param rotationQuaternion an optional rotation offset for this anchor
  75532. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75533. */
  75534. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75535. /**
  75536. * Add a new anchor at a specific position and rotation
  75537. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75538. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75539. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75540. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75541. *
  75542. * @param position the position in which to add an anchor
  75543. * @param rotationQuaternion an optional rotation for the anchor transformation
  75544. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75545. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75546. */
  75547. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75548. /**
  75549. * detach this feature.
  75550. * Will usually be called by the features manager
  75551. *
  75552. * @returns true if successful.
  75553. */
  75554. detach(): boolean;
  75555. /**
  75556. * Dispose this feature and all of the resources attached
  75557. */
  75558. dispose(): void;
  75559. protected _onXRFrame(frame: XRFrame): void;
  75560. /**
  75561. * avoiding using Array.find for global support.
  75562. * @param xrAnchor the plane to find in the array
  75563. */
  75564. private _findIndexInAnchorArray;
  75565. private _updateAnchorWithXRFrame;
  75566. private _createAnchorAtTransformation;
  75567. }
  75568. }
  75569. declare module BABYLON {
  75570. /**
  75571. * Options used in the plane detector module
  75572. */
  75573. export interface IWebXRPlaneDetectorOptions {
  75574. /**
  75575. * The node to use to transform the local results to world coordinates
  75576. */
  75577. worldParentNode?: TransformNode;
  75578. /**
  75579. * If set to true a reference of the created planes will be kept until the next session starts
  75580. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75581. */
  75582. doNotRemovePlanesOnSessionEnded?: boolean;
  75583. }
  75584. /**
  75585. * A babylon interface for a WebXR plane.
  75586. * A Plane is actually a polygon, built from N points in space
  75587. *
  75588. * Supported in chrome 79, not supported in canary 81 ATM
  75589. */
  75590. export interface IWebXRPlane {
  75591. /**
  75592. * a babylon-assigned ID for this polygon
  75593. */
  75594. id: number;
  75595. /**
  75596. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75597. */
  75598. polygonDefinition: Array<Vector3>;
  75599. /**
  75600. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75601. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75602. */
  75603. transformationMatrix: Matrix;
  75604. /**
  75605. * the native xr-plane object
  75606. */
  75607. xrPlane: XRPlane;
  75608. }
  75609. /**
  75610. * The plane detector is used to detect planes in the real world when in AR
  75611. * For more information see https://github.com/immersive-web/real-world-geometry/
  75612. */
  75613. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75614. private _options;
  75615. private _detectedPlanes;
  75616. private _enabled;
  75617. private _lastFrameDetected;
  75618. /**
  75619. * The module's name
  75620. */
  75621. static readonly Name: string;
  75622. /**
  75623. * The (Babylon) version of this module.
  75624. * This is an integer representing the implementation version.
  75625. * This number does not correspond to the WebXR specs version
  75626. */
  75627. static readonly Version: number;
  75628. /**
  75629. * Observers registered here will be executed when a new plane was added to the session
  75630. */
  75631. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75632. /**
  75633. * Observers registered here will be executed when a plane is no longer detected in the session
  75634. */
  75635. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75636. /**
  75637. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75638. * This can execute N times every frame
  75639. */
  75640. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75641. /**
  75642. * construct a new Plane Detector
  75643. * @param _xrSessionManager an instance of xr Session manager
  75644. * @param _options configuration to use when constructing this feature
  75645. */
  75646. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75647. /**
  75648. * detach this feature.
  75649. * Will usually be called by the features manager
  75650. *
  75651. * @returns true if successful.
  75652. */
  75653. detach(): boolean;
  75654. /**
  75655. * Dispose this feature and all of the resources attached
  75656. */
  75657. dispose(): void;
  75658. protected _onXRFrame(frame: XRFrame): void;
  75659. private _init;
  75660. private _updatePlaneWithXRPlane;
  75661. /**
  75662. * avoiding using Array.find for global support.
  75663. * @param xrPlane the plane to find in the array
  75664. */
  75665. private findIndexInPlaneArray;
  75666. }
  75667. }
  75668. declare module BABYLON {
  75669. /**
  75670. * Options interface for the background remover plugin
  75671. */
  75672. export interface IWebXRBackgroundRemoverOptions {
  75673. /**
  75674. * Further background meshes to disable when entering AR
  75675. */
  75676. backgroundMeshes?: AbstractMesh[];
  75677. /**
  75678. * flags to configure the removal of the environment helper.
  75679. * If not set, the entire background will be removed. If set, flags should be set as well.
  75680. */
  75681. environmentHelperRemovalFlags?: {
  75682. /**
  75683. * Should the skybox be removed (default false)
  75684. */
  75685. skyBox?: boolean;
  75686. /**
  75687. * Should the ground be removed (default false)
  75688. */
  75689. ground?: boolean;
  75690. };
  75691. /**
  75692. * don't disable the environment helper
  75693. */
  75694. ignoreEnvironmentHelper?: boolean;
  75695. }
  75696. /**
  75697. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75698. */
  75699. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75700. /**
  75701. * read-only options to be used in this module
  75702. */
  75703. readonly options: IWebXRBackgroundRemoverOptions;
  75704. /**
  75705. * The module's name
  75706. */
  75707. static readonly Name: string;
  75708. /**
  75709. * The (Babylon) version of this module.
  75710. * This is an integer representing the implementation version.
  75711. * This number does not correspond to the WebXR specs version
  75712. */
  75713. static readonly Version: number;
  75714. /**
  75715. * registered observers will be triggered when the background state changes
  75716. */
  75717. onBackgroundStateChangedObservable: Observable<boolean>;
  75718. /**
  75719. * constructs a new background remover module
  75720. * @param _xrSessionManager the session manager for this module
  75721. * @param options read-only options to be used in this module
  75722. */
  75723. constructor(_xrSessionManager: WebXRSessionManager,
  75724. /**
  75725. * read-only options to be used in this module
  75726. */
  75727. options?: IWebXRBackgroundRemoverOptions);
  75728. /**
  75729. * attach this feature
  75730. * Will usually be called by the features manager
  75731. *
  75732. * @returns true if successful.
  75733. */
  75734. attach(): boolean;
  75735. /**
  75736. * detach this feature.
  75737. * Will usually be called by the features manager
  75738. *
  75739. * @returns true if successful.
  75740. */
  75741. detach(): boolean;
  75742. /**
  75743. * Dispose this feature and all of the resources attached
  75744. */
  75745. dispose(): void;
  75746. protected _onXRFrame(_xrFrame: XRFrame): void;
  75747. private _setBackgroundState;
  75748. }
  75749. }
  75750. declare module BABYLON {
  75751. /**
  75752. * Options for the controller physics feature
  75753. */
  75754. export class IWebXRControllerPhysicsOptions {
  75755. /**
  75756. * Should the headset get its own impostor
  75757. */
  75758. enableHeadsetImpostor?: boolean;
  75759. /**
  75760. * Optional parameters for the headset impostor
  75761. */
  75762. headsetImpostorParams?: {
  75763. /**
  75764. * The type of impostor to create. Default is sphere
  75765. */
  75766. impostorType: number;
  75767. /**
  75768. * the size of the impostor. Defaults to 10cm
  75769. */
  75770. impostorSize?: number | {
  75771. width: number;
  75772. height: number;
  75773. depth: number;
  75774. };
  75775. /**
  75776. * Friction definitions
  75777. */
  75778. friction?: number;
  75779. /**
  75780. * Restitution
  75781. */
  75782. restitution?: number;
  75783. };
  75784. /**
  75785. * The physics properties of the future impostors
  75786. */
  75787. physicsProperties?: {
  75788. /**
  75789. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75790. * Note that this requires a physics engine that supports mesh impostors!
  75791. */
  75792. useControllerMesh?: boolean;
  75793. /**
  75794. * The type of impostor to create. Default is sphere
  75795. */
  75796. impostorType?: number;
  75797. /**
  75798. * the size of the impostor. Defaults to 10cm
  75799. */
  75800. impostorSize?: number | {
  75801. width: number;
  75802. height: number;
  75803. depth: number;
  75804. };
  75805. /**
  75806. * Friction definitions
  75807. */
  75808. friction?: number;
  75809. /**
  75810. * Restitution
  75811. */
  75812. restitution?: number;
  75813. };
  75814. /**
  75815. * the xr input to use with this pointer selection
  75816. */
  75817. xrInput: WebXRInput;
  75818. }
  75819. /**
  75820. * Add physics impostor to your webxr controllers,
  75821. * including naive calculation of their linear and angular velocity
  75822. */
  75823. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75824. private readonly _options;
  75825. private _attachController;
  75826. private _controllers;
  75827. private _debugMode;
  75828. private _delta;
  75829. private _headsetImpostor?;
  75830. private _headsetMesh?;
  75831. private _lastTimestamp;
  75832. private _tmpQuaternion;
  75833. private _tmpVector;
  75834. /**
  75835. * The module's name
  75836. */
  75837. static readonly Name: string;
  75838. /**
  75839. * The (Babylon) version of this module.
  75840. * This is an integer representing the implementation version.
  75841. * This number does not correspond to the webxr specs version
  75842. */
  75843. static readonly Version: number;
  75844. /**
  75845. * Construct a new Controller Physics Feature
  75846. * @param _xrSessionManager the corresponding xr session manager
  75847. * @param _options options to create this feature with
  75848. */
  75849. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75850. /**
  75851. * @hidden
  75852. * enable debugging - will show console outputs and the impostor mesh
  75853. */
  75854. _enablePhysicsDebug(): void;
  75855. /**
  75856. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75857. * @param xrController the controller to add
  75858. */
  75859. addController(xrController: WebXRInputSource): void;
  75860. /**
  75861. * attach this feature
  75862. * Will usually be called by the features manager
  75863. *
  75864. * @returns true if successful.
  75865. */
  75866. attach(): boolean;
  75867. /**
  75868. * detach this feature.
  75869. * Will usually be called by the features manager
  75870. *
  75871. * @returns true if successful.
  75872. */
  75873. detach(): boolean;
  75874. /**
  75875. * Get the headset impostor, if enabled
  75876. * @returns the impostor
  75877. */
  75878. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75879. /**
  75880. * Get the physics impostor of a specific controller.
  75881. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75882. * @param controller the controller or the controller id of which to get the impostor
  75883. * @returns the impostor or null
  75884. */
  75885. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75886. /**
  75887. * Update the physics properties provided in the constructor
  75888. * @param newProperties the new properties object
  75889. */
  75890. setPhysicsProperties(newProperties: {
  75891. impostorType?: number;
  75892. impostorSize?: number | {
  75893. width: number;
  75894. height: number;
  75895. depth: number;
  75896. };
  75897. friction?: number;
  75898. restitution?: number;
  75899. }): void;
  75900. protected _onXRFrame(_xrFrame: any): void;
  75901. private _detachController;
  75902. }
  75903. }
  75904. declare module BABYLON {
  75905. /**
  75906. * A babylon interface for a "WebXR" feature point.
  75907. * Represents the position and confidence value of a given feature point.
  75908. */
  75909. export interface IWebXRFeaturePoint {
  75910. /**
  75911. * Represents the position of the feature point in world space.
  75912. */
  75913. position: Vector3;
  75914. /**
  75915. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75916. */
  75917. confidenceValue: number;
  75918. }
  75919. /**
  75920. * The feature point system is used to detect feature points from real world geometry.
  75921. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75922. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75923. */
  75924. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75925. private _enabled;
  75926. private _featurePointCloud;
  75927. /**
  75928. * The module's name
  75929. */
  75930. static readonly Name: string;
  75931. /**
  75932. * The (Babylon) version of this module.
  75933. * This is an integer representing the implementation version.
  75934. * This number does not correspond to the WebXR specs version
  75935. */
  75936. static readonly Version: number;
  75937. /**
  75938. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75939. * Will notify the observers about which feature points have been added.
  75940. */
  75941. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75942. /**
  75943. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75944. * Will notify the observers about which feature points have been updated.
  75945. */
  75946. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75947. /**
  75948. * The current feature point cloud maintained across frames.
  75949. */
  75950. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75951. /**
  75952. * construct the feature point system
  75953. * @param _xrSessionManager an instance of xr Session manager
  75954. */
  75955. constructor(_xrSessionManager: WebXRSessionManager);
  75956. /**
  75957. * Detach this feature.
  75958. * Will usually be called by the features manager
  75959. *
  75960. * @returns true if successful.
  75961. */
  75962. detach(): boolean;
  75963. /**
  75964. * Dispose this feature and all of the resources attached
  75965. */
  75966. dispose(): void;
  75967. /**
  75968. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75969. */
  75970. protected _onXRFrame(frame: XRFrame): void;
  75971. /**
  75972. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75973. */
  75974. private _init;
  75975. }
  75976. }
  75977. declare module BABYLON {
  75978. /**
  75979. * Configuration interface for the hand tracking feature
  75980. */
  75981. export interface IWebXRHandTrackingOptions {
  75982. /**
  75983. * The xrInput that will be used as source for new hands
  75984. */
  75985. xrInput: WebXRInput;
  75986. /**
  75987. * Configuration object for the joint meshes
  75988. */
  75989. jointMeshes?: {
  75990. /**
  75991. * Should the meshes created be invisible (defaults to false)
  75992. */
  75993. invisible?: boolean;
  75994. /**
  75995. * A source mesh to be used to create instances. Defaults to a sphere.
  75996. * This mesh will be the source for all other (25) meshes.
  75997. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75998. */
  75999. sourceMesh?: Mesh;
  76000. /**
  76001. * This function will be called after a mesh was created for a specific joint.
  76002. * Using this function you can either manipulate the instance or return a new mesh.
  76003. * When returning a new mesh the instance created before will be disposed
  76004. */
  76005. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76006. /**
  76007. * Should the source mesh stay visible. Defaults to false
  76008. */
  76009. keepOriginalVisible?: boolean;
  76010. /**
  76011. * Scale factor for all instances (defaults to 2)
  76012. */
  76013. scaleFactor?: number;
  76014. /**
  76015. * Should each instance have its own physics impostor
  76016. */
  76017. enablePhysics?: boolean;
  76018. /**
  76019. * If enabled, override default physics properties
  76020. */
  76021. physicsProps?: {
  76022. friction?: number;
  76023. restitution?: number;
  76024. impostorType?: number;
  76025. };
  76026. /**
  76027. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76028. */
  76029. handMesh?: AbstractMesh;
  76030. };
  76031. }
  76032. /**
  76033. * Parts of the hands divided to writs and finger names
  76034. */
  76035. export const enum HandPart {
  76036. /**
  76037. * HandPart - Wrist
  76038. */
  76039. WRIST = "wrist",
  76040. /**
  76041. * HandPart - The THumb
  76042. */
  76043. THUMB = "thumb",
  76044. /**
  76045. * HandPart - Index finger
  76046. */
  76047. INDEX = "index",
  76048. /**
  76049. * HandPart - Middle finger
  76050. */
  76051. MIDDLE = "middle",
  76052. /**
  76053. * HandPart - Ring finger
  76054. */
  76055. RING = "ring",
  76056. /**
  76057. * HandPart - Little finger
  76058. */
  76059. LITTLE = "little"
  76060. }
  76061. /**
  76062. * Representing a single hand (with its corresponding native XRHand object)
  76063. */
  76064. export class WebXRHand implements IDisposable {
  76065. /** the controller to which the hand correlates */
  76066. readonly xrController: WebXRInputSource;
  76067. /** the meshes to be used to track the hand joints */
  76068. readonly trackedMeshes: AbstractMesh[];
  76069. /**
  76070. * Hand-parts definition (key is HandPart)
  76071. */
  76072. handPartsDefinition: {
  76073. [key: string]: number[];
  76074. };
  76075. /**
  76076. * Populate the HandPartsDefinition object.
  76077. * This is called as a side effect since certain browsers don't have XRHand defined.
  76078. */
  76079. private generateHandPartsDefinition;
  76080. /**
  76081. * Construct a new hand object
  76082. * @param xrController the controller to which the hand correlates
  76083. * @param trackedMeshes the meshes to be used to track the hand joints
  76084. */
  76085. constructor(
  76086. /** the controller to which the hand correlates */
  76087. xrController: WebXRInputSource,
  76088. /** the meshes to be used to track the hand joints */
  76089. trackedMeshes: AbstractMesh[]);
  76090. /**
  76091. * Update this hand from the latest xr frame
  76092. * @param xrFrame xrFrame to update from
  76093. * @param referenceSpace The current viewer reference space
  76094. * @param scaleFactor optional scale factor for the meshes
  76095. */
  76096. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76097. /**
  76098. * Get meshes of part of the hand
  76099. * @param part the part of hand to get
  76100. * @returns An array of meshes that correlate to the hand part requested
  76101. */
  76102. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76103. /**
  76104. * Dispose this Hand object
  76105. */
  76106. dispose(): void;
  76107. }
  76108. /**
  76109. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76110. */
  76111. export class WebXRHandTracking extends WebXRAbstractFeature {
  76112. /**
  76113. * options to use when constructing this feature
  76114. */
  76115. readonly options: IWebXRHandTrackingOptions;
  76116. private static _idCounter;
  76117. /**
  76118. * The module's name
  76119. */
  76120. static readonly Name: string;
  76121. /**
  76122. * The (Babylon) version of this module.
  76123. * This is an integer representing the implementation version.
  76124. * This number does not correspond to the WebXR specs version
  76125. */
  76126. static readonly Version: number;
  76127. /**
  76128. * This observable will notify registered observers when a new hand object was added and initialized
  76129. */
  76130. onHandAddedObservable: Observable<WebXRHand>;
  76131. /**
  76132. * This observable will notify its observers right before the hand object is disposed
  76133. */
  76134. onHandRemovedObservable: Observable<WebXRHand>;
  76135. private _hands;
  76136. /**
  76137. * Creates a new instance of the hit test feature
  76138. * @param _xrSessionManager an instance of WebXRSessionManager
  76139. * @param options options to use when constructing this feature
  76140. */
  76141. constructor(_xrSessionManager: WebXRSessionManager,
  76142. /**
  76143. * options to use when constructing this feature
  76144. */
  76145. options: IWebXRHandTrackingOptions);
  76146. /**
  76147. * Check if the needed objects are defined.
  76148. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76149. */
  76150. isCompatible(): boolean;
  76151. /**
  76152. * attach this feature
  76153. * Will usually be called by the features manager
  76154. *
  76155. * @returns true if successful.
  76156. */
  76157. attach(): boolean;
  76158. /**
  76159. * detach this feature.
  76160. * Will usually be called by the features manager
  76161. *
  76162. * @returns true if successful.
  76163. */
  76164. detach(): boolean;
  76165. /**
  76166. * Dispose this feature and all of the resources attached
  76167. */
  76168. dispose(): void;
  76169. /**
  76170. * Get the hand object according to the controller id
  76171. * @param controllerId the controller id to which we want to get the hand
  76172. * @returns null if not found or the WebXRHand object if found
  76173. */
  76174. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76175. /**
  76176. * Get a hand object according to the requested handedness
  76177. * @param handedness the handedness to request
  76178. * @returns null if not found or the WebXRHand object if found
  76179. */
  76180. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76181. protected _onXRFrame(_xrFrame: XRFrame): void;
  76182. private _attachHand;
  76183. private _detachHand;
  76184. }
  76185. }
  76186. declare module BABYLON {
  76187. /**
  76188. * The motion controller class for all microsoft mixed reality controllers
  76189. */
  76190. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76191. protected readonly _mapping: {
  76192. defaultButton: {
  76193. valueNodeName: string;
  76194. unpressedNodeName: string;
  76195. pressedNodeName: string;
  76196. };
  76197. defaultAxis: {
  76198. valueNodeName: string;
  76199. minNodeName: string;
  76200. maxNodeName: string;
  76201. };
  76202. buttons: {
  76203. "xr-standard-trigger": {
  76204. rootNodeName: string;
  76205. componentProperty: string;
  76206. states: string[];
  76207. };
  76208. "xr-standard-squeeze": {
  76209. rootNodeName: string;
  76210. componentProperty: string;
  76211. states: string[];
  76212. };
  76213. "xr-standard-touchpad": {
  76214. rootNodeName: string;
  76215. labelAnchorNodeName: string;
  76216. touchPointNodeName: string;
  76217. };
  76218. "xr-standard-thumbstick": {
  76219. rootNodeName: string;
  76220. componentProperty: string;
  76221. states: string[];
  76222. };
  76223. };
  76224. axes: {
  76225. "xr-standard-touchpad": {
  76226. "x-axis": {
  76227. rootNodeName: string;
  76228. };
  76229. "y-axis": {
  76230. rootNodeName: string;
  76231. };
  76232. };
  76233. "xr-standard-thumbstick": {
  76234. "x-axis": {
  76235. rootNodeName: string;
  76236. };
  76237. "y-axis": {
  76238. rootNodeName: string;
  76239. };
  76240. };
  76241. };
  76242. };
  76243. /**
  76244. * The base url used to load the left and right controller models
  76245. */
  76246. static MODEL_BASE_URL: string;
  76247. /**
  76248. * The name of the left controller model file
  76249. */
  76250. static MODEL_LEFT_FILENAME: string;
  76251. /**
  76252. * The name of the right controller model file
  76253. */
  76254. static MODEL_RIGHT_FILENAME: string;
  76255. profileId: string;
  76256. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76257. protected _getFilenameAndPath(): {
  76258. filename: string;
  76259. path: string;
  76260. };
  76261. protected _getModelLoadingConstraints(): boolean;
  76262. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76263. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76264. protected _updateModel(): void;
  76265. }
  76266. }
  76267. declare module BABYLON {
  76268. /**
  76269. * The motion controller class for oculus touch (quest, rift).
  76270. * This class supports legacy mapping as well the standard xr mapping
  76271. */
  76272. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76273. private _forceLegacyControllers;
  76274. private _modelRootNode;
  76275. /**
  76276. * The base url used to load the left and right controller models
  76277. */
  76278. static MODEL_BASE_URL: string;
  76279. /**
  76280. * The name of the left controller model file
  76281. */
  76282. static MODEL_LEFT_FILENAME: string;
  76283. /**
  76284. * The name of the right controller model file
  76285. */
  76286. static MODEL_RIGHT_FILENAME: string;
  76287. /**
  76288. * Base Url for the Quest controller model.
  76289. */
  76290. static QUEST_MODEL_BASE_URL: string;
  76291. profileId: string;
  76292. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76293. protected _getFilenameAndPath(): {
  76294. filename: string;
  76295. path: string;
  76296. };
  76297. protected _getModelLoadingConstraints(): boolean;
  76298. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76299. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76300. protected _updateModel(): void;
  76301. /**
  76302. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76303. * between the touch and touch 2.
  76304. */
  76305. private _isQuest;
  76306. }
  76307. }
  76308. declare module BABYLON {
  76309. /**
  76310. * The motion controller class for the standard HTC-Vive controllers
  76311. */
  76312. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76313. private _modelRootNode;
  76314. /**
  76315. * The base url used to load the left and right controller models
  76316. */
  76317. static MODEL_BASE_URL: string;
  76318. /**
  76319. * File name for the controller model.
  76320. */
  76321. static MODEL_FILENAME: string;
  76322. profileId: string;
  76323. /**
  76324. * Create a new Vive motion controller object
  76325. * @param scene the scene to use to create this controller
  76326. * @param gamepadObject the corresponding gamepad object
  76327. * @param handedness the handedness of the controller
  76328. */
  76329. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76330. protected _getFilenameAndPath(): {
  76331. filename: string;
  76332. path: string;
  76333. };
  76334. protected _getModelLoadingConstraints(): boolean;
  76335. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76336. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76337. protected _updateModel(): void;
  76338. }
  76339. }
  76340. declare module BABYLON {
  76341. /**
  76342. * A cursor which tracks a point on a path
  76343. */
  76344. export class PathCursor {
  76345. private path;
  76346. /**
  76347. * Stores path cursor callbacks for when an onchange event is triggered
  76348. */
  76349. private _onchange;
  76350. /**
  76351. * The value of the path cursor
  76352. */
  76353. value: number;
  76354. /**
  76355. * The animation array of the path cursor
  76356. */
  76357. animations: Animation[];
  76358. /**
  76359. * Initializes the path cursor
  76360. * @param path The path to track
  76361. */
  76362. constructor(path: Path2);
  76363. /**
  76364. * Gets the cursor point on the path
  76365. * @returns A point on the path cursor at the cursor location
  76366. */
  76367. getPoint(): Vector3;
  76368. /**
  76369. * Moves the cursor ahead by the step amount
  76370. * @param step The amount to move the cursor forward
  76371. * @returns This path cursor
  76372. */
  76373. moveAhead(step?: number): PathCursor;
  76374. /**
  76375. * Moves the cursor behind by the step amount
  76376. * @param step The amount to move the cursor back
  76377. * @returns This path cursor
  76378. */
  76379. moveBack(step?: number): PathCursor;
  76380. /**
  76381. * Moves the cursor by the step amount
  76382. * If the step amount is greater than one, an exception is thrown
  76383. * @param step The amount to move the cursor
  76384. * @returns This path cursor
  76385. */
  76386. move(step: number): PathCursor;
  76387. /**
  76388. * Ensures that the value is limited between zero and one
  76389. * @returns This path cursor
  76390. */
  76391. private ensureLimits;
  76392. /**
  76393. * Runs onchange callbacks on change (used by the animation engine)
  76394. * @returns This path cursor
  76395. */
  76396. private raiseOnChange;
  76397. /**
  76398. * Executes a function on change
  76399. * @param f A path cursor onchange callback
  76400. * @returns This path cursor
  76401. */
  76402. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76403. }
  76404. }
  76405. declare module BABYLON {
  76406. /** @hidden */
  76407. export var blurPixelShader: {
  76408. name: string;
  76409. shader: string;
  76410. };
  76411. }
  76412. declare module BABYLON {
  76413. /** @hidden */
  76414. export var pointCloudVertexDeclaration: {
  76415. name: string;
  76416. shader: string;
  76417. };
  76418. }
  76419. // Mixins
  76420. interface Window {
  76421. mozIndexedDB: IDBFactory;
  76422. webkitIndexedDB: IDBFactory;
  76423. msIndexedDB: IDBFactory;
  76424. webkitURL: typeof URL;
  76425. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76426. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76427. WebGLRenderingContext: WebGLRenderingContext;
  76428. MSGesture: MSGesture;
  76429. CANNON: any;
  76430. AudioContext: AudioContext;
  76431. webkitAudioContext: AudioContext;
  76432. PointerEvent: any;
  76433. Math: Math;
  76434. Uint8Array: Uint8ArrayConstructor;
  76435. Float32Array: Float32ArrayConstructor;
  76436. mozURL: typeof URL;
  76437. msURL: typeof URL;
  76438. VRFrameData: any; // WebVR, from specs 1.1
  76439. DracoDecoderModule: any;
  76440. setImmediate(handler: (...args: any[]) => void): number;
  76441. }
  76442. interface HTMLCanvasElement {
  76443. requestPointerLock(): void;
  76444. msRequestPointerLock?(): void;
  76445. mozRequestPointerLock?(): void;
  76446. webkitRequestPointerLock?(): void;
  76447. /** Track wether a record is in progress */
  76448. isRecording: boolean;
  76449. /** Capture Stream method defined by some browsers */
  76450. captureStream(fps?: number): MediaStream;
  76451. }
  76452. interface CanvasRenderingContext2D {
  76453. msImageSmoothingEnabled: boolean;
  76454. }
  76455. interface MouseEvent {
  76456. mozMovementX: number;
  76457. mozMovementY: number;
  76458. webkitMovementX: number;
  76459. webkitMovementY: number;
  76460. msMovementX: number;
  76461. msMovementY: number;
  76462. }
  76463. interface Navigator {
  76464. mozGetVRDevices: (any: any) => any;
  76465. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76466. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76467. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76468. webkitGetGamepads(): Gamepad[];
  76469. msGetGamepads(): Gamepad[];
  76470. webkitGamepads(): Gamepad[];
  76471. }
  76472. interface HTMLVideoElement {
  76473. mozSrcObject: any;
  76474. }
  76475. interface Math {
  76476. fround(x: number): number;
  76477. imul(a: number, b: number): number;
  76478. }
  76479. interface WebGLRenderingContext {
  76480. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76481. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76482. vertexAttribDivisor(index: number, divisor: number): void;
  76483. createVertexArray(): any;
  76484. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76485. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76486. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76487. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76488. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76489. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76490. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76491. // Queries
  76492. createQuery(): WebGLQuery;
  76493. deleteQuery(query: WebGLQuery): void;
  76494. beginQuery(target: number, query: WebGLQuery): void;
  76495. endQuery(target: number): void;
  76496. getQueryParameter(query: WebGLQuery, pname: number): any;
  76497. getQuery(target: number, pname: number): any;
  76498. MAX_SAMPLES: number;
  76499. RGBA8: number;
  76500. READ_FRAMEBUFFER: number;
  76501. DRAW_FRAMEBUFFER: number;
  76502. UNIFORM_BUFFER: number;
  76503. HALF_FLOAT_OES: number;
  76504. RGBA16F: number;
  76505. RGBA32F: number;
  76506. R32F: number;
  76507. RG32F: number;
  76508. RGB32F: number;
  76509. R16F: number;
  76510. RG16F: number;
  76511. RGB16F: number;
  76512. RED: number;
  76513. RG: number;
  76514. R8: number;
  76515. RG8: number;
  76516. UNSIGNED_INT_24_8: number;
  76517. DEPTH24_STENCIL8: number;
  76518. MIN: number;
  76519. MAX: number;
  76520. /* Multiple Render Targets */
  76521. drawBuffers(buffers: number[]): void;
  76522. readBuffer(src: number): void;
  76523. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76524. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76525. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76526. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76527. // Occlusion Query
  76528. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76529. ANY_SAMPLES_PASSED: number;
  76530. QUERY_RESULT_AVAILABLE: number;
  76531. QUERY_RESULT: number;
  76532. }
  76533. interface WebGLProgram {
  76534. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76535. }
  76536. interface EXT_disjoint_timer_query {
  76537. QUERY_COUNTER_BITS_EXT: number;
  76538. TIME_ELAPSED_EXT: number;
  76539. TIMESTAMP_EXT: number;
  76540. GPU_DISJOINT_EXT: number;
  76541. QUERY_RESULT_EXT: number;
  76542. QUERY_RESULT_AVAILABLE_EXT: number;
  76543. queryCounterEXT(query: WebGLQuery, target: number): void;
  76544. createQueryEXT(): WebGLQuery;
  76545. beginQueryEXT(target: number, query: WebGLQuery): void;
  76546. endQueryEXT(target: number): void;
  76547. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76548. deleteQueryEXT(query: WebGLQuery): void;
  76549. }
  76550. interface WebGLUniformLocation {
  76551. _currentState: any;
  76552. }
  76553. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76554. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76555. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76556. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76557. interface WebGLRenderingContext {
  76558. readonly RASTERIZER_DISCARD: number;
  76559. readonly DEPTH_COMPONENT24: number;
  76560. readonly TEXTURE_3D: number;
  76561. readonly TEXTURE_2D_ARRAY: number;
  76562. readonly TEXTURE_COMPARE_FUNC: number;
  76563. readonly TEXTURE_COMPARE_MODE: number;
  76564. readonly COMPARE_REF_TO_TEXTURE: number;
  76565. readonly TEXTURE_WRAP_R: number;
  76566. readonly HALF_FLOAT: number;
  76567. readonly RGB8: number;
  76568. readonly RED_INTEGER: number;
  76569. readonly RG_INTEGER: number;
  76570. readonly RGB_INTEGER: number;
  76571. readonly RGBA_INTEGER: number;
  76572. readonly R8_SNORM: number;
  76573. readonly RG8_SNORM: number;
  76574. readonly RGB8_SNORM: number;
  76575. readonly RGBA8_SNORM: number;
  76576. readonly R8I: number;
  76577. readonly RG8I: number;
  76578. readonly RGB8I: number;
  76579. readonly RGBA8I: number;
  76580. readonly R8UI: number;
  76581. readonly RG8UI: number;
  76582. readonly RGB8UI: number;
  76583. readonly RGBA8UI: number;
  76584. readonly R16I: number;
  76585. readonly RG16I: number;
  76586. readonly RGB16I: number;
  76587. readonly RGBA16I: number;
  76588. readonly R16UI: number;
  76589. readonly RG16UI: number;
  76590. readonly RGB16UI: number;
  76591. readonly RGBA16UI: number;
  76592. readonly R32I: number;
  76593. readonly RG32I: number;
  76594. readonly RGB32I: number;
  76595. readonly RGBA32I: number;
  76596. readonly R32UI: number;
  76597. readonly RG32UI: number;
  76598. readonly RGB32UI: number;
  76599. readonly RGBA32UI: number;
  76600. readonly RGB10_A2UI: number;
  76601. readonly R11F_G11F_B10F: number;
  76602. readonly RGB9_E5: number;
  76603. readonly RGB10_A2: number;
  76604. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76605. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76606. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76607. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76608. readonly DEPTH_COMPONENT32F: number;
  76609. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76610. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76611. 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;
  76612. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76613. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76614. readonly TRANSFORM_FEEDBACK: number;
  76615. readonly INTERLEAVED_ATTRIBS: number;
  76616. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76617. createTransformFeedback(): WebGLTransformFeedback;
  76618. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76619. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76620. beginTransformFeedback(primitiveMode: number): void;
  76621. endTransformFeedback(): void;
  76622. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76623. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76624. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76625. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76626. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76627. }
  76628. interface ImageBitmap {
  76629. readonly width: number;
  76630. readonly height: number;
  76631. close(): void;
  76632. }
  76633. interface WebGLQuery extends WebGLObject {
  76634. }
  76635. declare var WebGLQuery: {
  76636. prototype: WebGLQuery;
  76637. new(): WebGLQuery;
  76638. };
  76639. interface WebGLSampler extends WebGLObject {
  76640. }
  76641. declare var WebGLSampler: {
  76642. prototype: WebGLSampler;
  76643. new(): WebGLSampler;
  76644. };
  76645. interface WebGLSync extends WebGLObject {
  76646. }
  76647. declare var WebGLSync: {
  76648. prototype: WebGLSync;
  76649. new(): WebGLSync;
  76650. };
  76651. interface WebGLTransformFeedback extends WebGLObject {
  76652. }
  76653. declare var WebGLTransformFeedback: {
  76654. prototype: WebGLTransformFeedback;
  76655. new(): WebGLTransformFeedback;
  76656. };
  76657. interface WebGLVertexArrayObject extends WebGLObject {
  76658. }
  76659. declare var WebGLVertexArrayObject: {
  76660. prototype: WebGLVertexArrayObject;
  76661. new(): WebGLVertexArrayObject;
  76662. };
  76663. // Type definitions for WebVR API
  76664. // Project: https://w3c.github.io/webvr/
  76665. // Definitions by: six a <https://github.com/lostfictions>
  76666. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76667. interface VRDisplay extends EventTarget {
  76668. /**
  76669. * Dictionary of capabilities describing the VRDisplay.
  76670. */
  76671. readonly capabilities: VRDisplayCapabilities;
  76672. /**
  76673. * z-depth defining the far plane of the eye view frustum
  76674. * enables mapping of values in the render target depth
  76675. * attachment to scene coordinates. Initially set to 10000.0.
  76676. */
  76677. depthFar: number;
  76678. /**
  76679. * z-depth defining the near plane of the eye view frustum
  76680. * enables mapping of values in the render target depth
  76681. * attachment to scene coordinates. Initially set to 0.01.
  76682. */
  76683. depthNear: number;
  76684. /**
  76685. * An identifier for this distinct VRDisplay. Used as an
  76686. * association point in the Gamepad API.
  76687. */
  76688. readonly displayId: number;
  76689. /**
  76690. * A display name, a user-readable name identifying it.
  76691. */
  76692. readonly displayName: string;
  76693. readonly isConnected: boolean;
  76694. readonly isPresenting: boolean;
  76695. /**
  76696. * If this VRDisplay supports room-scale experiences, the optional
  76697. * stage attribute contains details on the room-scale parameters.
  76698. */
  76699. readonly stageParameters: VRStageParameters | null;
  76700. /**
  76701. * Passing the value returned by `requestAnimationFrame` to
  76702. * `cancelAnimationFrame` will unregister the callback.
  76703. * @param handle Define the hanle of the request to cancel
  76704. */
  76705. cancelAnimationFrame(handle: number): void;
  76706. /**
  76707. * Stops presenting to the VRDisplay.
  76708. * @returns a promise to know when it stopped
  76709. */
  76710. exitPresent(): Promise<void>;
  76711. /**
  76712. * Return the current VREyeParameters for the given eye.
  76713. * @param whichEye Define the eye we want the parameter for
  76714. * @returns the eye parameters
  76715. */
  76716. getEyeParameters(whichEye: string): VREyeParameters;
  76717. /**
  76718. * Populates the passed VRFrameData with the information required to render
  76719. * the current frame.
  76720. * @param frameData Define the data structure to populate
  76721. * @returns true if ok otherwise false
  76722. */
  76723. getFrameData(frameData: VRFrameData): boolean;
  76724. /**
  76725. * Get the layers currently being presented.
  76726. * @returns the list of VR layers
  76727. */
  76728. getLayers(): VRLayer[];
  76729. /**
  76730. * Return a VRPose containing the future predicted pose of the VRDisplay
  76731. * when the current frame will be presented. The value returned will not
  76732. * change until JavaScript has returned control to the browser.
  76733. *
  76734. * The VRPose will contain the position, orientation, velocity,
  76735. * and acceleration of each of these properties.
  76736. * @returns the pose object
  76737. */
  76738. getPose(): VRPose;
  76739. /**
  76740. * Return the current instantaneous pose of the VRDisplay, with no
  76741. * prediction applied.
  76742. * @returns the current instantaneous pose
  76743. */
  76744. getImmediatePose(): VRPose;
  76745. /**
  76746. * The callback passed to `requestAnimationFrame` will be called
  76747. * any time a new frame should be rendered. When the VRDisplay is
  76748. * presenting the callback will be called at the native refresh
  76749. * rate of the HMD. When not presenting this function acts
  76750. * identically to how window.requestAnimationFrame acts. Content should
  76751. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76752. * asynchronously from other displays and at differing refresh rates.
  76753. * @param callback Define the eaction to run next frame
  76754. * @returns the request handle it
  76755. */
  76756. requestAnimationFrame(callback: FrameRequestCallback): number;
  76757. /**
  76758. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76759. * Repeat calls while already presenting will update the VRLayers being displayed.
  76760. * @param layers Define the list of layer to present
  76761. * @returns a promise to know when the request has been fulfilled
  76762. */
  76763. requestPresent(layers: VRLayer[]): Promise<void>;
  76764. /**
  76765. * Reset the pose for this display, treating its current position and
  76766. * orientation as the "origin/zero" values. VRPose.position,
  76767. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76768. * updated when calling resetPose(). This should be called in only
  76769. * sitting-space experiences.
  76770. */
  76771. resetPose(): void;
  76772. /**
  76773. * The VRLayer provided to the VRDisplay will be captured and presented
  76774. * in the HMD. Calling this function has the same effect on the source
  76775. * canvas as any other operation that uses its source image, and canvases
  76776. * created without preserveDrawingBuffer set to true will be cleared.
  76777. * @param pose Define the pose to submit
  76778. */
  76779. submitFrame(pose?: VRPose): void;
  76780. }
  76781. declare var VRDisplay: {
  76782. prototype: VRDisplay;
  76783. new(): VRDisplay;
  76784. };
  76785. interface VRLayer {
  76786. leftBounds?: number[] | Float32Array | null;
  76787. rightBounds?: number[] | Float32Array | null;
  76788. source?: HTMLCanvasElement | null;
  76789. }
  76790. interface VRDisplayCapabilities {
  76791. readonly canPresent: boolean;
  76792. readonly hasExternalDisplay: boolean;
  76793. readonly hasOrientation: boolean;
  76794. readonly hasPosition: boolean;
  76795. readonly maxLayers: number;
  76796. }
  76797. interface VREyeParameters {
  76798. /** @deprecated */
  76799. readonly fieldOfView: VRFieldOfView;
  76800. readonly offset: Float32Array;
  76801. readonly renderHeight: number;
  76802. readonly renderWidth: number;
  76803. }
  76804. interface VRFieldOfView {
  76805. readonly downDegrees: number;
  76806. readonly leftDegrees: number;
  76807. readonly rightDegrees: number;
  76808. readonly upDegrees: number;
  76809. }
  76810. interface VRFrameData {
  76811. readonly leftProjectionMatrix: Float32Array;
  76812. readonly leftViewMatrix: Float32Array;
  76813. readonly pose: VRPose;
  76814. readonly rightProjectionMatrix: Float32Array;
  76815. readonly rightViewMatrix: Float32Array;
  76816. readonly timestamp: number;
  76817. }
  76818. interface VRPose {
  76819. readonly angularAcceleration: Float32Array | null;
  76820. readonly angularVelocity: Float32Array | null;
  76821. readonly linearAcceleration: Float32Array | null;
  76822. readonly linearVelocity: Float32Array | null;
  76823. readonly orientation: Float32Array | null;
  76824. readonly position: Float32Array | null;
  76825. readonly timestamp: number;
  76826. }
  76827. interface VRStageParameters {
  76828. sittingToStandingTransform?: Float32Array;
  76829. sizeX?: number;
  76830. sizeY?: number;
  76831. }
  76832. interface Navigator {
  76833. getVRDisplays(): Promise<VRDisplay[]>;
  76834. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76835. }
  76836. interface Window {
  76837. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76838. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76839. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76840. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76841. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76842. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76843. }
  76844. interface Gamepad {
  76845. readonly displayId: number;
  76846. }
  76847. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76848. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76849. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76850. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76851. type XRHandedness = "none" | "left" | "right";
  76852. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76853. type XREye = "none" | "left" | "right";
  76854. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76855. interface XRSpace extends EventTarget {}
  76856. interface XRRenderState {
  76857. depthNear?: number;
  76858. depthFar?: number;
  76859. inlineVerticalFieldOfView?: number;
  76860. baseLayer?: XRWebGLLayer;
  76861. }
  76862. interface XRInputSource {
  76863. handedness: XRHandedness;
  76864. targetRayMode: XRTargetRayMode;
  76865. targetRaySpace: XRSpace;
  76866. gripSpace: XRSpace | undefined;
  76867. gamepad: Gamepad | undefined;
  76868. profiles: Array<string>;
  76869. hand: XRHand | undefined;
  76870. }
  76871. interface XRSessionInit {
  76872. optionalFeatures?: string[];
  76873. requiredFeatures?: string[];
  76874. }
  76875. interface XRSession {
  76876. addEventListener: Function;
  76877. removeEventListener: Function;
  76878. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76879. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76880. requestAnimationFrame: Function;
  76881. end(): Promise<void>;
  76882. renderState: XRRenderState;
  76883. inputSources: Array<XRInputSource>;
  76884. // hit test
  76885. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76886. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76887. // legacy AR hit test
  76888. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76889. // legacy plane detection
  76890. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76891. }
  76892. interface XRReferenceSpace extends XRSpace {
  76893. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76894. onreset: any;
  76895. }
  76896. type XRPlaneSet = Set<XRPlane>;
  76897. type XRAnchorSet = Set<XRAnchor>;
  76898. interface XRFrame {
  76899. session: XRSession;
  76900. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76901. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76902. // AR
  76903. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76904. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76905. // Anchors
  76906. trackedAnchors?: XRAnchorSet;
  76907. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76908. // Planes
  76909. worldInformation: {
  76910. detectedPlanes?: XRPlaneSet;
  76911. };
  76912. // Hand tracking
  76913. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76914. }
  76915. interface XRViewerPose extends XRPose {
  76916. views: Array<XRView>;
  76917. }
  76918. interface XRPose {
  76919. transform: XRRigidTransform;
  76920. emulatedPosition: boolean;
  76921. }
  76922. interface XRWebGLLayerOptions {
  76923. antialias?: boolean;
  76924. depth?: boolean;
  76925. stencil?: boolean;
  76926. alpha?: boolean;
  76927. multiview?: boolean;
  76928. framebufferScaleFactor?: number;
  76929. }
  76930. declare var XRWebGLLayer: {
  76931. prototype: XRWebGLLayer;
  76932. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76933. };
  76934. interface XRWebGLLayer {
  76935. framebuffer: WebGLFramebuffer;
  76936. framebufferWidth: number;
  76937. framebufferHeight: number;
  76938. getViewport: Function;
  76939. }
  76940. declare class XRRigidTransform {
  76941. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76942. position: DOMPointReadOnly;
  76943. orientation: DOMPointReadOnly;
  76944. matrix: Float32Array;
  76945. inverse: XRRigidTransform;
  76946. }
  76947. interface XRView {
  76948. eye: XREye;
  76949. projectionMatrix: Float32Array;
  76950. transform: XRRigidTransform;
  76951. }
  76952. interface XRInputSourceChangeEvent {
  76953. session: XRSession;
  76954. removed: Array<XRInputSource>;
  76955. added: Array<XRInputSource>;
  76956. }
  76957. interface XRInputSourceEvent extends Event {
  76958. readonly frame: XRFrame;
  76959. readonly inputSource: XRInputSource;
  76960. }
  76961. // Experimental(er) features
  76962. declare class XRRay {
  76963. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76964. origin: DOMPointReadOnly;
  76965. direction: DOMPointReadOnly;
  76966. matrix: Float32Array;
  76967. }
  76968. declare enum XRHitTestTrackableType {
  76969. "point",
  76970. "plane",
  76971. "mesh",
  76972. }
  76973. interface XRHitResult {
  76974. hitMatrix: Float32Array;
  76975. }
  76976. interface XRTransientInputHitTestResult {
  76977. readonly inputSource: XRInputSource;
  76978. readonly results: Array<XRHitTestResult>;
  76979. }
  76980. interface XRHitTestResult {
  76981. getPose(baseSpace: XRSpace): XRPose | undefined;
  76982. // When anchor system is enabled
  76983. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76984. }
  76985. interface XRHitTestSource {
  76986. cancel(): void;
  76987. }
  76988. interface XRTransientInputHitTestSource {
  76989. cancel(): void;
  76990. }
  76991. interface XRHitTestOptionsInit {
  76992. space: XRSpace;
  76993. entityTypes?: Array<XRHitTestTrackableType>;
  76994. offsetRay?: XRRay;
  76995. }
  76996. interface XRTransientInputHitTestOptionsInit {
  76997. profile: string;
  76998. entityTypes?: Array<XRHitTestTrackableType>;
  76999. offsetRay?: XRRay;
  77000. }
  77001. interface XRAnchor {
  77002. anchorSpace: XRSpace;
  77003. delete(): void;
  77004. }
  77005. interface XRPlane {
  77006. orientation: "Horizontal" | "Vertical";
  77007. planeSpace: XRSpace;
  77008. polygon: Array<DOMPointReadOnly>;
  77009. lastChangedTime: number;
  77010. }
  77011. interface XRJointSpace extends XRSpace {}
  77012. interface XRJointPose extends XRPose {
  77013. radius: number | undefined;
  77014. }
  77015. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  77016. readonly length: number;
  77017. [index: number]: XRJointSpace;
  77018. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  77019. readonly WRIST: number;
  77020. readonly THUMB_METACARPAL: number;
  77021. readonly THUMB_PHALANX_PROXIMAL: number;
  77022. readonly THUMB_PHALANX_DISTAL: number;
  77023. readonly THUMB_PHALANX_TIP: number;
  77024. readonly INDEX_METACARPAL: number;
  77025. readonly INDEX_PHALANX_PROXIMAL: number;
  77026. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77027. readonly INDEX_PHALANX_DISTAL: number;
  77028. readonly INDEX_PHALANX_TIP: number;
  77029. readonly MIDDLE_METACARPAL: number;
  77030. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77031. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77032. readonly MIDDLE_PHALANX_DISTAL: number;
  77033. readonly MIDDLE_PHALANX_TIP: number;
  77034. readonly RING_METACARPAL: number;
  77035. readonly RING_PHALANX_PROXIMAL: number;
  77036. readonly RING_PHALANX_INTERMEDIATE: number;
  77037. readonly RING_PHALANX_DISTAL: number;
  77038. readonly RING_PHALANX_TIP: number;
  77039. readonly LITTLE_METACARPAL: number;
  77040. readonly LITTLE_PHALANX_PROXIMAL: number;
  77041. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77042. readonly LITTLE_PHALANX_DISTAL: number;
  77043. readonly LITTLE_PHALANX_TIP: number;
  77044. }
  77045. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77046. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77047. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77048. interface XRSession {
  77049. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77050. }
  77051. interface XRFrame {
  77052. featurePointCloud? : Array<number>;
  77053. }
  77054. /**
  77055. * @ignore
  77056. */
  77057. declare module BABYLON.GLTF2.Exporter {
  77058. }
  77059. /**
  77060. * @ignore
  77061. */
  77062. declare module BABYLON.GLTF1 {
  77063. }
  77064. declare module BABYLON.GUI {
  77065. /**
  77066. * Class used to specific a value and its associated unit
  77067. */
  77068. export class ValueAndUnit {
  77069. /** defines the unit to store */
  77070. unit: number;
  77071. /** defines a boolean indicating if the value can be negative */
  77072. negativeValueAllowed: boolean;
  77073. private _value;
  77074. private _originalUnit;
  77075. /**
  77076. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77077. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77078. */
  77079. ignoreAdaptiveScaling: boolean;
  77080. /**
  77081. * Creates a new ValueAndUnit
  77082. * @param value defines the value to store
  77083. * @param unit defines the unit to store
  77084. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77085. */
  77086. constructor(value: number,
  77087. /** defines the unit to store */
  77088. unit?: number,
  77089. /** defines a boolean indicating if the value can be negative */
  77090. negativeValueAllowed?: boolean);
  77091. /** Gets a boolean indicating if the value is a percentage */
  77092. get isPercentage(): boolean;
  77093. /** Gets a boolean indicating if the value is store as pixel */
  77094. get isPixel(): boolean;
  77095. /** Gets direct internal value */
  77096. get internalValue(): number;
  77097. /**
  77098. * Gets value as pixel
  77099. * @param host defines the root host
  77100. * @param refValue defines the reference value for percentages
  77101. * @returns the value as pixel
  77102. */
  77103. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77104. /**
  77105. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77106. * @param value defines the value to store
  77107. * @param unit defines the unit to store
  77108. * @returns the current ValueAndUnit
  77109. */
  77110. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77111. /**
  77112. * Gets the value accordingly to its unit
  77113. * @param host defines the root host
  77114. * @returns the value
  77115. */
  77116. getValue(host: AdvancedDynamicTexture): number;
  77117. /**
  77118. * Gets a string representation of the value
  77119. * @param host defines the root host
  77120. * @param decimals defines an optional number of decimals to display
  77121. * @returns a string
  77122. */
  77123. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77124. /**
  77125. * Store a value parsed from a string
  77126. * @param source defines the source string
  77127. * @returns true if the value was successfully parsed
  77128. */
  77129. fromString(source: string | number): boolean;
  77130. private static _Regex;
  77131. private static _UNITMODE_PERCENTAGE;
  77132. private static _UNITMODE_PIXEL;
  77133. /** UNITMODE_PERCENTAGE */
  77134. static get UNITMODE_PERCENTAGE(): number;
  77135. /** UNITMODE_PIXEL */
  77136. static get UNITMODE_PIXEL(): number;
  77137. }
  77138. }
  77139. declare module BABYLON.GUI {
  77140. /**
  77141. * Define a style used by control to automatically setup properties based on a template.
  77142. * Only support font related properties so far
  77143. */
  77144. export class Style implements BABYLON.IDisposable {
  77145. private _fontFamily;
  77146. private _fontStyle;
  77147. private _fontWeight;
  77148. /** @hidden */
  77149. _host: AdvancedDynamicTexture;
  77150. /** @hidden */
  77151. _fontSize: ValueAndUnit;
  77152. /**
  77153. * BABYLON.Observable raised when the style values are changed
  77154. */
  77155. onChangedObservable: BABYLON.Observable<Style>;
  77156. /**
  77157. * Creates a new style object
  77158. * @param host defines the AdvancedDynamicTexture which hosts this style
  77159. */
  77160. constructor(host: AdvancedDynamicTexture);
  77161. /**
  77162. * Gets or sets the font size
  77163. */
  77164. get fontSize(): string | number;
  77165. set fontSize(value: string | number);
  77166. /**
  77167. * Gets or sets the font family
  77168. */
  77169. get fontFamily(): string;
  77170. set fontFamily(value: string);
  77171. /**
  77172. * Gets or sets the font style
  77173. */
  77174. get fontStyle(): string;
  77175. set fontStyle(value: string);
  77176. /** Gets or sets font weight */
  77177. get fontWeight(): string;
  77178. set fontWeight(value: string);
  77179. /** Dispose all associated resources */
  77180. dispose(): void;
  77181. }
  77182. }
  77183. declare module BABYLON.GUI {
  77184. /**
  77185. * Class used to transport BABYLON.Vector2 information for pointer events
  77186. */
  77187. export class Vector2WithInfo extends BABYLON.Vector2 {
  77188. /** defines the current mouse button index */
  77189. buttonIndex: number;
  77190. /**
  77191. * Creates a new Vector2WithInfo
  77192. * @param source defines the vector2 data to transport
  77193. * @param buttonIndex defines the current mouse button index
  77194. */
  77195. constructor(source: BABYLON.Vector2,
  77196. /** defines the current mouse button index */
  77197. buttonIndex?: number);
  77198. }
  77199. /** Class used to provide 2D matrix features */
  77200. export class Matrix2D {
  77201. /** Gets the internal array of 6 floats used to store matrix data */
  77202. m: Float32Array;
  77203. /**
  77204. * Creates a new matrix
  77205. * @param m00 defines value for (0, 0)
  77206. * @param m01 defines value for (0, 1)
  77207. * @param m10 defines value for (1, 0)
  77208. * @param m11 defines value for (1, 1)
  77209. * @param m20 defines value for (2, 0)
  77210. * @param m21 defines value for (2, 1)
  77211. */
  77212. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77213. /**
  77214. * Fills the matrix from direct values
  77215. * @param m00 defines value for (0, 0)
  77216. * @param m01 defines value for (0, 1)
  77217. * @param m10 defines value for (1, 0)
  77218. * @param m11 defines value for (1, 1)
  77219. * @param m20 defines value for (2, 0)
  77220. * @param m21 defines value for (2, 1)
  77221. * @returns the current modified matrix
  77222. */
  77223. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77224. /**
  77225. * Gets matrix determinant
  77226. * @returns the determinant
  77227. */
  77228. determinant(): number;
  77229. /**
  77230. * Inverses the matrix and stores it in a target matrix
  77231. * @param result defines the target matrix
  77232. * @returns the current matrix
  77233. */
  77234. invertToRef(result: Matrix2D): Matrix2D;
  77235. /**
  77236. * Multiplies the current matrix with another one
  77237. * @param other defines the second operand
  77238. * @param result defines the target matrix
  77239. * @returns the current matrix
  77240. */
  77241. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77242. /**
  77243. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77244. * @param x defines the x coordinate to transform
  77245. * @param y defines the x coordinate to transform
  77246. * @param result defines the target vector2
  77247. * @returns the current matrix
  77248. */
  77249. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77250. /**
  77251. * Creates an identity matrix
  77252. * @returns a new matrix
  77253. */
  77254. static Identity(): Matrix2D;
  77255. /**
  77256. * Creates a translation matrix and stores it in a target matrix
  77257. * @param x defines the x coordinate of the translation
  77258. * @param y defines the y coordinate of the translation
  77259. * @param result defines the target matrix
  77260. */
  77261. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77262. /**
  77263. * Creates a scaling matrix and stores it in a target matrix
  77264. * @param x defines the x coordinate of the scaling
  77265. * @param y defines the y coordinate of the scaling
  77266. * @param result defines the target matrix
  77267. */
  77268. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77269. /**
  77270. * Creates a rotation matrix and stores it in a target matrix
  77271. * @param angle defines the rotation angle
  77272. * @param result defines the target matrix
  77273. */
  77274. static RotationToRef(angle: number, result: Matrix2D): void;
  77275. private static _TempPreTranslationMatrix;
  77276. private static _TempPostTranslationMatrix;
  77277. private static _TempRotationMatrix;
  77278. private static _TempScalingMatrix;
  77279. private static _TempCompose0;
  77280. private static _TempCompose1;
  77281. private static _TempCompose2;
  77282. /**
  77283. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77284. * @param tx defines the x coordinate of the translation
  77285. * @param ty defines the y coordinate of the translation
  77286. * @param angle defines the rotation angle
  77287. * @param scaleX defines the x coordinate of the scaling
  77288. * @param scaleY defines the y coordinate of the scaling
  77289. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77290. * @param result defines the target matrix
  77291. */
  77292. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77293. }
  77294. }
  77295. declare module BABYLON.GUI {
  77296. /**
  77297. * Class used to store 2D control sizes
  77298. */
  77299. export class Measure {
  77300. /** defines left coordinate */
  77301. left: number;
  77302. /** defines top coordinate */
  77303. top: number;
  77304. /** defines width dimension */
  77305. width: number;
  77306. /** defines height dimension */
  77307. height: number;
  77308. /**
  77309. * Creates a new measure
  77310. * @param left defines left coordinate
  77311. * @param top defines top coordinate
  77312. * @param width defines width dimension
  77313. * @param height defines height dimension
  77314. */
  77315. constructor(
  77316. /** defines left coordinate */
  77317. left: number,
  77318. /** defines top coordinate */
  77319. top: number,
  77320. /** defines width dimension */
  77321. width: number,
  77322. /** defines height dimension */
  77323. height: number);
  77324. /**
  77325. * Copy from another measure
  77326. * @param other defines the other measure to copy from
  77327. */
  77328. copyFrom(other: Measure): void;
  77329. /**
  77330. * Copy from a group of 4 floats
  77331. * @param left defines left coordinate
  77332. * @param top defines top coordinate
  77333. * @param width defines width dimension
  77334. * @param height defines height dimension
  77335. */
  77336. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77337. /**
  77338. * Computes the axis aligned bounding box measure for two given measures
  77339. * @param a Input measure
  77340. * @param b Input measure
  77341. * @param result the resulting bounding measure
  77342. */
  77343. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77344. /**
  77345. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77346. * @param transform the matrix to transform the measure before computing the AABB
  77347. * @param addX number to add to left
  77348. * @param addY number to add to top
  77349. * @param addWidth number to add to width
  77350. * @param addHeight number to add to height
  77351. * @param result the resulting AABB
  77352. */
  77353. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77354. /**
  77355. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77356. * @param transform the matrix to transform the measure before computing the AABB
  77357. * @param result the resulting AABB
  77358. */
  77359. transformToRef(transform: Matrix2D, result: Measure): void;
  77360. /**
  77361. * Check equality between this measure and another one
  77362. * @param other defines the other measures
  77363. * @returns true if both measures are equals
  77364. */
  77365. isEqualsTo(other: Measure): boolean;
  77366. /**
  77367. * Creates an empty measure
  77368. * @returns a new measure
  77369. */
  77370. static Empty(): Measure;
  77371. }
  77372. }
  77373. declare module BABYLON.GUI {
  77374. /**
  77375. * Interface used to define a control that can receive focus
  77376. */
  77377. export interface IFocusableControl {
  77378. /**
  77379. * Function called when the control receives the focus
  77380. */
  77381. onFocus(): void;
  77382. /**
  77383. * Function called when the control loses the focus
  77384. */
  77385. onBlur(): void;
  77386. /**
  77387. * Function called to let the control handle keyboard events
  77388. * @param evt defines the current keyboard event
  77389. */
  77390. processKeyboard(evt: KeyboardEvent): void;
  77391. /**
  77392. * Function called to get the list of controls that should not steal the focus from this control
  77393. * @returns an array of controls
  77394. */
  77395. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77396. }
  77397. /**
  77398. * Class used to create texture to support 2D GUI elements
  77399. * @see https://doc.babylonjs.com/how_to/gui
  77400. */
  77401. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77402. private _isDirty;
  77403. private _renderObserver;
  77404. private _resizeObserver;
  77405. private _preKeyboardObserver;
  77406. private _pointerMoveObserver;
  77407. private _pointerObserver;
  77408. private _canvasPointerOutObserver;
  77409. private _canvasBlurObserver;
  77410. private _background;
  77411. /** @hidden */
  77412. _rootContainer: Container;
  77413. /** @hidden */
  77414. _lastPickedControl: Control;
  77415. /** @hidden */
  77416. _lastControlOver: {
  77417. [pointerId: number]: Control;
  77418. };
  77419. /** @hidden */
  77420. _lastControlDown: {
  77421. [pointerId: number]: Control;
  77422. };
  77423. /** @hidden */
  77424. _capturingControl: {
  77425. [pointerId: number]: Control;
  77426. };
  77427. /** @hidden */
  77428. _shouldBlockPointer: boolean;
  77429. /** @hidden */
  77430. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77431. /** @hidden */
  77432. _linkedControls: Control[];
  77433. private _isFullscreen;
  77434. private _fullscreenViewport;
  77435. private _idealWidth;
  77436. private _idealHeight;
  77437. private _useSmallestIdeal;
  77438. private _renderAtIdealSize;
  77439. private _focusedControl;
  77440. private _blockNextFocusCheck;
  77441. private _renderScale;
  77442. private _rootElement;
  77443. private _cursorChanged;
  77444. private _defaultMousePointerId;
  77445. /** @hidden */
  77446. _numLayoutCalls: number;
  77447. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77448. get numLayoutCalls(): number;
  77449. /** @hidden */
  77450. _numRenderCalls: number;
  77451. /** Gets the number of render calls made the last time the ADT has been rendered */
  77452. get numRenderCalls(): number;
  77453. /**
  77454. * Define type to string to ensure compatibility across browsers
  77455. * Safari doesn't support DataTransfer constructor
  77456. */
  77457. private _clipboardData;
  77458. /**
  77459. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77460. */
  77461. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77462. /**
  77463. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77464. */
  77465. onControlPickedObservable: BABYLON.Observable<Control>;
  77466. /**
  77467. * BABYLON.Observable event triggered before layout is evaluated
  77468. */
  77469. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77470. /**
  77471. * BABYLON.Observable event triggered after the layout was evaluated
  77472. */
  77473. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77474. /**
  77475. * BABYLON.Observable event triggered before the texture is rendered
  77476. */
  77477. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77478. /**
  77479. * BABYLON.Observable event triggered after the texture was rendered
  77480. */
  77481. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77482. /**
  77483. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77484. */
  77485. premulAlpha: boolean;
  77486. /**
  77487. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77488. * Useful when you want more antialiasing
  77489. */
  77490. get renderScale(): number;
  77491. set renderScale(value: number);
  77492. /** Gets or sets the background color */
  77493. get background(): string;
  77494. set background(value: string);
  77495. /**
  77496. * Gets or sets the ideal width used to design controls.
  77497. * The GUI will then rescale everything accordingly
  77498. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77499. */
  77500. get idealWidth(): number;
  77501. set idealWidth(value: number);
  77502. /**
  77503. * Gets or sets the ideal height used to design controls.
  77504. * The GUI will then rescale everything accordingly
  77505. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77506. */
  77507. get idealHeight(): number;
  77508. set idealHeight(value: number);
  77509. /**
  77510. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77511. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77512. */
  77513. get useSmallestIdeal(): boolean;
  77514. set useSmallestIdeal(value: boolean);
  77515. /**
  77516. * Gets or sets a boolean indicating if adaptive scaling must be used
  77517. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77518. */
  77519. get renderAtIdealSize(): boolean;
  77520. set renderAtIdealSize(value: boolean);
  77521. /**
  77522. * Gets the ratio used when in "ideal mode"
  77523. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77524. * */
  77525. get idealRatio(): number;
  77526. /**
  77527. * Gets the underlying layer used to render the texture when in fullscreen mode
  77528. */
  77529. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77530. /**
  77531. * Gets the root container control
  77532. */
  77533. get rootContainer(): Container;
  77534. /**
  77535. * Returns an array containing the root container.
  77536. * This is mostly used to let the Inspector introspects the ADT
  77537. * @returns an array containing the rootContainer
  77538. */
  77539. getChildren(): Array<Container>;
  77540. /**
  77541. * Will return all controls that are inside this texture
  77542. * @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
  77543. * @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
  77544. * @return all child controls
  77545. */
  77546. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77547. /**
  77548. * Gets or sets the current focused control
  77549. */
  77550. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77551. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77552. /**
  77553. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77554. */
  77555. get isForeground(): boolean;
  77556. set isForeground(value: boolean);
  77557. /**
  77558. * Gets or set information about clipboardData
  77559. */
  77560. get clipboardData(): string;
  77561. set clipboardData(value: string);
  77562. /**
  77563. * Creates a new AdvancedDynamicTexture
  77564. * @param name defines the name of the texture
  77565. * @param width defines the width of the texture
  77566. * @param height defines the height of the texture
  77567. * @param scene defines the hosting scene
  77568. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77569. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77570. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77571. */
  77572. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77573. /**
  77574. * Get the current class name of the texture useful for serialization or dynamic coding.
  77575. * @returns "AdvancedDynamicTexture"
  77576. */
  77577. getClassName(): string;
  77578. /**
  77579. * Function used to execute a function on all controls
  77580. * @param func defines the function to execute
  77581. * @param container defines the container where controls belong. If null the root container will be used
  77582. */
  77583. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77584. private _useInvalidateRectOptimization;
  77585. /**
  77586. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77587. */
  77588. get useInvalidateRectOptimization(): boolean;
  77589. set useInvalidateRectOptimization(value: boolean);
  77590. private _invalidatedRectangle;
  77591. /**
  77592. * Invalidates a rectangle area on the gui texture
  77593. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77594. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77595. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77596. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77597. */
  77598. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77599. /**
  77600. * Marks the texture as dirty forcing a complete update
  77601. */
  77602. markAsDirty(): void;
  77603. /**
  77604. * Helper function used to create a new style
  77605. * @returns a new style
  77606. * @see https://doc.babylonjs.com/how_to/gui#styles
  77607. */
  77608. createStyle(): Style;
  77609. /**
  77610. * Adds a new control to the root container
  77611. * @param control defines the control to add
  77612. * @returns the current texture
  77613. */
  77614. addControl(control: Control): AdvancedDynamicTexture;
  77615. /**
  77616. * Removes a control from the root container
  77617. * @param control defines the control to remove
  77618. * @returns the current texture
  77619. */
  77620. removeControl(control: Control): AdvancedDynamicTexture;
  77621. /**
  77622. * Release all resources
  77623. */
  77624. dispose(): void;
  77625. private _onResize;
  77626. /** @hidden */
  77627. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77628. /**
  77629. * Get screen coordinates for a vector3
  77630. * @param position defines the position to project
  77631. * @param worldMatrix defines the world matrix to use
  77632. * @returns the projected position
  77633. */
  77634. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77635. private _checkUpdate;
  77636. private _clearMeasure;
  77637. private _render;
  77638. /** @hidden */
  77639. _changeCursor(cursor: string): void;
  77640. /** @hidden */
  77641. _registerLastControlDown(control: Control, pointerId: number): void;
  77642. private _doPicking;
  77643. /** @hidden */
  77644. _cleanControlAfterRemovalFromList(list: {
  77645. [pointerId: number]: Control;
  77646. }, control: Control): void;
  77647. /** @hidden */
  77648. _cleanControlAfterRemoval(control: Control): void;
  77649. /** Attach to all scene events required to support pointer events */
  77650. attach(): void;
  77651. /** @hidden */
  77652. private onClipboardCopy;
  77653. /** @hidden */
  77654. private onClipboardCut;
  77655. /** @hidden */
  77656. private onClipboardPaste;
  77657. /**
  77658. * Register the clipboard Events onto the canvas
  77659. */
  77660. registerClipboardEvents(): void;
  77661. /**
  77662. * Unregister the clipboard Events from the canvas
  77663. */
  77664. unRegisterClipboardEvents(): void;
  77665. /**
  77666. * Connect the texture to a hosting mesh to enable interactions
  77667. * @param mesh defines the mesh to attach to
  77668. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77669. */
  77670. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77671. /**
  77672. * Move the focus to a specific control
  77673. * @param control defines the control which will receive the focus
  77674. */
  77675. moveFocusToControl(control: IFocusableControl): void;
  77676. private _manageFocus;
  77677. private _attachToOnPointerOut;
  77678. private _attachToOnBlur;
  77679. /**
  77680. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77681. * @param mesh defines the mesh which will receive the texture
  77682. * @param width defines the texture width (1024 by default)
  77683. * @param height defines the texture height (1024 by default)
  77684. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77685. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77686. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77687. * @returns a new AdvancedDynamicTexture
  77688. */
  77689. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77690. /**
  77691. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77692. * In this mode the texture will rely on a layer for its rendering.
  77693. * This allows it to be treated like any other layer.
  77694. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77695. * LayerMask is set through advancedTexture.layer.layerMask
  77696. * @param name defines name for the texture
  77697. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77698. * @param scene defines the hsoting scene
  77699. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77700. * @returns a new AdvancedDynamicTexture
  77701. */
  77702. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77703. }
  77704. }
  77705. declare module BABYLON.GUI {
  77706. /**
  77707. * Root class used for all 2D controls
  77708. * @see https://doc.babylonjs.com/how_to/gui#controls
  77709. */
  77710. export class Control {
  77711. /** defines the name of the control */
  77712. name?: string | undefined;
  77713. /**
  77714. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77715. */
  77716. static AllowAlphaInheritance: boolean;
  77717. private _alpha;
  77718. private _alphaSet;
  77719. private _zIndex;
  77720. /** @hidden */
  77721. _host: AdvancedDynamicTexture;
  77722. /** Gets or sets the control parent */
  77723. parent: BABYLON.Nullable<Container>;
  77724. /** @hidden */
  77725. _currentMeasure: Measure;
  77726. private _fontFamily;
  77727. private _fontStyle;
  77728. private _fontWeight;
  77729. private _fontSize;
  77730. private _font;
  77731. /** @hidden */
  77732. _width: ValueAndUnit;
  77733. /** @hidden */
  77734. _height: ValueAndUnit;
  77735. /** @hidden */
  77736. protected _fontOffset: {
  77737. ascent: number;
  77738. height: number;
  77739. descent: number;
  77740. };
  77741. private _color;
  77742. private _style;
  77743. private _styleObserver;
  77744. /** @hidden */
  77745. protected _horizontalAlignment: number;
  77746. /** @hidden */
  77747. protected _verticalAlignment: number;
  77748. /** @hidden */
  77749. protected _isDirty: boolean;
  77750. /** @hidden */
  77751. protected _wasDirty: boolean;
  77752. /** @hidden */
  77753. _tempParentMeasure: Measure;
  77754. /** @hidden */
  77755. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77756. /** @hidden */
  77757. protected _cachedParentMeasure: Measure;
  77758. private _paddingLeft;
  77759. private _paddingRight;
  77760. private _paddingTop;
  77761. private _paddingBottom;
  77762. /** @hidden */
  77763. _left: ValueAndUnit;
  77764. /** @hidden */
  77765. _top: ValueAndUnit;
  77766. private _scaleX;
  77767. private _scaleY;
  77768. private _rotation;
  77769. private _transformCenterX;
  77770. private _transformCenterY;
  77771. /** @hidden */
  77772. _transformMatrix: Matrix2D;
  77773. /** @hidden */
  77774. protected _invertTransformMatrix: Matrix2D;
  77775. /** @hidden */
  77776. protected _transformedPosition: BABYLON.Vector2;
  77777. private _isMatrixDirty;
  77778. private _cachedOffsetX;
  77779. private _cachedOffsetY;
  77780. private _isVisible;
  77781. private _isHighlighted;
  77782. /** @hidden */
  77783. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77784. private _fontSet;
  77785. private _dummyVector2;
  77786. private _downCount;
  77787. private _enterCount;
  77788. private _doNotRender;
  77789. private _downPointerIds;
  77790. protected _isEnabled: boolean;
  77791. protected _disabledColor: string;
  77792. protected _disabledColorItem: string;
  77793. /** @hidden */
  77794. protected _rebuildLayout: boolean;
  77795. /** @hidden */
  77796. _customData: any;
  77797. /** @hidden */
  77798. _isClipped: boolean;
  77799. /** @hidden */
  77800. _automaticSize: boolean;
  77801. /** @hidden */
  77802. _tag: any;
  77803. /**
  77804. * 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
  77805. */
  77806. uniqueId: number;
  77807. /**
  77808. * Gets or sets an object used to store user defined information for the node
  77809. */
  77810. metadata: any;
  77811. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77812. isHitTestVisible: boolean;
  77813. /** Gets or sets a boolean indicating if the control can block pointer events */
  77814. isPointerBlocker: boolean;
  77815. /** Gets or sets a boolean indicating if the control can be focusable */
  77816. isFocusInvisible: boolean;
  77817. /**
  77818. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77819. * 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
  77820. */
  77821. clipChildren: boolean;
  77822. /**
  77823. * Gets or sets a boolean indicating that control content must be clipped
  77824. * 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
  77825. */
  77826. clipContent: boolean;
  77827. /**
  77828. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77829. */
  77830. useBitmapCache: boolean;
  77831. private _cacheData;
  77832. private _shadowOffsetX;
  77833. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77834. get shadowOffsetX(): number;
  77835. set shadowOffsetX(value: number);
  77836. private _shadowOffsetY;
  77837. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77838. get shadowOffsetY(): number;
  77839. set shadowOffsetY(value: number);
  77840. private _shadowBlur;
  77841. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77842. get shadowBlur(): number;
  77843. set shadowBlur(value: number);
  77844. private _shadowColor;
  77845. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77846. get shadowColor(): string;
  77847. set shadowColor(value: string);
  77848. /** Gets or sets the cursor to use when the control is hovered */
  77849. hoverCursor: string;
  77850. /** @hidden */
  77851. protected _linkOffsetX: ValueAndUnit;
  77852. /** @hidden */
  77853. protected _linkOffsetY: ValueAndUnit;
  77854. /** Gets the control type name */
  77855. get typeName(): string;
  77856. /**
  77857. * Get the current class name of the control.
  77858. * @returns current class name
  77859. */
  77860. getClassName(): string;
  77861. /**
  77862. * An event triggered when pointer wheel is scrolled
  77863. */
  77864. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77865. /**
  77866. * An event triggered when the pointer move over the control.
  77867. */
  77868. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77869. /**
  77870. * An event triggered when the pointer move out of the control.
  77871. */
  77872. onPointerOutObservable: BABYLON.Observable<Control>;
  77873. /**
  77874. * An event triggered when the pointer taps the control
  77875. */
  77876. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77877. /**
  77878. * An event triggered when pointer up
  77879. */
  77880. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77881. /**
  77882. * An event triggered when a control is clicked on
  77883. */
  77884. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77885. /**
  77886. * An event triggered when pointer enters the control
  77887. */
  77888. onPointerEnterObservable: BABYLON.Observable<Control>;
  77889. /**
  77890. * An event triggered when the control is marked as dirty
  77891. */
  77892. onDirtyObservable: BABYLON.Observable<Control>;
  77893. /**
  77894. * An event triggered before drawing the control
  77895. */
  77896. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77897. /**
  77898. * An event triggered after the control was drawn
  77899. */
  77900. onAfterDrawObservable: BABYLON.Observable<Control>;
  77901. /**
  77902. * An event triggered when the control has been disposed
  77903. */
  77904. onDisposeObservable: BABYLON.Observable<Control>;
  77905. /**
  77906. * Get the hosting AdvancedDynamicTexture
  77907. */
  77908. get host(): AdvancedDynamicTexture;
  77909. /** Gets or set information about font offsets (used to render and align text) */
  77910. get fontOffset(): {
  77911. ascent: number;
  77912. height: number;
  77913. descent: number;
  77914. };
  77915. set fontOffset(offset: {
  77916. ascent: number;
  77917. height: number;
  77918. descent: number;
  77919. });
  77920. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77921. get alpha(): number;
  77922. set alpha(value: number);
  77923. /**
  77924. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77925. */
  77926. get isHighlighted(): boolean;
  77927. set isHighlighted(value: boolean);
  77928. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77929. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77930. */
  77931. get scaleX(): number;
  77932. set scaleX(value: number);
  77933. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77934. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77935. */
  77936. get scaleY(): number;
  77937. set scaleY(value: number);
  77938. /** Gets or sets the rotation angle (0 by default)
  77939. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77940. */
  77941. get rotation(): number;
  77942. set rotation(value: number);
  77943. /** Gets or sets the transformation center on Y axis (0 by default)
  77944. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77945. */
  77946. get transformCenterY(): number;
  77947. set transformCenterY(value: number);
  77948. /** Gets or sets the transformation center on X axis (0 by default)
  77949. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77950. */
  77951. get transformCenterX(): number;
  77952. set transformCenterX(value: number);
  77953. /**
  77954. * Gets or sets the horizontal alignment
  77955. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77956. */
  77957. get horizontalAlignment(): number;
  77958. set horizontalAlignment(value: number);
  77959. /**
  77960. * Gets or sets the vertical alignment
  77961. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77962. */
  77963. get verticalAlignment(): number;
  77964. set verticalAlignment(value: number);
  77965. /**
  77966. * Gets or sets a fixed ratio for this control.
  77967. * When different from 0, the ratio is used to compute the "second" dimension.
  77968. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77969. * second dimension is computed as first dimension * fixedRatio
  77970. */
  77971. fixedRatio: number;
  77972. private _fixedRatioMasterIsWidth;
  77973. /**
  77974. * Gets or sets control width
  77975. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77976. */
  77977. get width(): string | number;
  77978. set width(value: string | number);
  77979. /**
  77980. * Gets or sets the control width in pixel
  77981. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77982. */
  77983. get widthInPixels(): number;
  77984. set widthInPixels(value: number);
  77985. /**
  77986. * Gets or sets control height
  77987. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77988. */
  77989. get height(): string | number;
  77990. set height(value: string | number);
  77991. /**
  77992. * Gets or sets control height in pixel
  77993. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77994. */
  77995. get heightInPixels(): number;
  77996. set heightInPixels(value: number);
  77997. /** Gets or set font family */
  77998. get fontFamily(): string;
  77999. set fontFamily(value: string);
  78000. /** Gets or sets font style */
  78001. get fontStyle(): string;
  78002. set fontStyle(value: string);
  78003. /** Gets or sets font weight */
  78004. get fontWeight(): string;
  78005. set fontWeight(value: string);
  78006. /**
  78007. * Gets or sets style
  78008. * @see https://doc.babylonjs.com/how_to/gui#styles
  78009. */
  78010. get style(): BABYLON.Nullable<Style>;
  78011. set style(value: BABYLON.Nullable<Style>);
  78012. /** @hidden */
  78013. get _isFontSizeInPercentage(): boolean;
  78014. /** Gets or sets font size in pixels */
  78015. get fontSizeInPixels(): number;
  78016. set fontSizeInPixels(value: number);
  78017. /** Gets or sets font size */
  78018. get fontSize(): string | number;
  78019. set fontSize(value: string | number);
  78020. /** Gets or sets foreground color */
  78021. get color(): string;
  78022. set color(value: string);
  78023. /** Gets or sets z index which is used to reorder controls on the z axis */
  78024. get zIndex(): number;
  78025. set zIndex(value: number);
  78026. /** Gets or sets a boolean indicating if the control can be rendered */
  78027. get notRenderable(): boolean;
  78028. set notRenderable(value: boolean);
  78029. /** Gets or sets a boolean indicating if the control is visible */
  78030. get isVisible(): boolean;
  78031. set isVisible(value: boolean);
  78032. /** Gets a boolean indicating that the control needs to update its rendering */
  78033. get isDirty(): boolean;
  78034. /**
  78035. * Gets the current linked mesh (or null if none)
  78036. */
  78037. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78038. /**
  78039. * Gets or sets a value indicating the padding to use on the left of the control
  78040. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78041. */
  78042. get paddingLeft(): string | number;
  78043. set paddingLeft(value: string | number);
  78044. /**
  78045. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78046. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78047. */
  78048. get paddingLeftInPixels(): number;
  78049. set paddingLeftInPixels(value: number);
  78050. /**
  78051. * Gets or sets a value indicating the padding to use on the right of the control
  78052. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78053. */
  78054. get paddingRight(): string | number;
  78055. set paddingRight(value: string | number);
  78056. /**
  78057. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78058. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78059. */
  78060. get paddingRightInPixels(): number;
  78061. set paddingRightInPixels(value: number);
  78062. /**
  78063. * Gets or sets a value indicating the padding to use on the top of the control
  78064. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78065. */
  78066. get paddingTop(): string | number;
  78067. set paddingTop(value: string | number);
  78068. /**
  78069. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78070. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78071. */
  78072. get paddingTopInPixels(): number;
  78073. set paddingTopInPixels(value: number);
  78074. /**
  78075. * Gets or sets a value indicating the padding to use on the bottom of the control
  78076. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78077. */
  78078. get paddingBottom(): string | number;
  78079. set paddingBottom(value: string | number);
  78080. /**
  78081. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78082. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78083. */
  78084. get paddingBottomInPixels(): number;
  78085. set paddingBottomInPixels(value: number);
  78086. /**
  78087. * Gets or sets a value indicating the left coordinate of the control
  78088. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78089. */
  78090. get left(): string | number;
  78091. set left(value: string | number);
  78092. /**
  78093. * Gets or sets a value indicating the left coordinate in pixels of the control
  78094. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78095. */
  78096. get leftInPixels(): number;
  78097. set leftInPixels(value: number);
  78098. /**
  78099. * Gets or sets a value indicating the top coordinate of the control
  78100. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78101. */
  78102. get top(): string | number;
  78103. set top(value: string | number);
  78104. /**
  78105. * Gets or sets a value indicating the top coordinate in pixels of the control
  78106. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78107. */
  78108. get topInPixels(): number;
  78109. set topInPixels(value: number);
  78110. /**
  78111. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78112. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78113. */
  78114. get linkOffsetX(): string | number;
  78115. set linkOffsetX(value: string | number);
  78116. /**
  78117. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78118. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78119. */
  78120. get linkOffsetXInPixels(): number;
  78121. set linkOffsetXInPixels(value: number);
  78122. /**
  78123. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78124. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78125. */
  78126. get linkOffsetY(): string | number;
  78127. set linkOffsetY(value: string | number);
  78128. /**
  78129. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78130. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78131. */
  78132. get linkOffsetYInPixels(): number;
  78133. set linkOffsetYInPixels(value: number);
  78134. /** Gets the center coordinate on X axis */
  78135. get centerX(): number;
  78136. /** Gets the center coordinate on Y axis */
  78137. get centerY(): number;
  78138. /** Gets or sets if control is Enabled*/
  78139. get isEnabled(): boolean;
  78140. set isEnabled(value: boolean);
  78141. /** Gets or sets background color of control if it's disabled*/
  78142. get disabledColor(): string;
  78143. set disabledColor(value: string);
  78144. /** Gets or sets front color of control if it's disabled*/
  78145. get disabledColorItem(): string;
  78146. set disabledColorItem(value: string);
  78147. /**
  78148. * Creates a new control
  78149. * @param name defines the name of the control
  78150. */
  78151. constructor(
  78152. /** defines the name of the control */
  78153. name?: string | undefined);
  78154. /** @hidden */
  78155. protected _getTypeName(): string;
  78156. /**
  78157. * Gets the first ascendant in the hierarchy of the given type
  78158. * @param className defines the required type
  78159. * @returns the ascendant or null if not found
  78160. */
  78161. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78162. /** @hidden */
  78163. _resetFontCache(): void;
  78164. /**
  78165. * Determines if a container is an ascendant of the current control
  78166. * @param container defines the container to look for
  78167. * @returns true if the container is one of the ascendant of the control
  78168. */
  78169. isAscendant(container: Control): boolean;
  78170. /**
  78171. * Gets coordinates in local control space
  78172. * @param globalCoordinates defines the coordinates to transform
  78173. * @returns the new coordinates in local space
  78174. */
  78175. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78176. /**
  78177. * Gets coordinates in local control space
  78178. * @param globalCoordinates defines the coordinates to transform
  78179. * @param result defines the target vector2 where to store the result
  78180. * @returns the current control
  78181. */
  78182. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78183. /**
  78184. * Gets coordinates in parent local control space
  78185. * @param globalCoordinates defines the coordinates to transform
  78186. * @returns the new coordinates in parent local space
  78187. */
  78188. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78189. /**
  78190. * Move the current control to a vector3 position projected onto the screen.
  78191. * @param position defines the target position
  78192. * @param scene defines the hosting scene
  78193. */
  78194. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78195. /**
  78196. * Will store all controls that have this control as ascendant in a given array
  78197. * @param results defines the array where to store the descendants
  78198. * @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
  78199. * @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
  78200. */
  78201. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78202. /**
  78203. * Will return all controls that have this control as ascendant
  78204. * @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
  78205. * @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
  78206. * @return all child controls
  78207. */
  78208. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78209. /**
  78210. * Link current control with a target mesh
  78211. * @param mesh defines the mesh to link with
  78212. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78213. */
  78214. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  78215. /** @hidden */
  78216. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78217. /** @hidden */
  78218. _offsetLeft(offset: number): void;
  78219. /** @hidden */
  78220. _offsetTop(offset: number): void;
  78221. /** @hidden */
  78222. _markMatrixAsDirty(): void;
  78223. /** @hidden */
  78224. _flagDescendantsAsMatrixDirty(): void;
  78225. /** @hidden */
  78226. _intersectsRect(rect: Measure): boolean;
  78227. /** @hidden */
  78228. protected invalidateRect(): void;
  78229. /** @hidden */
  78230. _markAsDirty(force?: boolean): void;
  78231. /** @hidden */
  78232. _markAllAsDirty(): void;
  78233. /** @hidden */
  78234. _link(host: AdvancedDynamicTexture): void;
  78235. /** @hidden */
  78236. protected _transform(context?: CanvasRenderingContext2D): void;
  78237. /** @hidden */
  78238. _renderHighlight(context: CanvasRenderingContext2D): void;
  78239. /** @hidden */
  78240. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78241. /** @hidden */
  78242. protected _applyStates(context: CanvasRenderingContext2D): void;
  78243. /** @hidden */
  78244. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78245. /** @hidden */
  78246. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78247. protected _evaluateClippingState(parentMeasure: Measure): void;
  78248. /** @hidden */
  78249. _measure(): void;
  78250. /** @hidden */
  78251. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78252. /** @hidden */
  78253. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78254. /** @hidden */
  78255. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78256. /** @hidden */
  78257. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78258. private static _ClipMeasure;
  78259. private _tmpMeasureA;
  78260. private _clip;
  78261. /** @hidden */
  78262. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78263. /** @hidden */
  78264. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78265. /**
  78266. * Tests if a given coordinates belong to the current control
  78267. * @param x defines x coordinate to test
  78268. * @param y defines y coordinate to test
  78269. * @returns true if the coordinates are inside the control
  78270. */
  78271. contains(x: number, y: number): boolean;
  78272. /** @hidden */
  78273. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78274. /** @hidden */
  78275. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78276. /** @hidden */
  78277. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78278. /** @hidden */
  78279. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78280. /** @hidden */
  78281. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78282. /** @hidden */
  78283. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78284. /** @hidden */
  78285. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78286. /** @hidden */
  78287. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78288. /** @hidden */
  78289. _onCanvasBlur(): void;
  78290. /** @hidden */
  78291. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78292. private _prepareFont;
  78293. /** Releases associated resources */
  78294. dispose(): void;
  78295. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78296. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78297. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78298. private static _VERTICAL_ALIGNMENT_TOP;
  78299. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78300. private static _VERTICAL_ALIGNMENT_CENTER;
  78301. /** HORIZONTAL_ALIGNMENT_LEFT */
  78302. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78303. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78304. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78305. /** HORIZONTAL_ALIGNMENT_CENTER */
  78306. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78307. /** VERTICAL_ALIGNMENT_TOP */
  78308. static get VERTICAL_ALIGNMENT_TOP(): number;
  78309. /** VERTICAL_ALIGNMENT_BOTTOM */
  78310. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78311. /** VERTICAL_ALIGNMENT_CENTER */
  78312. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78313. private static _FontHeightSizes;
  78314. /** @hidden */
  78315. static _GetFontOffset(font: string): {
  78316. ascent: number;
  78317. height: number;
  78318. descent: number;
  78319. };
  78320. /**
  78321. * Creates a stack panel that can be used to render headers
  78322. * @param control defines the control to associate with the header
  78323. * @param text defines the text of the header
  78324. * @param size defines the size of the header
  78325. * @param options defines options used to configure the header
  78326. * @returns a new StackPanel
  78327. * @ignore
  78328. * @hidden
  78329. */
  78330. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78331. isHorizontal: boolean;
  78332. controlFirst: boolean;
  78333. }) => any;
  78334. /** @hidden */
  78335. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78336. }
  78337. }
  78338. declare module BABYLON.GUI {
  78339. /**
  78340. * Root class for 2D containers
  78341. * @see https://doc.babylonjs.com/how_to/gui#containers
  78342. */
  78343. export class Container extends Control {
  78344. name?: string | undefined;
  78345. /** @hidden */
  78346. _children: Control[];
  78347. /** @hidden */
  78348. protected _measureForChildren: Measure;
  78349. /** @hidden */
  78350. protected _background: string;
  78351. /** @hidden */
  78352. protected _adaptWidthToChildren: boolean;
  78353. /** @hidden */
  78354. protected _adaptHeightToChildren: boolean;
  78355. /**
  78356. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78357. */
  78358. logLayoutCycleErrors: boolean;
  78359. /**
  78360. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78361. */
  78362. maxLayoutCycle: number;
  78363. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78364. get adaptHeightToChildren(): boolean;
  78365. set adaptHeightToChildren(value: boolean);
  78366. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78367. get adaptWidthToChildren(): boolean;
  78368. set adaptWidthToChildren(value: boolean);
  78369. /** Gets or sets background color */
  78370. get background(): string;
  78371. set background(value: string);
  78372. /** Gets the list of children */
  78373. get children(): Control[];
  78374. /**
  78375. * Creates a new Container
  78376. * @param name defines the name of the container
  78377. */
  78378. constructor(name?: string | undefined);
  78379. protected _getTypeName(): string;
  78380. _flagDescendantsAsMatrixDirty(): void;
  78381. /**
  78382. * Gets a child using its name
  78383. * @param name defines the child name to look for
  78384. * @returns the child control if found
  78385. */
  78386. getChildByName(name: string): BABYLON.Nullable<Control>;
  78387. /**
  78388. * Gets a child using its type and its name
  78389. * @param name defines the child name to look for
  78390. * @param type defines the child type to look for
  78391. * @returns the child control if found
  78392. */
  78393. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78394. /**
  78395. * Search for a specific control in children
  78396. * @param control defines the control to look for
  78397. * @returns true if the control is in child list
  78398. */
  78399. containsControl(control: Control): boolean;
  78400. /**
  78401. * Adds a new control to the current container
  78402. * @param control defines the control to add
  78403. * @returns the current container
  78404. */
  78405. addControl(control: BABYLON.Nullable<Control>): Container;
  78406. /**
  78407. * Removes all controls from the current container
  78408. * @returns the current container
  78409. */
  78410. clearControls(): Container;
  78411. /**
  78412. * Removes a control from the current container
  78413. * @param control defines the control to remove
  78414. * @returns the current container
  78415. */
  78416. removeControl(control: Control): Container;
  78417. /** @hidden */
  78418. _reOrderControl(control: Control): void;
  78419. /** @hidden */
  78420. _offsetLeft(offset: number): void;
  78421. /** @hidden */
  78422. _offsetTop(offset: number): void;
  78423. /** @hidden */
  78424. _markAllAsDirty(): void;
  78425. /** @hidden */
  78426. protected _localDraw(context: CanvasRenderingContext2D): void;
  78427. /** @hidden */
  78428. _link(host: AdvancedDynamicTexture): void;
  78429. /** @hidden */
  78430. protected _beforeLayout(): void;
  78431. /** @hidden */
  78432. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78433. /** @hidden */
  78434. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78435. protected _postMeasure(): void;
  78436. /** @hidden */
  78437. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78438. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78439. /** @hidden */
  78440. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78441. /** @hidden */
  78442. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78443. /** Releases associated resources */
  78444. dispose(): void;
  78445. }
  78446. }
  78447. declare module BABYLON.GUI {
  78448. /** Class used to create rectangle container */
  78449. export class Rectangle extends Container {
  78450. name?: string | undefined;
  78451. private _thickness;
  78452. private _cornerRadius;
  78453. /** Gets or sets border thickness */
  78454. get thickness(): number;
  78455. set thickness(value: number);
  78456. /** Gets or sets the corner radius angle */
  78457. get cornerRadius(): number;
  78458. set cornerRadius(value: number);
  78459. /**
  78460. * Creates a new Rectangle
  78461. * @param name defines the control name
  78462. */
  78463. constructor(name?: string | undefined);
  78464. protected _getTypeName(): string;
  78465. protected _localDraw(context: CanvasRenderingContext2D): void;
  78466. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78467. private _drawRoundedRect;
  78468. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78469. }
  78470. }
  78471. declare module BABYLON.GUI {
  78472. /**
  78473. * Enum that determines the text-wrapping mode to use.
  78474. */
  78475. export enum TextWrapping {
  78476. /**
  78477. * Clip the text when it's larger than Control.width; this is the default mode.
  78478. */
  78479. Clip = 0,
  78480. /**
  78481. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78482. */
  78483. WordWrap = 1,
  78484. /**
  78485. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78486. */
  78487. Ellipsis = 2
  78488. }
  78489. /**
  78490. * Class used to create text block control
  78491. */
  78492. export class TextBlock extends Control {
  78493. /**
  78494. * Defines the name of the control
  78495. */
  78496. name?: string | undefined;
  78497. private _text;
  78498. private _textWrapping;
  78499. private _textHorizontalAlignment;
  78500. private _textVerticalAlignment;
  78501. private _lines;
  78502. private _resizeToFit;
  78503. private _lineSpacing;
  78504. private _outlineWidth;
  78505. private _outlineColor;
  78506. private _underline;
  78507. private _lineThrough;
  78508. /**
  78509. * An event triggered after the text is changed
  78510. */
  78511. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78512. /**
  78513. * An event triggered after the text was broken up into lines
  78514. */
  78515. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78516. /**
  78517. * Function used to split a string into words. By default, a string is split at each space character found
  78518. */
  78519. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78520. /**
  78521. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78522. */
  78523. get lines(): any[];
  78524. /**
  78525. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78526. */
  78527. get resizeToFit(): boolean;
  78528. /**
  78529. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78530. */
  78531. set resizeToFit(value: boolean);
  78532. /**
  78533. * Gets or sets a boolean indicating if text must be wrapped
  78534. */
  78535. get textWrapping(): TextWrapping | boolean;
  78536. /**
  78537. * Gets or sets a boolean indicating if text must be wrapped
  78538. */
  78539. set textWrapping(value: TextWrapping | boolean);
  78540. /**
  78541. * Gets or sets text to display
  78542. */
  78543. get text(): string;
  78544. /**
  78545. * Gets or sets text to display
  78546. */
  78547. set text(value: string);
  78548. /**
  78549. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78550. */
  78551. get textHorizontalAlignment(): number;
  78552. /**
  78553. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78554. */
  78555. set textHorizontalAlignment(value: number);
  78556. /**
  78557. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78558. */
  78559. get textVerticalAlignment(): number;
  78560. /**
  78561. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78562. */
  78563. set textVerticalAlignment(value: number);
  78564. /**
  78565. * Gets or sets line spacing value
  78566. */
  78567. set lineSpacing(value: string | number);
  78568. /**
  78569. * Gets or sets line spacing value
  78570. */
  78571. get lineSpacing(): string | number;
  78572. /**
  78573. * Gets or sets outlineWidth of the text to display
  78574. */
  78575. get outlineWidth(): number;
  78576. /**
  78577. * Gets or sets outlineWidth of the text to display
  78578. */
  78579. set outlineWidth(value: number);
  78580. /**
  78581. * Gets or sets a boolean indicating that text must have underline
  78582. */
  78583. get underline(): boolean;
  78584. /**
  78585. * Gets or sets a boolean indicating that text must have underline
  78586. */
  78587. set underline(value: boolean);
  78588. /**
  78589. * Gets or sets an boolean indicating that text must be crossed out
  78590. */
  78591. get lineThrough(): boolean;
  78592. /**
  78593. * Gets or sets an boolean indicating that text must be crossed out
  78594. */
  78595. set lineThrough(value: boolean);
  78596. /**
  78597. * Gets or sets outlineColor of the text to display
  78598. */
  78599. get outlineColor(): string;
  78600. /**
  78601. * Gets or sets outlineColor of the text to display
  78602. */
  78603. set outlineColor(value: string);
  78604. /**
  78605. * Creates a new TextBlock object
  78606. * @param name defines the name of the control
  78607. * @param text defines the text to display (emptry string by default)
  78608. */
  78609. constructor(
  78610. /**
  78611. * Defines the name of the control
  78612. */
  78613. name?: string | undefined, text?: string);
  78614. protected _getTypeName(): string;
  78615. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78616. private _drawText;
  78617. /** @hidden */
  78618. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78619. protected _applyStates(context: CanvasRenderingContext2D): void;
  78620. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78621. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78622. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78623. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78624. protected _renderLines(context: CanvasRenderingContext2D): void;
  78625. /**
  78626. * Given a width constraint applied on the text block, find the expected height
  78627. * @returns expected height
  78628. */
  78629. computeExpectedHeight(): number;
  78630. dispose(): void;
  78631. }
  78632. }
  78633. declare module BABYLON.GUI {
  78634. /**
  78635. * Class used to create 2D images
  78636. */
  78637. export class Image extends Control {
  78638. name?: string | undefined;
  78639. private _workingCanvas;
  78640. private _domImage;
  78641. private _imageWidth;
  78642. private _imageHeight;
  78643. private _loaded;
  78644. private _stretch;
  78645. private _source;
  78646. private _autoScale;
  78647. private _sourceLeft;
  78648. private _sourceTop;
  78649. private _sourceWidth;
  78650. private _sourceHeight;
  78651. private _svgAttributesComputationCompleted;
  78652. private _isSVG;
  78653. private _cellWidth;
  78654. private _cellHeight;
  78655. private _cellId;
  78656. private _populateNinePatchSlicesFromImage;
  78657. private _sliceLeft;
  78658. private _sliceRight;
  78659. private _sliceTop;
  78660. private _sliceBottom;
  78661. private _detectPointerOnOpaqueOnly;
  78662. private _imageDataCache;
  78663. /**
  78664. * BABYLON.Observable notified when the content is loaded
  78665. */
  78666. onImageLoadedObservable: BABYLON.Observable<Image>;
  78667. /**
  78668. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78669. */
  78670. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78671. /**
  78672. * Gets a boolean indicating that the content is loaded
  78673. */
  78674. get isLoaded(): boolean;
  78675. /**
  78676. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78677. */
  78678. get populateNinePatchSlicesFromImage(): boolean;
  78679. set populateNinePatchSlicesFromImage(value: boolean);
  78680. /**
  78681. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78682. * Beware using this as this will comsume more memory as the image has to be stored twice
  78683. */
  78684. get detectPointerOnOpaqueOnly(): boolean;
  78685. set detectPointerOnOpaqueOnly(value: boolean);
  78686. /**
  78687. * Gets or sets the left value for slicing (9-patch)
  78688. */
  78689. get sliceLeft(): number;
  78690. set sliceLeft(value: number);
  78691. /**
  78692. * Gets or sets the right value for slicing (9-patch)
  78693. */
  78694. get sliceRight(): number;
  78695. set sliceRight(value: number);
  78696. /**
  78697. * Gets or sets the top value for slicing (9-patch)
  78698. */
  78699. get sliceTop(): number;
  78700. set sliceTop(value: number);
  78701. /**
  78702. * Gets or sets the bottom value for slicing (9-patch)
  78703. */
  78704. get sliceBottom(): number;
  78705. set sliceBottom(value: number);
  78706. /**
  78707. * Gets or sets the left coordinate in the source image
  78708. */
  78709. get sourceLeft(): number;
  78710. set sourceLeft(value: number);
  78711. /**
  78712. * Gets or sets the top coordinate in the source image
  78713. */
  78714. get sourceTop(): number;
  78715. set sourceTop(value: number);
  78716. /**
  78717. * Gets or sets the width to capture in the source image
  78718. */
  78719. get sourceWidth(): number;
  78720. set sourceWidth(value: number);
  78721. /**
  78722. * Gets or sets the height to capture in the source image
  78723. */
  78724. get sourceHeight(): number;
  78725. set sourceHeight(value: number);
  78726. /** Indicates if the format of the image is SVG */
  78727. get isSVG(): boolean;
  78728. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78729. get svgAttributesComputationCompleted(): boolean;
  78730. /**
  78731. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78732. * @see https://doc.babylonjs.com/how_to/gui#image
  78733. */
  78734. get autoScale(): boolean;
  78735. set autoScale(value: boolean);
  78736. /** Gets or sets the streching mode used by the image */
  78737. get stretch(): number;
  78738. set stretch(value: number);
  78739. /** @hidden */
  78740. _rotate90(n: number, preserveProperties?: boolean): Image;
  78741. private _handleRotationForSVGImage;
  78742. private _rotate90SourceProperties;
  78743. /**
  78744. * Gets or sets the internal DOM image used to render the control
  78745. */
  78746. set domImage(value: HTMLImageElement);
  78747. get domImage(): HTMLImageElement;
  78748. private _onImageLoaded;
  78749. private _extractNinePatchSliceDataFromImage;
  78750. /**
  78751. * Gets or sets image source url
  78752. */
  78753. set source(value: BABYLON.Nullable<string>);
  78754. /**
  78755. * Checks for svg document with icon id present
  78756. */
  78757. private _svgCheck;
  78758. /**
  78759. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78760. * given external svg file and icon id
  78761. */
  78762. private _getSVGAttribs;
  78763. /**
  78764. * Gets or sets the cell width to use when animation sheet is enabled
  78765. * @see https://doc.babylonjs.com/how_to/gui#image
  78766. */
  78767. get cellWidth(): number;
  78768. set cellWidth(value: number);
  78769. /**
  78770. * Gets or sets the cell height to use when animation sheet is enabled
  78771. * @see https://doc.babylonjs.com/how_to/gui#image
  78772. */
  78773. get cellHeight(): number;
  78774. set cellHeight(value: number);
  78775. /**
  78776. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78777. * @see https://doc.babylonjs.com/how_to/gui#image
  78778. */
  78779. get cellId(): number;
  78780. set cellId(value: number);
  78781. /**
  78782. * Creates a new Image
  78783. * @param name defines the control name
  78784. * @param url defines the image url
  78785. */
  78786. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78787. /**
  78788. * Tests if a given coordinates belong to the current control
  78789. * @param x defines x coordinate to test
  78790. * @param y defines y coordinate to test
  78791. * @returns true if the coordinates are inside the control
  78792. */
  78793. contains(x: number, y: number): boolean;
  78794. protected _getTypeName(): string;
  78795. /** Force the control to synchronize with its content */
  78796. synchronizeSizeWithContent(): void;
  78797. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78798. private _prepareWorkingCanvasForOpaqueDetection;
  78799. private _drawImage;
  78800. _draw(context: CanvasRenderingContext2D): void;
  78801. private _renderCornerPatch;
  78802. private _renderNinePatch;
  78803. dispose(): void;
  78804. /** STRETCH_NONE */
  78805. static readonly STRETCH_NONE: number;
  78806. /** STRETCH_FILL */
  78807. static readonly STRETCH_FILL: number;
  78808. /** STRETCH_UNIFORM */
  78809. static readonly STRETCH_UNIFORM: number;
  78810. /** STRETCH_EXTEND */
  78811. static readonly STRETCH_EXTEND: number;
  78812. /** NINE_PATCH */
  78813. static readonly STRETCH_NINE_PATCH: number;
  78814. }
  78815. }
  78816. declare module BABYLON.GUI {
  78817. /**
  78818. * Class used to create 2D buttons
  78819. */
  78820. export class Button extends Rectangle {
  78821. name?: string | undefined;
  78822. /**
  78823. * Function called to generate a pointer enter animation
  78824. */
  78825. pointerEnterAnimation: () => void;
  78826. /**
  78827. * Function called to generate a pointer out animation
  78828. */
  78829. pointerOutAnimation: () => void;
  78830. /**
  78831. * Function called to generate a pointer down animation
  78832. */
  78833. pointerDownAnimation: () => void;
  78834. /**
  78835. * Function called to generate a pointer up animation
  78836. */
  78837. pointerUpAnimation: () => void;
  78838. /**
  78839. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78840. */
  78841. delegatePickingToChildren: boolean;
  78842. private _image;
  78843. /**
  78844. * Returns the image part of the button (if any)
  78845. */
  78846. get image(): BABYLON.Nullable<Image>;
  78847. private _textBlock;
  78848. /**
  78849. * Returns the image part of the button (if any)
  78850. */
  78851. get textBlock(): BABYLON.Nullable<TextBlock>;
  78852. /**
  78853. * Creates a new Button
  78854. * @param name defines the name of the button
  78855. */
  78856. constructor(name?: string | undefined);
  78857. protected _getTypeName(): string;
  78858. /** @hidden */
  78859. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78860. /** @hidden */
  78861. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78862. /** @hidden */
  78863. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  78864. /** @hidden */
  78865. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78866. /** @hidden */
  78867. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  78868. /**
  78869. * Creates a new button made with an image and a text
  78870. * @param name defines the name of the button
  78871. * @param text defines the text of the button
  78872. * @param imageUrl defines the url of the image
  78873. * @returns a new Button
  78874. */
  78875. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78876. /**
  78877. * Creates a new button made with an image
  78878. * @param name defines the name of the button
  78879. * @param imageUrl defines the url of the image
  78880. * @returns a new Button
  78881. */
  78882. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78883. /**
  78884. * Creates a new button made with a text
  78885. * @param name defines the name of the button
  78886. * @param text defines the text of the button
  78887. * @returns a new Button
  78888. */
  78889. static CreateSimpleButton(name: string, text: string): Button;
  78890. /**
  78891. * Creates a new button made with an image and a centered text
  78892. * @param name defines the name of the button
  78893. * @param text defines the text of the button
  78894. * @param imageUrl defines the url of the image
  78895. * @returns a new Button
  78896. */
  78897. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78898. }
  78899. }
  78900. declare module BABYLON.GUI {
  78901. /**
  78902. * Class used to create a 2D stack panel container
  78903. */
  78904. export class StackPanel extends Container {
  78905. name?: string | undefined;
  78906. private _isVertical;
  78907. private _manualWidth;
  78908. private _manualHeight;
  78909. private _doNotTrackManualChanges;
  78910. /**
  78911. * Gets or sets a boolean indicating that layou warnings should be ignored
  78912. */
  78913. ignoreLayoutWarnings: boolean;
  78914. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78915. get isVertical(): boolean;
  78916. set isVertical(value: boolean);
  78917. /**
  78918. * Gets or sets panel width.
  78919. * This value should not be set when in horizontal mode as it will be computed automatically
  78920. */
  78921. set width(value: string | number);
  78922. get width(): string | number;
  78923. /**
  78924. * Gets or sets panel height.
  78925. * This value should not be set when in vertical mode as it will be computed automatically
  78926. */
  78927. set height(value: string | number);
  78928. get height(): string | number;
  78929. /**
  78930. * Creates a new StackPanel
  78931. * @param name defines control name
  78932. */
  78933. constructor(name?: string | undefined);
  78934. protected _getTypeName(): string;
  78935. /** @hidden */
  78936. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78937. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78938. protected _postMeasure(): void;
  78939. }
  78940. }
  78941. declare module BABYLON.GUI {
  78942. /**
  78943. * Class used to represent a 2D checkbox
  78944. */
  78945. export class Checkbox extends Control {
  78946. name?: string | undefined;
  78947. private _isChecked;
  78948. private _background;
  78949. private _checkSizeRatio;
  78950. private _thickness;
  78951. /** Gets or sets border thickness */
  78952. get thickness(): number;
  78953. set thickness(value: number);
  78954. /**
  78955. * BABYLON.Observable raised when isChecked property changes
  78956. */
  78957. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78958. /** Gets or sets a value indicating the ratio between overall size and check size */
  78959. get checkSizeRatio(): number;
  78960. set checkSizeRatio(value: number);
  78961. /** Gets or sets background color */
  78962. get background(): string;
  78963. set background(value: string);
  78964. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78965. get isChecked(): boolean;
  78966. set isChecked(value: boolean);
  78967. /**
  78968. * Creates a new CheckBox
  78969. * @param name defines the control name
  78970. */
  78971. constructor(name?: string | undefined);
  78972. protected _getTypeName(): string;
  78973. /** @hidden */
  78974. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78975. /** @hidden */
  78976. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78977. /**
  78978. * Utility function to easily create a checkbox with a header
  78979. * @param title defines the label to use for the header
  78980. * @param onValueChanged defines the callback to call when value changes
  78981. * @returns a StackPanel containing the checkbox and a textBlock
  78982. */
  78983. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78984. }
  78985. }
  78986. declare module BABYLON.GUI {
  78987. /**
  78988. * Class used to store key control properties
  78989. */
  78990. export class KeyPropertySet {
  78991. /** Width */
  78992. width?: string;
  78993. /** Height */
  78994. height?: string;
  78995. /** Left padding */
  78996. paddingLeft?: string;
  78997. /** Right padding */
  78998. paddingRight?: string;
  78999. /** Top padding */
  79000. paddingTop?: string;
  79001. /** Bottom padding */
  79002. paddingBottom?: string;
  79003. /** Foreground color */
  79004. color?: string;
  79005. /** Background color */
  79006. background?: string;
  79007. }
  79008. /**
  79009. * Class used to create virtual keyboard
  79010. */
  79011. export class VirtualKeyboard extends StackPanel {
  79012. /** BABYLON.Observable raised when a key is pressed */
  79013. onKeyPressObservable: BABYLON.Observable<string>;
  79014. /** Gets or sets default key button width */
  79015. defaultButtonWidth: string;
  79016. /** Gets or sets default key button height */
  79017. defaultButtonHeight: string;
  79018. /** Gets or sets default key button left padding */
  79019. defaultButtonPaddingLeft: string;
  79020. /** Gets or sets default key button right padding */
  79021. defaultButtonPaddingRight: string;
  79022. /** Gets or sets default key button top padding */
  79023. defaultButtonPaddingTop: string;
  79024. /** Gets or sets default key button bottom padding */
  79025. defaultButtonPaddingBottom: string;
  79026. /** Gets or sets default key button foreground color */
  79027. defaultButtonColor: string;
  79028. /** Gets or sets default key button background color */
  79029. defaultButtonBackground: string;
  79030. /** Gets or sets shift button foreground color */
  79031. shiftButtonColor: string;
  79032. /** Gets or sets shift button thickness*/
  79033. selectedShiftThickness: number;
  79034. /** Gets shift key state */
  79035. shiftState: number;
  79036. protected _getTypeName(): string;
  79037. private _createKey;
  79038. /**
  79039. * Adds a new row of keys
  79040. * @param keys defines the list of keys to add
  79041. * @param propertySets defines the associated property sets
  79042. */
  79043. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79044. /**
  79045. * Set the shift key to a specific state
  79046. * @param shiftState defines the new shift state
  79047. */
  79048. applyShiftState(shiftState: number): void;
  79049. private _currentlyConnectedInputText;
  79050. private _connectedInputTexts;
  79051. private _onKeyPressObserver;
  79052. /** Gets the input text control currently attached to the keyboard */
  79053. get connectedInputText(): BABYLON.Nullable<InputText>;
  79054. /**
  79055. * Connects the keyboard with an input text control
  79056. *
  79057. * @param input defines the target control
  79058. */
  79059. connect(input: InputText): void;
  79060. /**
  79061. * Disconnects the keyboard from connected InputText controls
  79062. *
  79063. * @param input optionally defines a target control, otherwise all are disconnected
  79064. */
  79065. disconnect(input?: InputText): void;
  79066. private _removeConnectedInputObservables;
  79067. /**
  79068. * Release all resources
  79069. */
  79070. dispose(): void;
  79071. /**
  79072. * Creates a new keyboard using a default layout
  79073. *
  79074. * @param name defines control name
  79075. * @returns a new VirtualKeyboard
  79076. */
  79077. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79078. }
  79079. }
  79080. declare module BABYLON.GUI {
  79081. /**
  79082. * Class used to create input text control
  79083. */
  79084. export class InputText extends Control implements IFocusableControl {
  79085. name?: string | undefined;
  79086. private _text;
  79087. private _placeholderText;
  79088. private _background;
  79089. private _focusedBackground;
  79090. private _focusedColor;
  79091. private _placeholderColor;
  79092. private _thickness;
  79093. private _margin;
  79094. private _autoStretchWidth;
  79095. private _maxWidth;
  79096. private _isFocused;
  79097. private _blinkTimeout;
  79098. private _blinkIsEven;
  79099. private _cursorOffset;
  79100. private _scrollLeft;
  79101. private _textWidth;
  79102. private _clickedCoordinate;
  79103. private _deadKey;
  79104. private _addKey;
  79105. private _currentKey;
  79106. private _isTextHighlightOn;
  79107. private _textHighlightColor;
  79108. private _highligherOpacity;
  79109. private _highlightedText;
  79110. private _startHighlightIndex;
  79111. private _endHighlightIndex;
  79112. private _cursorIndex;
  79113. private _onFocusSelectAll;
  79114. private _isPointerDown;
  79115. private _onClipboardObserver;
  79116. private _onPointerDblTapObserver;
  79117. /** @hidden */
  79118. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79119. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79120. promptMessage: string;
  79121. /** Force disable prompt on mobile device */
  79122. disableMobilePrompt: boolean;
  79123. /** BABYLON.Observable raised when the text changes */
  79124. onTextChangedObservable: BABYLON.Observable<InputText>;
  79125. /** BABYLON.Observable raised just before an entered character is to be added */
  79126. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79127. /** BABYLON.Observable raised when the control gets the focus */
  79128. onFocusObservable: BABYLON.Observable<InputText>;
  79129. /** BABYLON.Observable raised when the control loses the focus */
  79130. onBlurObservable: BABYLON.Observable<InputText>;
  79131. /**Observable raised when the text is highlighted */
  79132. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79133. /**Observable raised when copy event is triggered */
  79134. onTextCopyObservable: BABYLON.Observable<InputText>;
  79135. /** BABYLON.Observable raised when cut event is triggered */
  79136. onTextCutObservable: BABYLON.Observable<InputText>;
  79137. /** BABYLON.Observable raised when paste event is triggered */
  79138. onTextPasteObservable: BABYLON.Observable<InputText>;
  79139. /** BABYLON.Observable raised when a key event was processed */
  79140. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79141. /** Gets or sets the maximum width allowed by the control */
  79142. get maxWidth(): string | number;
  79143. /** Gets the maximum width allowed by the control in pixels */
  79144. get maxWidthInPixels(): number;
  79145. set maxWidth(value: string | number);
  79146. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79147. get highligherOpacity(): number;
  79148. set highligherOpacity(value: number);
  79149. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79150. get onFocusSelectAll(): boolean;
  79151. set onFocusSelectAll(value: boolean);
  79152. /** Gets or sets the text hightlight color */
  79153. get textHighlightColor(): string;
  79154. set textHighlightColor(value: string);
  79155. /** Gets or sets control margin */
  79156. get margin(): string;
  79157. /** Gets control margin in pixels */
  79158. get marginInPixels(): number;
  79159. set margin(value: string);
  79160. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79161. get autoStretchWidth(): boolean;
  79162. set autoStretchWidth(value: boolean);
  79163. /** Gets or sets border thickness */
  79164. get thickness(): number;
  79165. set thickness(value: number);
  79166. /** Gets or sets the background color when focused */
  79167. get focusedBackground(): string;
  79168. set focusedBackground(value: string);
  79169. /** Gets or sets the background color when focused */
  79170. get focusedColor(): string;
  79171. set focusedColor(value: string);
  79172. /** Gets or sets the background color */
  79173. get background(): string;
  79174. set background(value: string);
  79175. /** Gets or sets the placeholder color */
  79176. get placeholderColor(): string;
  79177. set placeholderColor(value: string);
  79178. /** Gets or sets the text displayed when the control is empty */
  79179. get placeholderText(): string;
  79180. set placeholderText(value: string);
  79181. /** Gets or sets the dead key flag */
  79182. get deadKey(): boolean;
  79183. set deadKey(flag: boolean);
  79184. /** Gets or sets the highlight text */
  79185. get highlightedText(): string;
  79186. set highlightedText(text: string);
  79187. /** Gets or sets if the current key should be added */
  79188. get addKey(): boolean;
  79189. set addKey(flag: boolean);
  79190. /** Gets or sets the value of the current key being entered */
  79191. get currentKey(): string;
  79192. set currentKey(key: string);
  79193. /** Gets or sets the text displayed in the control */
  79194. get text(): string;
  79195. set text(value: string);
  79196. /** Gets or sets control width */
  79197. get width(): string | number;
  79198. set width(value: string | number);
  79199. /**
  79200. * Creates a new InputText
  79201. * @param name defines the control name
  79202. * @param text defines the text of the control
  79203. */
  79204. constructor(name?: string | undefined, text?: string);
  79205. /** @hidden */
  79206. onBlur(): void;
  79207. /** @hidden */
  79208. onFocus(): void;
  79209. protected _getTypeName(): string;
  79210. /**
  79211. * Function called to get the list of controls that should not steal the focus from this control
  79212. * @returns an array of controls
  79213. */
  79214. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79215. /** @hidden */
  79216. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79217. /** @hidden */
  79218. private _updateValueFromCursorIndex;
  79219. /** @hidden */
  79220. private _processDblClick;
  79221. /** @hidden */
  79222. private _selectAllText;
  79223. /**
  79224. * Handles the keyboard event
  79225. * @param evt Defines the KeyboardEvent
  79226. */
  79227. processKeyboard(evt: KeyboardEvent): void;
  79228. /** @hidden */
  79229. private _onCopyText;
  79230. /** @hidden */
  79231. private _onCutText;
  79232. /** @hidden */
  79233. private _onPasteText;
  79234. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79235. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79236. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79237. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79238. protected _beforeRenderText(text: string): string;
  79239. dispose(): void;
  79240. }
  79241. }
  79242. declare module BABYLON.GUI {
  79243. /**
  79244. * Class used to create a 2D grid container
  79245. */
  79246. export class Grid extends Container {
  79247. name?: string | undefined;
  79248. private _rowDefinitions;
  79249. private _columnDefinitions;
  79250. private _cells;
  79251. private _childControls;
  79252. /**
  79253. * Gets the number of columns
  79254. */
  79255. get columnCount(): number;
  79256. /**
  79257. * Gets the number of rows
  79258. */
  79259. get rowCount(): number;
  79260. /** Gets the list of children */
  79261. get children(): Control[];
  79262. /** Gets the list of cells (e.g. the containers) */
  79263. get cells(): {
  79264. [key: string]: Container;
  79265. };
  79266. /**
  79267. * Gets the definition of a specific row
  79268. * @param index defines the index of the row
  79269. * @returns the row definition
  79270. */
  79271. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79272. /**
  79273. * Gets the definition of a specific column
  79274. * @param index defines the index of the column
  79275. * @returns the column definition
  79276. */
  79277. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79278. /**
  79279. * Adds a new row to the grid
  79280. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79281. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79282. * @returns the current grid
  79283. */
  79284. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79285. /**
  79286. * Adds a new column to the grid
  79287. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79288. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79289. * @returns the current grid
  79290. */
  79291. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79292. /**
  79293. * Update a row definition
  79294. * @param index defines the index of the row to update
  79295. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79296. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79297. * @returns the current grid
  79298. */
  79299. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79300. /**
  79301. * Update a column definition
  79302. * @param index defines the index of the column to update
  79303. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79304. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79305. * @returns the current grid
  79306. */
  79307. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79308. /**
  79309. * Gets the list of children stored in a specific cell
  79310. * @param row defines the row to check
  79311. * @param column defines the column to check
  79312. * @returns the list of controls
  79313. */
  79314. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79315. /**
  79316. * Gets a string representing the child cell info (row x column)
  79317. * @param child defines the control to get info from
  79318. * @returns a string containing the child cell info (row x column)
  79319. */
  79320. getChildCellInfo(child: Control): string;
  79321. private _removeCell;
  79322. private _offsetCell;
  79323. /**
  79324. * Remove a column definition at specified index
  79325. * @param index defines the index of the column to remove
  79326. * @returns the current grid
  79327. */
  79328. removeColumnDefinition(index: number): Grid;
  79329. /**
  79330. * Remove a row definition at specified index
  79331. * @param index defines the index of the row to remove
  79332. * @returns the current grid
  79333. */
  79334. removeRowDefinition(index: number): Grid;
  79335. /**
  79336. * Adds a new control to the current grid
  79337. * @param control defines the control to add
  79338. * @param row defines the row where to add the control (0 by default)
  79339. * @param column defines the column where to add the control (0 by default)
  79340. * @returns the current grid
  79341. */
  79342. addControl(control: Control, row?: number, column?: number): Grid;
  79343. /**
  79344. * Removes a control from the current container
  79345. * @param control defines the control to remove
  79346. * @returns the current container
  79347. */
  79348. removeControl(control: Control): Container;
  79349. /**
  79350. * Creates a new Grid
  79351. * @param name defines control name
  79352. */
  79353. constructor(name?: string | undefined);
  79354. protected _getTypeName(): string;
  79355. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79356. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79357. _flagDescendantsAsMatrixDirty(): void;
  79358. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79359. /** Releases associated resources */
  79360. dispose(): void;
  79361. }
  79362. }
  79363. declare module BABYLON.GUI {
  79364. /** Class used to create color pickers */
  79365. export class ColorPicker extends Control {
  79366. name?: string | undefined;
  79367. private static _Epsilon;
  79368. private _colorWheelCanvas;
  79369. private _value;
  79370. private _tmpColor;
  79371. private _pointerStartedOnSquare;
  79372. private _pointerStartedOnWheel;
  79373. private _squareLeft;
  79374. private _squareTop;
  79375. private _squareSize;
  79376. private _h;
  79377. private _s;
  79378. private _v;
  79379. private _lastPointerDownID;
  79380. /**
  79381. * BABYLON.Observable raised when the value changes
  79382. */
  79383. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79384. /** Gets or sets the color of the color picker */
  79385. get value(): BABYLON.Color3;
  79386. set value(value: BABYLON.Color3);
  79387. /**
  79388. * Gets or sets control width
  79389. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79390. */
  79391. get width(): string | number;
  79392. set width(value: string | number);
  79393. /**
  79394. * Gets or sets control height
  79395. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79396. */
  79397. get height(): string | number;
  79398. /** Gets or sets control height */
  79399. set height(value: string | number);
  79400. /** Gets or sets control size */
  79401. get size(): string | number;
  79402. set size(value: string | number);
  79403. /**
  79404. * Creates a new ColorPicker
  79405. * @param name defines the control name
  79406. */
  79407. constructor(name?: string | undefined);
  79408. protected _getTypeName(): string;
  79409. /** @hidden */
  79410. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79411. private _updateSquareProps;
  79412. private _drawGradientSquare;
  79413. private _drawCircle;
  79414. private _createColorWheelCanvas;
  79415. /** @hidden */
  79416. _draw(context: CanvasRenderingContext2D): void;
  79417. private _pointerIsDown;
  79418. private _updateValueFromPointer;
  79419. private _isPointOnSquare;
  79420. private _isPointOnWheel;
  79421. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79422. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79423. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79424. _onCanvasBlur(): void;
  79425. /**
  79426. * This function expands the color picker by creating a color picker dialog with manual
  79427. * color value input and the ability to save colors into an array to be used later in
  79428. * subsequent launches of the dialogue.
  79429. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79430. * @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.
  79431. * @returns picked color as a hex string and the saved colors array as hex strings.
  79432. */
  79433. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79434. pickerWidth?: string;
  79435. pickerHeight?: string;
  79436. headerHeight?: string;
  79437. lastColor?: string;
  79438. swatchLimit?: number;
  79439. numSwatchesPerLine?: number;
  79440. savedColors?: Array<string>;
  79441. }): Promise<{
  79442. savedColors?: string[];
  79443. pickedColor: string;
  79444. }>;
  79445. }
  79446. }
  79447. declare module BABYLON.GUI {
  79448. /** Class used to create 2D ellipse containers */
  79449. export class Ellipse extends Container {
  79450. name?: string | undefined;
  79451. private _thickness;
  79452. /** Gets or sets border thickness */
  79453. get thickness(): number;
  79454. set thickness(value: number);
  79455. /**
  79456. * Creates a new Ellipse
  79457. * @param name defines the control name
  79458. */
  79459. constructor(name?: string | undefined);
  79460. protected _getTypeName(): string;
  79461. protected _localDraw(context: CanvasRenderingContext2D): void;
  79462. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79463. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79464. }
  79465. }
  79466. declare module BABYLON.GUI {
  79467. /**
  79468. * Class used to create a password control
  79469. */
  79470. export class InputPassword extends InputText {
  79471. protected _beforeRenderText(text: string): string;
  79472. }
  79473. }
  79474. declare module BABYLON.GUI {
  79475. /** Class used to render 2D lines */
  79476. export class Line extends Control {
  79477. name?: string | undefined;
  79478. private _lineWidth;
  79479. private _x1;
  79480. private _y1;
  79481. private _x2;
  79482. private _y2;
  79483. private _dash;
  79484. private _connectedControl;
  79485. private _connectedControlDirtyObserver;
  79486. /** Gets or sets the dash pattern */
  79487. get dash(): Array<number>;
  79488. set dash(value: Array<number>);
  79489. /** Gets or sets the control connected with the line end */
  79490. get connectedControl(): Control;
  79491. set connectedControl(value: Control);
  79492. /** Gets or sets start coordinates on X axis */
  79493. get x1(): string | number;
  79494. set x1(value: string | number);
  79495. /** Gets or sets start coordinates on Y axis */
  79496. get y1(): string | number;
  79497. set y1(value: string | number);
  79498. /** Gets or sets end coordinates on X axis */
  79499. get x2(): string | number;
  79500. set x2(value: string | number);
  79501. /** Gets or sets end coordinates on Y axis */
  79502. get y2(): string | number;
  79503. set y2(value: string | number);
  79504. /** Gets or sets line width */
  79505. get lineWidth(): number;
  79506. set lineWidth(value: number);
  79507. /** Gets or sets horizontal alignment */
  79508. set horizontalAlignment(value: number);
  79509. /** Gets or sets vertical alignment */
  79510. set verticalAlignment(value: number);
  79511. private get _effectiveX2();
  79512. private get _effectiveY2();
  79513. /**
  79514. * Creates a new Line
  79515. * @param name defines the control name
  79516. */
  79517. constructor(name?: string | undefined);
  79518. protected _getTypeName(): string;
  79519. _draw(context: CanvasRenderingContext2D): void;
  79520. _measure(): void;
  79521. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79522. /**
  79523. * Move one end of the line given 3D cartesian coordinates.
  79524. * @param position Targeted world position
  79525. * @param scene BABYLON.Scene
  79526. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79527. */
  79528. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79529. /**
  79530. * Move one end of the line to a position in screen absolute space.
  79531. * @param projectedPosition Position in screen absolute space (X, Y)
  79532. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79533. */
  79534. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79535. }
  79536. }
  79537. declare module BABYLON.GUI {
  79538. /**
  79539. * Class used to store a point for a MultiLine object.
  79540. * The point can be pure 2D coordinates, a mesh or a control
  79541. */
  79542. export class MultiLinePoint {
  79543. private _multiLine;
  79544. private _x;
  79545. private _y;
  79546. private _control;
  79547. private _mesh;
  79548. private _controlObserver;
  79549. private _meshObserver;
  79550. /** @hidden */
  79551. _point: BABYLON.Vector2;
  79552. /**
  79553. * Creates a new MultiLinePoint
  79554. * @param multiLine defines the source MultiLine object
  79555. */
  79556. constructor(multiLine: MultiLine);
  79557. /** Gets or sets x coordinate */
  79558. get x(): string | number;
  79559. set x(value: string | number);
  79560. /** Gets or sets y coordinate */
  79561. get y(): string | number;
  79562. set y(value: string | number);
  79563. /** Gets or sets the control associated with this point */
  79564. get control(): BABYLON.Nullable<Control>;
  79565. set control(value: BABYLON.Nullable<Control>);
  79566. /** Gets or sets the mesh associated with this point */
  79567. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79568. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79569. /** Resets links */
  79570. resetLinks(): void;
  79571. /**
  79572. * Gets a translation vector
  79573. * @returns the translation vector
  79574. */
  79575. translate(): BABYLON.Vector2;
  79576. private _translatePoint;
  79577. /** Release associated resources */
  79578. dispose(): void;
  79579. }
  79580. }
  79581. declare module BABYLON.GUI {
  79582. /**
  79583. * Class used to create multi line control
  79584. */
  79585. export class MultiLine extends Control {
  79586. name?: string | undefined;
  79587. private _lineWidth;
  79588. private _dash;
  79589. private _points;
  79590. private _minX;
  79591. private _minY;
  79592. private _maxX;
  79593. private _maxY;
  79594. /**
  79595. * Creates a new MultiLine
  79596. * @param name defines the control name
  79597. */
  79598. constructor(name?: string | undefined);
  79599. /** Gets or sets dash pattern */
  79600. get dash(): Array<number>;
  79601. set dash(value: Array<number>);
  79602. /**
  79603. * Gets point stored at specified index
  79604. * @param index defines the index to look for
  79605. * @returns the requested point if found
  79606. */
  79607. getAt(index: number): MultiLinePoint;
  79608. /** Function called when a point is updated */
  79609. onPointUpdate: () => void;
  79610. /**
  79611. * Adds new points to the point collection
  79612. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79613. * @returns the list of created MultiLinePoint
  79614. */
  79615. add(...items: (AbstractMesh | Control | {
  79616. x: string | number;
  79617. y: string | number;
  79618. })[]): MultiLinePoint[];
  79619. /**
  79620. * Adds a new point to the point collection
  79621. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79622. * @returns the created MultiLinePoint
  79623. */
  79624. push(item?: (AbstractMesh | Control | {
  79625. x: string | number;
  79626. y: string | number;
  79627. })): MultiLinePoint;
  79628. /**
  79629. * Remove a specific value or point from the active point collection
  79630. * @param value defines the value or point to remove
  79631. */
  79632. remove(value: number | MultiLinePoint): void;
  79633. /**
  79634. * Resets this object to initial state (no point)
  79635. */
  79636. reset(): void;
  79637. /**
  79638. * Resets all links
  79639. */
  79640. resetLinks(): void;
  79641. /** Gets or sets line width */
  79642. get lineWidth(): number;
  79643. set lineWidth(value: number);
  79644. set horizontalAlignment(value: number);
  79645. set verticalAlignment(value: number);
  79646. protected _getTypeName(): string;
  79647. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79648. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79649. _measure(): void;
  79650. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79651. dispose(): void;
  79652. }
  79653. }
  79654. declare module BABYLON.GUI {
  79655. /**
  79656. * Class used to create radio button controls
  79657. */
  79658. export class RadioButton extends Control {
  79659. name?: string | undefined;
  79660. private _isChecked;
  79661. private _background;
  79662. private _checkSizeRatio;
  79663. private _thickness;
  79664. /** Gets or sets border thickness */
  79665. get thickness(): number;
  79666. set thickness(value: number);
  79667. /** Gets or sets group name */
  79668. group: string;
  79669. /** BABYLON.Observable raised when isChecked is changed */
  79670. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79671. /** Gets or sets a value indicating the ratio between overall size and check size */
  79672. get checkSizeRatio(): number;
  79673. set checkSizeRatio(value: number);
  79674. /** Gets or sets background color */
  79675. get background(): string;
  79676. set background(value: string);
  79677. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79678. get isChecked(): boolean;
  79679. set isChecked(value: boolean);
  79680. /**
  79681. * Creates a new RadioButton
  79682. * @param name defines the control name
  79683. */
  79684. constructor(name?: string | undefined);
  79685. protected _getTypeName(): string;
  79686. _draw(context: CanvasRenderingContext2D): void;
  79687. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79688. /**
  79689. * Utility function to easily create a radio button with a header
  79690. * @param title defines the label to use for the header
  79691. * @param group defines the group to use for the radio button
  79692. * @param isChecked defines the initial state of the radio button
  79693. * @param onValueChanged defines the callback to call when value changes
  79694. * @returns a StackPanel containing the radio button and a textBlock
  79695. */
  79696. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79697. }
  79698. }
  79699. declare module BABYLON.GUI {
  79700. /**
  79701. * Class used to create slider controls
  79702. */
  79703. export class BaseSlider extends Control {
  79704. name?: string | undefined;
  79705. protected _thumbWidth: ValueAndUnit;
  79706. private _minimum;
  79707. private _maximum;
  79708. private _value;
  79709. private _isVertical;
  79710. protected _barOffset: ValueAndUnit;
  79711. private _isThumbClamped;
  79712. protected _displayThumb: boolean;
  79713. private _step;
  79714. private _lastPointerDownID;
  79715. protected _effectiveBarOffset: number;
  79716. protected _renderLeft: number;
  79717. protected _renderTop: number;
  79718. protected _renderWidth: number;
  79719. protected _renderHeight: number;
  79720. protected _backgroundBoxLength: number;
  79721. protected _backgroundBoxThickness: number;
  79722. protected _effectiveThumbThickness: number;
  79723. /** BABYLON.Observable raised when the sldier value changes */
  79724. onValueChangedObservable: BABYLON.Observable<number>;
  79725. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79726. get displayThumb(): boolean;
  79727. set displayThumb(value: boolean);
  79728. /** Gets or sets a step to apply to values (0 by default) */
  79729. get step(): number;
  79730. set step(value: number);
  79731. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79732. get barOffset(): string | number;
  79733. /** Gets main bar offset in pixels*/
  79734. get barOffsetInPixels(): number;
  79735. set barOffset(value: string | number);
  79736. /** Gets or sets thumb width */
  79737. get thumbWidth(): string | number;
  79738. /** Gets thumb width in pixels */
  79739. get thumbWidthInPixels(): number;
  79740. set thumbWidth(value: string | number);
  79741. /** Gets or sets minimum value */
  79742. get minimum(): number;
  79743. set minimum(value: number);
  79744. /** Gets or sets maximum value */
  79745. get maximum(): number;
  79746. set maximum(value: number);
  79747. /** Gets or sets current value */
  79748. get value(): number;
  79749. set value(value: number);
  79750. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79751. get isVertical(): boolean;
  79752. set isVertical(value: boolean);
  79753. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79754. get isThumbClamped(): boolean;
  79755. set isThumbClamped(value: boolean);
  79756. /**
  79757. * Creates a new BaseSlider
  79758. * @param name defines the control name
  79759. */
  79760. constructor(name?: string | undefined);
  79761. protected _getTypeName(): string;
  79762. protected _getThumbPosition(): number;
  79763. protected _getThumbThickness(type: string): number;
  79764. protected _prepareRenderingData(type: string): void;
  79765. private _pointerIsDown;
  79766. /** @hidden */
  79767. protected _updateValueFromPointer(x: number, y: number): void;
  79768. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79769. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79770. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79771. _onCanvasBlur(): void;
  79772. }
  79773. }
  79774. declare module BABYLON.GUI {
  79775. /**
  79776. * Class used to create slider controls
  79777. */
  79778. export class Slider extends BaseSlider {
  79779. name?: string | undefined;
  79780. private _background;
  79781. private _borderColor;
  79782. private _thumbColor;
  79783. private _isThumbCircle;
  79784. protected _displayValueBar: boolean;
  79785. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79786. get displayValueBar(): boolean;
  79787. set displayValueBar(value: boolean);
  79788. /** Gets or sets border color */
  79789. get borderColor(): string;
  79790. set borderColor(value: string);
  79791. /** Gets or sets background color */
  79792. get background(): string;
  79793. set background(value: string);
  79794. /** Gets or sets thumb's color */
  79795. get thumbColor(): string;
  79796. set thumbColor(value: string);
  79797. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79798. get isThumbCircle(): boolean;
  79799. set isThumbCircle(value: boolean);
  79800. /**
  79801. * Creates a new Slider
  79802. * @param name defines the control name
  79803. */
  79804. constructor(name?: string | undefined);
  79805. protected _getTypeName(): string;
  79806. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79807. }
  79808. }
  79809. declare module BABYLON.GUI {
  79810. /** Class used to create a RadioGroup
  79811. * which contains groups of radio buttons
  79812. */
  79813. export class SelectorGroup {
  79814. /** name of SelectorGroup */
  79815. name: string;
  79816. private _groupPanel;
  79817. private _selectors;
  79818. private _groupHeader;
  79819. /**
  79820. * Creates a new SelectorGroup
  79821. * @param name of group, used as a group heading
  79822. */
  79823. constructor(
  79824. /** name of SelectorGroup */
  79825. name: string);
  79826. /** Gets the groupPanel of the SelectorGroup */
  79827. get groupPanel(): StackPanel;
  79828. /** Gets the selectors array */
  79829. get selectors(): StackPanel[];
  79830. /** Gets and sets the group header */
  79831. get header(): string;
  79832. set header(label: string);
  79833. /** @hidden */
  79834. private _addGroupHeader;
  79835. /** @hidden*/
  79836. _getSelector(selectorNb: number): StackPanel | undefined;
  79837. /** Removes the selector at the given position
  79838. * @param selectorNb the position of the selector within the group
  79839. */
  79840. removeSelector(selectorNb: number): void;
  79841. }
  79842. /** Class used to create a CheckboxGroup
  79843. * which contains groups of checkbox buttons
  79844. */
  79845. export class CheckboxGroup extends SelectorGroup {
  79846. /** Adds a checkbox as a control
  79847. * @param text is the label for the selector
  79848. * @param func is the function called when the Selector is checked
  79849. * @param checked is true when Selector is checked
  79850. */
  79851. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79852. /** @hidden */
  79853. _setSelectorLabel(selectorNb: number, label: string): void;
  79854. /** @hidden */
  79855. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79856. /** @hidden */
  79857. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79858. /** @hidden */
  79859. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79860. }
  79861. /** Class used to create a RadioGroup
  79862. * which contains groups of radio buttons
  79863. */
  79864. export class RadioGroup extends SelectorGroup {
  79865. private _selectNb;
  79866. /** Adds a radio button as a control
  79867. * @param label is the label for the selector
  79868. * @param func is the function called when the Selector is checked
  79869. * @param checked is true when Selector is checked
  79870. */
  79871. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79872. /** @hidden */
  79873. _setSelectorLabel(selectorNb: number, label: string): void;
  79874. /** @hidden */
  79875. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79876. /** @hidden */
  79877. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79878. /** @hidden */
  79879. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79880. }
  79881. /** Class used to create a SliderGroup
  79882. * which contains groups of slider buttons
  79883. */
  79884. export class SliderGroup extends SelectorGroup {
  79885. /**
  79886. * Adds a slider to the SelectorGroup
  79887. * @param label is the label for the SliderBar
  79888. * @param func is the function called when the Slider moves
  79889. * @param unit is a string describing the units used, eg degrees or metres
  79890. * @param min is the minimum value for the Slider
  79891. * @param max is the maximum value for the Slider
  79892. * @param value is the start value for the Slider between min and max
  79893. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79894. */
  79895. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79896. /** @hidden */
  79897. _setSelectorLabel(selectorNb: number, label: string): void;
  79898. /** @hidden */
  79899. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79900. /** @hidden */
  79901. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79902. /** @hidden */
  79903. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79904. }
  79905. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79906. * @see https://doc.babylonjs.com/how_to/selector
  79907. */
  79908. export class SelectionPanel extends Rectangle {
  79909. /** name of SelectionPanel */
  79910. name: string;
  79911. /** an array of SelectionGroups */
  79912. groups: SelectorGroup[];
  79913. private _panel;
  79914. private _buttonColor;
  79915. private _buttonBackground;
  79916. private _headerColor;
  79917. private _barColor;
  79918. private _barHeight;
  79919. private _spacerHeight;
  79920. private _labelColor;
  79921. private _groups;
  79922. private _bars;
  79923. /**
  79924. * Creates a new SelectionPanel
  79925. * @param name of SelectionPanel
  79926. * @param groups is an array of SelectionGroups
  79927. */
  79928. constructor(
  79929. /** name of SelectionPanel */
  79930. name: string,
  79931. /** an array of SelectionGroups */
  79932. groups?: SelectorGroup[]);
  79933. protected _getTypeName(): string;
  79934. /** Gets the (stack) panel of the SelectionPanel */
  79935. get panel(): StackPanel;
  79936. /** Gets or sets the headerColor */
  79937. get headerColor(): string;
  79938. set headerColor(color: string);
  79939. private _setHeaderColor;
  79940. /** Gets or sets the button color */
  79941. get buttonColor(): string;
  79942. set buttonColor(color: string);
  79943. private _setbuttonColor;
  79944. /** Gets or sets the label color */
  79945. get labelColor(): string;
  79946. set labelColor(color: string);
  79947. private _setLabelColor;
  79948. /** Gets or sets the button background */
  79949. get buttonBackground(): string;
  79950. set buttonBackground(color: string);
  79951. private _setButtonBackground;
  79952. /** Gets or sets the color of separator bar */
  79953. get barColor(): string;
  79954. set barColor(color: string);
  79955. private _setBarColor;
  79956. /** Gets or sets the height of separator bar */
  79957. get barHeight(): string;
  79958. set barHeight(value: string);
  79959. private _setBarHeight;
  79960. /** Gets or sets the height of spacers*/
  79961. get spacerHeight(): string;
  79962. set spacerHeight(value: string);
  79963. private _setSpacerHeight;
  79964. /** Adds a bar between groups */
  79965. private _addSpacer;
  79966. /** Add a group to the selection panel
  79967. * @param group is the selector group to add
  79968. */
  79969. addGroup(group: SelectorGroup): void;
  79970. /** Remove the group from the given position
  79971. * @param groupNb is the position of the group in the list
  79972. */
  79973. removeGroup(groupNb: number): void;
  79974. /** Change a group header label
  79975. * @param label is the new group header label
  79976. * @param groupNb is the number of the group to relabel
  79977. * */
  79978. setHeaderName(label: string, groupNb: number): void;
  79979. /** Change selector label to the one given
  79980. * @param label is the new selector label
  79981. * @param groupNb is the number of the groupcontaining the selector
  79982. * @param selectorNb is the number of the selector within a group to relabel
  79983. * */
  79984. relabel(label: string, groupNb: number, selectorNb: number): void;
  79985. /** For a given group position remove the selector at the given position
  79986. * @param groupNb is the number of the group to remove the selector from
  79987. * @param selectorNb is the number of the selector within the group
  79988. */
  79989. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79990. /** For a given group position of correct type add a checkbox button
  79991. * @param groupNb is the number of the group to remove the selector from
  79992. * @param label is the label for the selector
  79993. * @param func is the function called when the Selector is checked
  79994. * @param checked is true when Selector is checked
  79995. */
  79996. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79997. /** For a given group position of correct type add a radio button
  79998. * @param groupNb is the number of the group to remove the selector from
  79999. * @param label is the label for the selector
  80000. * @param func is the function called when the Selector is checked
  80001. * @param checked is true when Selector is checked
  80002. */
  80003. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80004. /**
  80005. * For a given slider group add a slider
  80006. * @param groupNb is the number of the group to add the slider to
  80007. * @param label is the label for the Slider
  80008. * @param func is the function called when the Slider moves
  80009. * @param unit is a string describing the units used, eg degrees or metres
  80010. * @param min is the minimum value for the Slider
  80011. * @param max is the maximum value for the Slider
  80012. * @param value is the start value for the Slider between min and max
  80013. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80014. */
  80015. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80016. }
  80017. }
  80018. declare module BABYLON.GUI {
  80019. /**
  80020. * Class used to hold a the container for ScrollViewer
  80021. * @hidden
  80022. */
  80023. export class _ScrollViewerWindow extends Container {
  80024. parentClientWidth: number;
  80025. parentClientHeight: number;
  80026. private _freezeControls;
  80027. private _parentMeasure;
  80028. private _oldLeft;
  80029. private _oldTop;
  80030. get freezeControls(): boolean;
  80031. set freezeControls(value: boolean);
  80032. private _bucketWidth;
  80033. private _bucketHeight;
  80034. private _buckets;
  80035. private _bucketLen;
  80036. get bucketWidth(): number;
  80037. get bucketHeight(): number;
  80038. setBucketSizes(width: number, height: number): void;
  80039. private _useBuckets;
  80040. private _makeBuckets;
  80041. private _dispatchInBuckets;
  80042. private _updateMeasures;
  80043. private _updateChildrenMeasures;
  80044. private _restoreMeasures;
  80045. /**
  80046. * Creates a new ScrollViewerWindow
  80047. * @param name of ScrollViewerWindow
  80048. */
  80049. constructor(name?: string);
  80050. protected _getTypeName(): string;
  80051. /** @hidden */
  80052. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80053. /** @hidden */
  80054. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80055. private _scrollChildren;
  80056. private _scrollChildrenWithBuckets;
  80057. /** @hidden */
  80058. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80059. protected _postMeasure(): void;
  80060. }
  80061. }
  80062. declare module BABYLON.GUI {
  80063. /**
  80064. * Class used to create slider controls
  80065. */
  80066. export class ScrollBar extends BaseSlider {
  80067. name?: string | undefined;
  80068. private _background;
  80069. private _borderColor;
  80070. private _tempMeasure;
  80071. /** Gets or sets border color */
  80072. get borderColor(): string;
  80073. set borderColor(value: string);
  80074. /** Gets or sets background color */
  80075. get background(): string;
  80076. set background(value: string);
  80077. /**
  80078. * Creates a new Slider
  80079. * @param name defines the control name
  80080. */
  80081. constructor(name?: string | undefined);
  80082. protected _getTypeName(): string;
  80083. protected _getThumbThickness(): number;
  80084. _draw(context: CanvasRenderingContext2D): void;
  80085. private _first;
  80086. private _originX;
  80087. private _originY;
  80088. /** @hidden */
  80089. protected _updateValueFromPointer(x: number, y: number): void;
  80090. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80091. }
  80092. }
  80093. declare module BABYLON.GUI {
  80094. /**
  80095. * Class used to create slider controls
  80096. */
  80097. export class ImageScrollBar extends BaseSlider {
  80098. name?: string | undefined;
  80099. private _backgroundBaseImage;
  80100. private _backgroundImage;
  80101. private _thumbImage;
  80102. private _thumbBaseImage;
  80103. private _thumbLength;
  80104. private _thumbHeight;
  80105. private _barImageHeight;
  80106. private _tempMeasure;
  80107. /** Number of 90° rotation to apply on the images when in vertical mode */
  80108. num90RotationInVerticalMode: number;
  80109. /**
  80110. * Gets or sets the image used to render the background for horizontal bar
  80111. */
  80112. get backgroundImage(): Image;
  80113. set backgroundImage(value: Image);
  80114. /**
  80115. * Gets or sets the image used to render the thumb
  80116. */
  80117. get thumbImage(): Image;
  80118. set thumbImage(value: Image);
  80119. /**
  80120. * Gets or sets the length of the thumb
  80121. */
  80122. get thumbLength(): number;
  80123. set thumbLength(value: number);
  80124. /**
  80125. * Gets or sets the height of the thumb
  80126. */
  80127. get thumbHeight(): number;
  80128. set thumbHeight(value: number);
  80129. /**
  80130. * Gets or sets the height of the bar image
  80131. */
  80132. get barImageHeight(): number;
  80133. set barImageHeight(value: number);
  80134. /**
  80135. * Creates a new ImageScrollBar
  80136. * @param name defines the control name
  80137. */
  80138. constructor(name?: string | undefined);
  80139. protected _getTypeName(): string;
  80140. protected _getThumbThickness(): number;
  80141. _draw(context: CanvasRenderingContext2D): void;
  80142. private _first;
  80143. private _originX;
  80144. private _originY;
  80145. /** @hidden */
  80146. protected _updateValueFromPointer(x: number, y: number): void;
  80147. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80148. }
  80149. }
  80150. declare module BABYLON.GUI {
  80151. /**
  80152. * Class used to hold a viewer window and sliders in a grid
  80153. */
  80154. export class ScrollViewer extends Rectangle {
  80155. private _grid;
  80156. private _horizontalBarSpace;
  80157. private _verticalBarSpace;
  80158. private _dragSpace;
  80159. private _horizontalBar;
  80160. private _verticalBar;
  80161. private _barColor;
  80162. private _barBackground;
  80163. private _barImage;
  80164. private _horizontalBarImage;
  80165. private _verticalBarImage;
  80166. private _barBackgroundImage;
  80167. private _horizontalBarBackgroundImage;
  80168. private _verticalBarBackgroundImage;
  80169. private _barSize;
  80170. private _window;
  80171. private _pointerIsOver;
  80172. private _wheelPrecision;
  80173. private _onWheelObserver;
  80174. private _clientWidth;
  80175. private _clientHeight;
  80176. private _useImageBar;
  80177. private _thumbLength;
  80178. private _thumbHeight;
  80179. private _barImageHeight;
  80180. private _horizontalBarImageHeight;
  80181. private _verticalBarImageHeight;
  80182. private _oldWindowContentsWidth;
  80183. private _oldWindowContentsHeight;
  80184. /**
  80185. * Gets the horizontal scrollbar
  80186. */
  80187. get horizontalBar(): ScrollBar | ImageScrollBar;
  80188. /**
  80189. * Gets the vertical scrollbar
  80190. */
  80191. get verticalBar(): ScrollBar | ImageScrollBar;
  80192. /**
  80193. * Adds a new control to the current container
  80194. * @param control defines the control to add
  80195. * @returns the current container
  80196. */
  80197. addControl(control: BABYLON.Nullable<Control>): Container;
  80198. /**
  80199. * Removes a control from the current container
  80200. * @param control defines the control to remove
  80201. * @returns the current container
  80202. */
  80203. removeControl(control: Control): Container;
  80204. /** Gets the list of children */
  80205. get children(): Control[];
  80206. _flagDescendantsAsMatrixDirty(): void;
  80207. /**
  80208. * Freezes or unfreezes the controls in the window.
  80209. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80210. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80211. */
  80212. get freezeControls(): boolean;
  80213. set freezeControls(value: boolean);
  80214. /** Gets the bucket width */
  80215. get bucketWidth(): number;
  80216. /** Gets the bucket height */
  80217. get bucketHeight(): number;
  80218. /**
  80219. * Sets the bucket sizes.
  80220. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80221. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80222. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80223. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80224. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80225. * used), that's why it is not enabled by default.
  80226. * @param width width of the bucket
  80227. * @param height height of the bucket
  80228. */
  80229. setBucketSizes(width: number, height: number): void;
  80230. private _forceHorizontalBar;
  80231. private _forceVerticalBar;
  80232. /**
  80233. * Forces the horizontal scroll bar to be displayed
  80234. */
  80235. get forceHorizontalBar(): boolean;
  80236. set forceHorizontalBar(value: boolean);
  80237. /**
  80238. * Forces the vertical scroll bar to be displayed
  80239. */
  80240. get forceVerticalBar(): boolean;
  80241. set forceVerticalBar(value: boolean);
  80242. /**
  80243. * Creates a new ScrollViewer
  80244. * @param name of ScrollViewer
  80245. */
  80246. constructor(name?: string, isImageBased?: boolean);
  80247. /** Reset the scroll viewer window to initial size */
  80248. resetWindow(): void;
  80249. protected _getTypeName(): string;
  80250. private _buildClientSizes;
  80251. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80252. protected _postMeasure(): void;
  80253. /**
  80254. * Gets or sets the mouse wheel precision
  80255. * from 0 to 1 with a default value of 0.05
  80256. * */
  80257. get wheelPrecision(): number;
  80258. set wheelPrecision(value: number);
  80259. /** Gets or sets the scroll bar container background color */
  80260. get scrollBackground(): string;
  80261. set scrollBackground(color: string);
  80262. /** Gets or sets the bar color */
  80263. get barColor(): string;
  80264. set barColor(color: string);
  80265. /** Gets or sets the bar image */
  80266. get thumbImage(): Image;
  80267. set thumbImage(value: Image);
  80268. /** Gets or sets the horizontal bar image */
  80269. get horizontalThumbImage(): Image;
  80270. set horizontalThumbImage(value: Image);
  80271. /** Gets or sets the vertical bar image */
  80272. get verticalThumbImage(): Image;
  80273. set verticalThumbImage(value: Image);
  80274. /** Gets or sets the size of the bar */
  80275. get barSize(): number;
  80276. set barSize(value: number);
  80277. /** Gets or sets the length of the thumb */
  80278. get thumbLength(): number;
  80279. set thumbLength(value: number);
  80280. /** Gets or sets the height of the thumb */
  80281. get thumbHeight(): number;
  80282. set thumbHeight(value: number);
  80283. /** Gets or sets the height of the bar image */
  80284. get barImageHeight(): number;
  80285. set barImageHeight(value: number);
  80286. /** Gets or sets the height of the horizontal bar image */
  80287. get horizontalBarImageHeight(): number;
  80288. set horizontalBarImageHeight(value: number);
  80289. /** Gets or sets the height of the vertical bar image */
  80290. get verticalBarImageHeight(): number;
  80291. set verticalBarImageHeight(value: number);
  80292. /** Gets or sets the bar background */
  80293. get barBackground(): string;
  80294. set barBackground(color: string);
  80295. /** Gets or sets the bar background image */
  80296. get barImage(): Image;
  80297. set barImage(value: Image);
  80298. /** Gets or sets the horizontal bar background image */
  80299. get horizontalBarImage(): Image;
  80300. set horizontalBarImage(value: Image);
  80301. /** Gets or sets the vertical bar background image */
  80302. get verticalBarImage(): Image;
  80303. set verticalBarImage(value: Image);
  80304. private _setWindowPosition;
  80305. /** @hidden */
  80306. private _updateScroller;
  80307. _link(host: AdvancedDynamicTexture): void;
  80308. /** @hidden */
  80309. private _addBar;
  80310. /** @hidden */
  80311. private _attachWheel;
  80312. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80313. /** Releases associated resources */
  80314. dispose(): void;
  80315. }
  80316. }
  80317. declare module BABYLON.GUI {
  80318. /** Class used to render a grid */
  80319. export class DisplayGrid extends Control {
  80320. name?: string | undefined;
  80321. private _cellWidth;
  80322. private _cellHeight;
  80323. private _minorLineTickness;
  80324. private _minorLineColor;
  80325. private _majorLineTickness;
  80326. private _majorLineColor;
  80327. private _majorLineFrequency;
  80328. private _background;
  80329. private _displayMajorLines;
  80330. private _displayMinorLines;
  80331. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80332. get displayMinorLines(): boolean;
  80333. set displayMinorLines(value: boolean);
  80334. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80335. get displayMajorLines(): boolean;
  80336. set displayMajorLines(value: boolean);
  80337. /** Gets or sets background color (Black by default) */
  80338. get background(): string;
  80339. set background(value: string);
  80340. /** Gets or sets the width of each cell (20 by default) */
  80341. get cellWidth(): number;
  80342. set cellWidth(value: number);
  80343. /** Gets or sets the height of each cell (20 by default) */
  80344. get cellHeight(): number;
  80345. set cellHeight(value: number);
  80346. /** Gets or sets the tickness of minor lines (1 by default) */
  80347. get minorLineTickness(): number;
  80348. set minorLineTickness(value: number);
  80349. /** Gets or sets the color of minor lines (DarkGray by default) */
  80350. get minorLineColor(): string;
  80351. set minorLineColor(value: string);
  80352. /** Gets or sets the tickness of major lines (2 by default) */
  80353. get majorLineTickness(): number;
  80354. set majorLineTickness(value: number);
  80355. /** Gets or sets the color of major lines (White by default) */
  80356. get majorLineColor(): string;
  80357. set majorLineColor(value: string);
  80358. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80359. get majorLineFrequency(): number;
  80360. set majorLineFrequency(value: number);
  80361. /**
  80362. * Creates a new GridDisplayRectangle
  80363. * @param name defines the control name
  80364. */
  80365. constructor(name?: string | undefined);
  80366. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80367. protected _getTypeName(): string;
  80368. }
  80369. }
  80370. declare module BABYLON.GUI {
  80371. /**
  80372. * Class used to create slider controls based on images
  80373. */
  80374. export class ImageBasedSlider extends BaseSlider {
  80375. name?: string | undefined;
  80376. private _backgroundImage;
  80377. private _thumbImage;
  80378. private _valueBarImage;
  80379. private _tempMeasure;
  80380. get displayThumb(): boolean;
  80381. set displayThumb(value: boolean);
  80382. /**
  80383. * Gets or sets the image used to render the background
  80384. */
  80385. get backgroundImage(): Image;
  80386. set backgroundImage(value: Image);
  80387. /**
  80388. * Gets or sets the image used to render the value bar
  80389. */
  80390. get valueBarImage(): Image;
  80391. set valueBarImage(value: Image);
  80392. /**
  80393. * Gets or sets the image used to render the thumb
  80394. */
  80395. get thumbImage(): Image;
  80396. set thumbImage(value: Image);
  80397. /**
  80398. * Creates a new ImageBasedSlider
  80399. * @param name defines the control name
  80400. */
  80401. constructor(name?: string | undefined);
  80402. protected _getTypeName(): string;
  80403. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80404. }
  80405. }
  80406. declare module BABYLON.GUI {
  80407. /**
  80408. * Forcing an export so that this code will execute
  80409. * @hidden
  80410. */
  80411. const name = "Statics";
  80412. }
  80413. declare module BABYLON.GUI {
  80414. /**
  80415. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80416. */
  80417. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80418. /**
  80419. * Define the instrumented AdvancedDynamicTexture.
  80420. */
  80421. texture: AdvancedDynamicTexture;
  80422. private _captureRenderTime;
  80423. private _renderTime;
  80424. private _captureLayoutTime;
  80425. private _layoutTime;
  80426. private _onBeginRenderObserver;
  80427. private _onEndRenderObserver;
  80428. private _onBeginLayoutObserver;
  80429. private _onEndLayoutObserver;
  80430. /**
  80431. * Gets the perf counter used to capture render time
  80432. */
  80433. get renderTimeCounter(): BABYLON.PerfCounter;
  80434. /**
  80435. * Gets the perf counter used to capture layout time
  80436. */
  80437. get layoutTimeCounter(): BABYLON.PerfCounter;
  80438. /**
  80439. * Enable or disable the render time capture
  80440. */
  80441. get captureRenderTime(): boolean;
  80442. set captureRenderTime(value: boolean);
  80443. /**
  80444. * Enable or disable the layout time capture
  80445. */
  80446. get captureLayoutTime(): boolean;
  80447. set captureLayoutTime(value: boolean);
  80448. /**
  80449. * Instantiates a new advanced dynamic texture instrumentation.
  80450. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80451. * @param texture Defines the AdvancedDynamicTexture to instrument
  80452. */
  80453. constructor(
  80454. /**
  80455. * Define the instrumented AdvancedDynamicTexture.
  80456. */
  80457. texture: AdvancedDynamicTexture);
  80458. /**
  80459. * Dispose and release associated resources.
  80460. */
  80461. dispose(): void;
  80462. }
  80463. }
  80464. declare module BABYLON.GUI {
  80465. /**
  80466. * Class used to load GUI via XML.
  80467. */
  80468. export class XmlLoader {
  80469. private _nodes;
  80470. private _nodeTypes;
  80471. private _isLoaded;
  80472. private _objectAttributes;
  80473. private _parentClass;
  80474. /**
  80475. * Create a new xml loader
  80476. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80477. */
  80478. constructor(parentClass?: null);
  80479. private _getChainElement;
  80480. private _getClassAttribute;
  80481. private _createGuiElement;
  80482. private _parseGrid;
  80483. private _parseElement;
  80484. private _prepareSourceElement;
  80485. private _parseElementsFromSource;
  80486. private _parseXml;
  80487. /**
  80488. * Gets if the loading has finished.
  80489. * @returns whether the loading has finished or not
  80490. */
  80491. isLoaded(): boolean;
  80492. /**
  80493. * Gets a loaded node / control by id.
  80494. * @param id the Controls id set in the xml
  80495. * @returns element of type Control
  80496. */
  80497. getNodeById(id: string): any;
  80498. /**
  80499. * Gets all loaded nodes / controls
  80500. * @returns Array of controls
  80501. */
  80502. getNodes(): any;
  80503. /**
  80504. * Initiates the xml layout loading
  80505. * @param xmlFile defines the xml layout to load
  80506. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80507. * @param callback defines the callback called on layout load.
  80508. */
  80509. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80510. }
  80511. }
  80512. declare module BABYLON.GUI {
  80513. /**
  80514. * Class used to create containers for controls
  80515. */
  80516. export class Container3D extends Control3D {
  80517. private _blockLayout;
  80518. /**
  80519. * Gets the list of child controls
  80520. */
  80521. protected _children: Control3D[];
  80522. /**
  80523. * Gets the list of child controls
  80524. */
  80525. get children(): Array<Control3D>;
  80526. /**
  80527. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80528. * This is helpful to optimize layout operation when adding multiple children in a row
  80529. */
  80530. get blockLayout(): boolean;
  80531. set blockLayout(value: boolean);
  80532. /**
  80533. * Creates a new container
  80534. * @param name defines the container name
  80535. */
  80536. constructor(name?: string);
  80537. /**
  80538. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80539. * @returns the current container
  80540. */
  80541. updateLayout(): Container3D;
  80542. /**
  80543. * Gets a boolean indicating if the given control is in the children of this control
  80544. * @param control defines the control to check
  80545. * @returns true if the control is in the child list
  80546. */
  80547. containsControl(control: Control3D): boolean;
  80548. /**
  80549. * Adds a control to the children of this control
  80550. * @param control defines the control to add
  80551. * @returns the current container
  80552. */
  80553. addControl(control: Control3D): Container3D;
  80554. /**
  80555. * This function will be called everytime a new control is added
  80556. */
  80557. protected _arrangeChildren(): void;
  80558. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80559. /**
  80560. * Removes a control from the children of this control
  80561. * @param control defines the control to remove
  80562. * @returns the current container
  80563. */
  80564. removeControl(control: Control3D): Container3D;
  80565. protected _getTypeName(): string;
  80566. /**
  80567. * Releases all associated resources
  80568. */
  80569. dispose(): void;
  80570. /** Control rotation will remain unchanged */
  80571. static readonly UNSET_ORIENTATION: number;
  80572. /** Control will rotate to make it look at sphere central axis */
  80573. static readonly FACEORIGIN_ORIENTATION: number;
  80574. /** Control will rotate to make it look back at sphere central axis */
  80575. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80576. /** Control will rotate to look at z axis (0, 0, 1) */
  80577. static readonly FACEFORWARD_ORIENTATION: number;
  80578. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80579. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80580. }
  80581. }
  80582. declare module BABYLON.GUI {
  80583. /**
  80584. * Class used to manage 3D user interface
  80585. * @see https://doc.babylonjs.com/how_to/gui3d
  80586. */
  80587. export class GUI3DManager implements BABYLON.IDisposable {
  80588. private _scene;
  80589. private _sceneDisposeObserver;
  80590. private _utilityLayer;
  80591. private _rootContainer;
  80592. private _pointerObserver;
  80593. private _pointerOutObserver;
  80594. /** @hidden */
  80595. _lastPickedControl: Control3D;
  80596. /** @hidden */
  80597. _lastControlOver: {
  80598. [pointerId: number]: Control3D;
  80599. };
  80600. /** @hidden */
  80601. _lastControlDown: {
  80602. [pointerId: number]: Control3D;
  80603. };
  80604. /**
  80605. * BABYLON.Observable raised when the point picked by the pointer events changed
  80606. */
  80607. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80608. /** @hidden */
  80609. _sharedMaterials: {
  80610. [key: string]: BABYLON.Material;
  80611. };
  80612. /** Gets the hosting scene */
  80613. get scene(): BABYLON.Scene;
  80614. /** Gets associated utility layer */
  80615. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80616. /**
  80617. * Creates a new GUI3DManager
  80618. * @param scene
  80619. */
  80620. constructor(scene?: BABYLON.Scene);
  80621. private _handlePointerOut;
  80622. private _doPicking;
  80623. /**
  80624. * Gets the root container
  80625. */
  80626. get rootContainer(): Container3D;
  80627. /**
  80628. * Gets a boolean indicating if the given control is in the root child list
  80629. * @param control defines the control to check
  80630. * @returns true if the control is in the root child list
  80631. */
  80632. containsControl(control: Control3D): boolean;
  80633. /**
  80634. * Adds a control to the root child list
  80635. * @param control defines the control to add
  80636. * @returns the current manager
  80637. */
  80638. addControl(control: Control3D): GUI3DManager;
  80639. /**
  80640. * Removes a control from the root child list
  80641. * @param control defines the control to remove
  80642. * @returns the current container
  80643. */
  80644. removeControl(control: Control3D): GUI3DManager;
  80645. /**
  80646. * Releases all associated resources
  80647. */
  80648. dispose(): void;
  80649. }
  80650. }
  80651. declare module BABYLON.GUI {
  80652. /**
  80653. * Class used to transport BABYLON.Vector3 information for pointer events
  80654. */
  80655. export class Vector3WithInfo extends BABYLON.Vector3 {
  80656. /** defines the current mouse button index */
  80657. buttonIndex: number;
  80658. /**
  80659. * Creates a new Vector3WithInfo
  80660. * @param source defines the vector3 data to transport
  80661. * @param buttonIndex defines the current mouse button index
  80662. */
  80663. constructor(source: BABYLON.Vector3,
  80664. /** defines the current mouse button index */
  80665. buttonIndex?: number);
  80666. }
  80667. }
  80668. declare module BABYLON.GUI {
  80669. /**
  80670. * Class used as base class for controls
  80671. */
  80672. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80673. /** Defines the control name */
  80674. name?: string | undefined;
  80675. /** @hidden */
  80676. _host: GUI3DManager;
  80677. private _node;
  80678. private _downCount;
  80679. private _enterCount;
  80680. private _downPointerIds;
  80681. private _isVisible;
  80682. /** Gets or sets the control position in world space */
  80683. get position(): BABYLON.Vector3;
  80684. set position(value: BABYLON.Vector3);
  80685. /** Gets or sets the control scaling in world space */
  80686. get scaling(): BABYLON.Vector3;
  80687. set scaling(value: BABYLON.Vector3);
  80688. /** Callback used to start pointer enter animation */
  80689. pointerEnterAnimation: () => void;
  80690. /** Callback used to start pointer out animation */
  80691. pointerOutAnimation: () => void;
  80692. /** Callback used to start pointer down animation */
  80693. pointerDownAnimation: () => void;
  80694. /** Callback used to start pointer up animation */
  80695. pointerUpAnimation: () => void;
  80696. /**
  80697. * An event triggered when the pointer move over the control
  80698. */
  80699. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80700. /**
  80701. * An event triggered when the pointer move out of the control
  80702. */
  80703. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80704. /**
  80705. * An event triggered when the pointer taps the control
  80706. */
  80707. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80708. /**
  80709. * An event triggered when pointer is up
  80710. */
  80711. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80712. /**
  80713. * An event triggered when a control is clicked on (with a mouse)
  80714. */
  80715. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80716. /**
  80717. * An event triggered when pointer enters the control
  80718. */
  80719. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80720. /**
  80721. * Gets or sets the parent container
  80722. */
  80723. parent: BABYLON.Nullable<Container3D>;
  80724. private _behaviors;
  80725. /**
  80726. * Gets the list of attached behaviors
  80727. * @see https://doc.babylonjs.com/features/behaviour
  80728. */
  80729. get behaviors(): BABYLON.Behavior<Control3D>[];
  80730. /**
  80731. * Attach a behavior to the control
  80732. * @see https://doc.babylonjs.com/features/behaviour
  80733. * @param behavior defines the behavior to attach
  80734. * @returns the current control
  80735. */
  80736. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80737. /**
  80738. * Remove an attached behavior
  80739. * @see https://doc.babylonjs.com/features/behaviour
  80740. * @param behavior defines the behavior to attach
  80741. * @returns the current control
  80742. */
  80743. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80744. /**
  80745. * Gets an attached behavior by name
  80746. * @param name defines the name of the behavior to look for
  80747. * @see https://doc.babylonjs.com/features/behaviour
  80748. * @returns null if behavior was not found else the requested behavior
  80749. */
  80750. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80751. /** Gets or sets a boolean indicating if the control is visible */
  80752. get isVisible(): boolean;
  80753. set isVisible(value: boolean);
  80754. /**
  80755. * Creates a new control
  80756. * @param name defines the control name
  80757. */
  80758. constructor(
  80759. /** Defines the control name */
  80760. name?: string | undefined);
  80761. /**
  80762. * Gets a string representing the class name
  80763. */
  80764. get typeName(): string;
  80765. /**
  80766. * Get the current class name of the control.
  80767. * @returns current class name
  80768. */
  80769. getClassName(): string;
  80770. protected _getTypeName(): string;
  80771. /**
  80772. * Gets the transform node used by this control
  80773. */
  80774. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80775. /**
  80776. * Gets the mesh used to render this control
  80777. */
  80778. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80779. /**
  80780. * Link the control as child of the given node
  80781. * @param node defines the node to link to. Use null to unlink the control
  80782. * @returns the current control
  80783. */
  80784. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80785. /** @hidden **/
  80786. _prepareNode(scene: BABYLON.Scene): void;
  80787. /**
  80788. * Node creation.
  80789. * Can be overriden by children
  80790. * @param scene defines the scene where the node must be attached
  80791. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80792. */
  80793. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80794. /**
  80795. * Affect a material to the given mesh
  80796. * @param mesh defines the mesh which will represent the control
  80797. */
  80798. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80799. /** @hidden */
  80800. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80801. /** @hidden */
  80802. _onPointerEnter(target: Control3D): boolean;
  80803. /** @hidden */
  80804. _onPointerOut(target: Control3D): void;
  80805. /** @hidden */
  80806. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80807. /** @hidden */
  80808. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80809. /** @hidden */
  80810. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80811. /** @hidden */
  80812. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80813. /** @hidden */
  80814. _disposeNode(): void;
  80815. /**
  80816. * Releases all associated resources
  80817. */
  80818. dispose(): void;
  80819. }
  80820. }
  80821. declare module BABYLON.GUI {
  80822. /**
  80823. * Class used as a root to all buttons
  80824. */
  80825. export class AbstractButton3D extends Control3D {
  80826. /**
  80827. * Creates a new button
  80828. * @param name defines the control name
  80829. */
  80830. constructor(name?: string);
  80831. protected _getTypeName(): string;
  80832. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80833. }
  80834. }
  80835. declare module BABYLON.GUI {
  80836. /**
  80837. * Class used to create a button in 3D
  80838. */
  80839. export class Button3D extends AbstractButton3D {
  80840. /** @hidden */
  80841. protected _currentMaterial: BABYLON.Material;
  80842. private _facadeTexture;
  80843. private _content;
  80844. private _contentResolution;
  80845. private _contentScaleRatio;
  80846. /**
  80847. * Gets or sets the texture resolution used to render content (512 by default)
  80848. */
  80849. get contentResolution(): BABYLON.int;
  80850. set contentResolution(value: BABYLON.int);
  80851. /**
  80852. * Gets or sets the texture scale ratio used to render content (2 by default)
  80853. */
  80854. get contentScaleRatio(): number;
  80855. set contentScaleRatio(value: number);
  80856. protected _disposeFacadeTexture(): void;
  80857. protected _resetContent(): void;
  80858. /**
  80859. * Creates a new button
  80860. * @param name defines the control name
  80861. */
  80862. constructor(name?: string);
  80863. /**
  80864. * Gets or sets the GUI 2D content used to display the button's facade
  80865. */
  80866. get content(): Control;
  80867. set content(value: Control);
  80868. /**
  80869. * Apply the facade texture (created from the content property).
  80870. * This function can be overloaded by child classes
  80871. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80872. */
  80873. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80874. protected _getTypeName(): string;
  80875. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80876. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80877. /**
  80878. * Releases all associated resources
  80879. */
  80880. dispose(): void;
  80881. }
  80882. }
  80883. declare module BABYLON.GUI {
  80884. /**
  80885. * Abstract class used to create a container panel deployed on the surface of a volume
  80886. */
  80887. export abstract class VolumeBasedPanel extends Container3D {
  80888. private _columns;
  80889. private _rows;
  80890. private _rowThenColum;
  80891. private _orientation;
  80892. protected _cellWidth: number;
  80893. protected _cellHeight: number;
  80894. /**
  80895. * Gets or sets the distance between elements
  80896. */
  80897. margin: number;
  80898. /**
  80899. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80900. * | Value | Type | Description |
  80901. * | ----- | ----------------------------------- | ----------- |
  80902. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80903. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80904. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80905. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80906. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80907. */
  80908. get orientation(): number;
  80909. set orientation(value: number);
  80910. /**
  80911. * Gets or sets the number of columns requested (10 by default).
  80912. * The panel will automatically compute the number of rows based on number of child controls.
  80913. */
  80914. get columns(): BABYLON.int;
  80915. set columns(value: BABYLON.int);
  80916. /**
  80917. * Gets or sets a the number of rows requested.
  80918. * The panel will automatically compute the number of columns based on number of child controls.
  80919. */
  80920. get rows(): BABYLON.int;
  80921. set rows(value: BABYLON.int);
  80922. /**
  80923. * Creates new VolumeBasedPanel
  80924. */
  80925. constructor();
  80926. protected _arrangeChildren(): void;
  80927. /** Child classes must implement this function to provide correct control positioning */
  80928. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80929. /** Child classes can implement this function to provide additional processing */
  80930. protected _finalProcessing(): void;
  80931. }
  80932. }
  80933. declare module BABYLON.GUI {
  80934. /**
  80935. * Class used to create a container panel deployed on the surface of a cylinder
  80936. */
  80937. export class CylinderPanel extends VolumeBasedPanel {
  80938. private _radius;
  80939. /**
  80940. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80941. */
  80942. get radius(): BABYLON.float;
  80943. set radius(value: BABYLON.float);
  80944. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80945. private _cylindricalMapping;
  80946. }
  80947. }
  80948. declare module BABYLON.GUI {
  80949. /** @hidden */
  80950. export var fluentVertexShader: {
  80951. name: string;
  80952. shader: string;
  80953. };
  80954. }
  80955. declare module BABYLON.GUI {
  80956. /** @hidden */
  80957. export var fluentPixelShader: {
  80958. name: string;
  80959. shader: string;
  80960. };
  80961. }
  80962. declare module BABYLON.GUI {
  80963. /** @hidden */
  80964. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80965. INNERGLOW: boolean;
  80966. BORDER: boolean;
  80967. HOVERLIGHT: boolean;
  80968. TEXTURE: boolean;
  80969. constructor();
  80970. }
  80971. /**
  80972. * Class used to render controls with fluent desgin
  80973. */
  80974. export class FluentMaterial extends BABYLON.PushMaterial {
  80975. /**
  80976. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80977. */
  80978. innerGlowColorIntensity: number;
  80979. /**
  80980. * Gets or sets the inner glow color (white by default)
  80981. */
  80982. innerGlowColor: BABYLON.Color3;
  80983. /**
  80984. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80985. */
  80986. albedoColor: BABYLON.Color3;
  80987. /**
  80988. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80989. */
  80990. renderBorders: boolean;
  80991. /**
  80992. * Gets or sets border width (default is 0.5)
  80993. */
  80994. borderWidth: number;
  80995. /**
  80996. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80997. */
  80998. edgeSmoothingValue: number;
  80999. /**
  81000. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81001. */
  81002. borderMinValue: number;
  81003. /**
  81004. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81005. */
  81006. renderHoverLight: boolean;
  81007. /**
  81008. * Gets or sets the radius used to render the hover light (default is 1.0)
  81009. */
  81010. hoverRadius: number;
  81011. /**
  81012. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81013. */
  81014. hoverColor: BABYLON.Color4;
  81015. /**
  81016. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81017. */
  81018. hoverPosition: BABYLON.Vector3;
  81019. private _albedoTexture;
  81020. /** Gets or sets the texture to use for albedo color */
  81021. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81022. /**
  81023. * Creates a new Fluent material
  81024. * @param name defines the name of the material
  81025. * @param scene defines the hosting scene
  81026. */
  81027. constructor(name: string, scene: BABYLON.Scene);
  81028. needAlphaBlending(): boolean;
  81029. needAlphaTesting(): boolean;
  81030. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81031. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81032. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81033. getActiveTextures(): BABYLON.BaseTexture[];
  81034. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81035. dispose(forceDisposeEffect?: boolean): void;
  81036. clone(name: string): FluentMaterial;
  81037. serialize(): any;
  81038. getClassName(): string;
  81039. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81040. }
  81041. }
  81042. declare module BABYLON.GUI {
  81043. /**
  81044. * Class used to create a holographic button in 3D
  81045. */
  81046. export class HolographicButton extends Button3D {
  81047. private _backPlate;
  81048. private _textPlate;
  81049. private _frontPlate;
  81050. private _text;
  81051. private _imageUrl;
  81052. private _shareMaterials;
  81053. private _frontMaterial;
  81054. private _backMaterial;
  81055. private _plateMaterial;
  81056. private _pickedPointObserver;
  81057. private _tooltipFade;
  81058. private _tooltipTextBlock;
  81059. private _tooltipTexture;
  81060. private _tooltipMesh;
  81061. private _tooltipHoverObserver;
  81062. private _tooltipOutObserver;
  81063. private _disposeTooltip;
  81064. /**
  81065. * Rendering ground id of all the mesh in the button
  81066. */
  81067. set renderingGroupId(id: number);
  81068. get renderingGroupId(): number;
  81069. /**
  81070. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81071. */
  81072. set tooltipText(text: BABYLON.Nullable<string>);
  81073. get tooltipText(): BABYLON.Nullable<string>;
  81074. /**
  81075. * Gets or sets text for the button
  81076. */
  81077. get text(): string;
  81078. set text(value: string);
  81079. /**
  81080. * Gets or sets the image url for the button
  81081. */
  81082. get imageUrl(): string;
  81083. set imageUrl(value: string);
  81084. /**
  81085. * Gets the back material used by this button
  81086. */
  81087. get backMaterial(): FluentMaterial;
  81088. /**
  81089. * Gets the front material used by this button
  81090. */
  81091. get frontMaterial(): FluentMaterial;
  81092. /**
  81093. * Gets the plate material used by this button
  81094. */
  81095. get plateMaterial(): BABYLON.StandardMaterial;
  81096. /**
  81097. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81098. */
  81099. get shareMaterials(): boolean;
  81100. /**
  81101. * Creates a new button
  81102. * @param name defines the control name
  81103. */
  81104. constructor(name?: string, shareMaterials?: boolean);
  81105. protected _getTypeName(): string;
  81106. private _rebuildContent;
  81107. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81108. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81109. private _createBackMaterial;
  81110. private _createFrontMaterial;
  81111. private _createPlateMaterial;
  81112. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81113. /**
  81114. * Releases all associated resources
  81115. */
  81116. dispose(): void;
  81117. }
  81118. }
  81119. declare module BABYLON.GUI {
  81120. /**
  81121. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81122. */
  81123. export class MeshButton3D extends Button3D {
  81124. /** @hidden */
  81125. protected _currentMesh: BABYLON.Mesh;
  81126. /**
  81127. * Creates a new 3D button based on a mesh
  81128. * @param mesh mesh to become a 3D button
  81129. * @param name defines the control name
  81130. */
  81131. constructor(mesh: BABYLON.Mesh, name?: string);
  81132. protected _getTypeName(): string;
  81133. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81134. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81135. }
  81136. }
  81137. declare module BABYLON.GUI {
  81138. /**
  81139. * Class used to create a container panel deployed on the surface of a plane
  81140. */
  81141. export class PlanePanel extends VolumeBasedPanel {
  81142. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81143. }
  81144. }
  81145. declare module BABYLON.GUI {
  81146. /**
  81147. * Class used to create a container panel where items get randomized planar mapping
  81148. */
  81149. export class ScatterPanel extends VolumeBasedPanel {
  81150. private _iteration;
  81151. /**
  81152. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81153. */
  81154. get iteration(): BABYLON.float;
  81155. set iteration(value: BABYLON.float);
  81156. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81157. private _scatterMapping;
  81158. protected _finalProcessing(): void;
  81159. }
  81160. }
  81161. declare module BABYLON.GUI {
  81162. /**
  81163. * Class used to create a container panel deployed on the surface of a sphere
  81164. */
  81165. export class SpherePanel extends VolumeBasedPanel {
  81166. private _radius;
  81167. /**
  81168. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81169. */
  81170. get radius(): BABYLON.float;
  81171. set radius(value: BABYLON.float);
  81172. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81173. private _sphericalMapping;
  81174. }
  81175. }
  81176. declare module BABYLON.GUI {
  81177. /**
  81178. * Class used to create a stack panel in 3D on XY plane
  81179. */
  81180. export class StackPanel3D extends Container3D {
  81181. private _isVertical;
  81182. /**
  81183. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81184. */
  81185. get isVertical(): boolean;
  81186. set isVertical(value: boolean);
  81187. /**
  81188. * Gets or sets the distance between elements
  81189. */
  81190. margin: number;
  81191. /**
  81192. * Creates new StackPanel
  81193. * @param isVertical
  81194. */
  81195. constructor(isVertical?: boolean);
  81196. protected _arrangeChildren(): void;
  81197. }
  81198. }
  81199. declare module BABYLON {
  81200. /**
  81201. * Configuration for glTF validation
  81202. */
  81203. export interface IGLTFValidationConfiguration {
  81204. /**
  81205. * The url of the glTF validator.
  81206. */
  81207. url: string;
  81208. }
  81209. /**
  81210. * glTF validation
  81211. */
  81212. export class GLTFValidation {
  81213. /**
  81214. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81215. */
  81216. static Configuration: IGLTFValidationConfiguration;
  81217. private static _LoadScriptPromise;
  81218. /**
  81219. * Validate a glTF asset using the glTF-Validator.
  81220. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81221. * @param rootUrl The root url for the glTF
  81222. * @param fileName The file name for the glTF
  81223. * @param getExternalResource The callback to get external resources for the glTF validator
  81224. * @returns A promise that resolves with the glTF validation results once complete
  81225. */
  81226. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81227. }
  81228. }
  81229. declare module BABYLON {
  81230. /**
  81231. * Mode that determines the coordinate system to use.
  81232. */
  81233. export enum GLTFLoaderCoordinateSystemMode {
  81234. /**
  81235. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81236. */
  81237. AUTO = 0,
  81238. /**
  81239. * Sets the useRightHandedSystem flag on the scene.
  81240. */
  81241. FORCE_RIGHT_HANDED = 1
  81242. }
  81243. /**
  81244. * Mode that determines what animations will start.
  81245. */
  81246. export enum GLTFLoaderAnimationStartMode {
  81247. /**
  81248. * No animation will start.
  81249. */
  81250. NONE = 0,
  81251. /**
  81252. * The first animation will start.
  81253. */
  81254. FIRST = 1,
  81255. /**
  81256. * All animations will start.
  81257. */
  81258. ALL = 2
  81259. }
  81260. /**
  81261. * Interface that contains the data for the glTF asset.
  81262. */
  81263. export interface IGLTFLoaderData {
  81264. /**
  81265. * The object that represents the glTF JSON.
  81266. */
  81267. json: Object;
  81268. /**
  81269. * The BIN chunk of a binary glTF.
  81270. */
  81271. bin: Nullable<IDataBuffer>;
  81272. }
  81273. /**
  81274. * Interface for extending the loader.
  81275. */
  81276. export interface IGLTFLoaderExtension {
  81277. /**
  81278. * The name of this extension.
  81279. */
  81280. readonly name: string;
  81281. /**
  81282. * Defines whether this extension is enabled.
  81283. */
  81284. enabled: boolean;
  81285. /**
  81286. * Defines the order of this extension.
  81287. * The loader sorts the extensions using these values when loading.
  81288. */
  81289. order?: number;
  81290. }
  81291. /**
  81292. * Loader state.
  81293. */
  81294. export enum GLTFLoaderState {
  81295. /**
  81296. * The asset is loading.
  81297. */
  81298. LOADING = 0,
  81299. /**
  81300. * The asset is ready for rendering.
  81301. */
  81302. READY = 1,
  81303. /**
  81304. * The asset is completely loaded.
  81305. */
  81306. COMPLETE = 2
  81307. }
  81308. /** @hidden */
  81309. export interface IImportMeshAsyncOutput {
  81310. meshes: AbstractMesh[];
  81311. particleSystems: IParticleSystem[];
  81312. skeletons: Skeleton[];
  81313. animationGroups: AnimationGroup[];
  81314. lights: Light[];
  81315. transformNodes: TransformNode[];
  81316. }
  81317. /** @hidden */
  81318. export interface IGLTFLoader extends IDisposable {
  81319. readonly state: Nullable<GLTFLoaderState>;
  81320. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81321. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81322. }
  81323. /**
  81324. * File loader for loading glTF files into a scene.
  81325. */
  81326. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81327. /** @hidden */
  81328. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81329. /** @hidden */
  81330. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81331. /**
  81332. * Raised when the asset has been parsed
  81333. */
  81334. onParsedObservable: Observable<IGLTFLoaderData>;
  81335. private _onParsedObserver;
  81336. /**
  81337. * Raised when the asset has been parsed
  81338. */
  81339. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81340. /**
  81341. * 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.
  81342. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81343. * Defaults to true.
  81344. * @hidden
  81345. */
  81346. static IncrementalLoading: boolean;
  81347. /**
  81348. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81349. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81350. * @hidden
  81351. */
  81352. static HomogeneousCoordinates: boolean;
  81353. /**
  81354. * The coordinate system mode. Defaults to AUTO.
  81355. */
  81356. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81357. /**
  81358. * The animation start mode. Defaults to FIRST.
  81359. */
  81360. animationStartMode: GLTFLoaderAnimationStartMode;
  81361. /**
  81362. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81363. */
  81364. compileMaterials: boolean;
  81365. /**
  81366. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81367. */
  81368. useClipPlane: boolean;
  81369. /**
  81370. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81371. */
  81372. compileShadowGenerators: boolean;
  81373. /**
  81374. * Defines if the Alpha blended materials are only applied as coverage.
  81375. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81376. * If true, no extra effects are applied to transparent pixels.
  81377. */
  81378. transparencyAsCoverage: boolean;
  81379. /**
  81380. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81381. * Enabling will disable offline support and glTF validator.
  81382. * Defaults to false.
  81383. */
  81384. useRangeRequests: boolean;
  81385. /**
  81386. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81387. */
  81388. createInstances: boolean;
  81389. /**
  81390. * 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.
  81391. */
  81392. alwaysComputeBoundingBox: boolean;
  81393. /**
  81394. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81395. */
  81396. loadAllMaterials: boolean;
  81397. /**
  81398. * Function called before loading a url referenced by the asset.
  81399. */
  81400. preprocessUrlAsync: (url: string) => Promise<string>;
  81401. /**
  81402. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81403. * 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, ...)
  81404. */
  81405. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81406. private _onMeshLoadedObserver;
  81407. /**
  81408. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81409. * 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, ...)
  81410. */
  81411. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81412. /**
  81413. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81414. */
  81415. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81416. private _onTextureLoadedObserver;
  81417. /**
  81418. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81419. */
  81420. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81421. /**
  81422. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81423. */
  81424. readonly onMaterialLoadedObservable: Observable<Material>;
  81425. private _onMaterialLoadedObserver;
  81426. /**
  81427. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81428. */
  81429. set onMaterialLoaded(callback: (material: Material) => void);
  81430. /**
  81431. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81432. */
  81433. readonly onCameraLoadedObservable: Observable<Camera>;
  81434. private _onCameraLoadedObserver;
  81435. /**
  81436. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81437. */
  81438. set onCameraLoaded(callback: (camera: Camera) => void);
  81439. /**
  81440. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81441. * For assets with LODs, raised when all of the LODs are complete.
  81442. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81443. */
  81444. readonly onCompleteObservable: Observable<void>;
  81445. private _onCompleteObserver;
  81446. /**
  81447. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81448. * For assets with LODs, raised when all of the LODs are complete.
  81449. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81450. */
  81451. set onComplete(callback: () => void);
  81452. /**
  81453. * Observable raised when an error occurs.
  81454. */
  81455. readonly onErrorObservable: Observable<any>;
  81456. private _onErrorObserver;
  81457. /**
  81458. * Callback raised when an error occurs.
  81459. */
  81460. set onError(callback: (reason: any) => void);
  81461. /**
  81462. * Observable raised after the loader is disposed.
  81463. */
  81464. readonly onDisposeObservable: Observable<void>;
  81465. private _onDisposeObserver;
  81466. /**
  81467. * Callback raised after the loader is disposed.
  81468. */
  81469. set onDispose(callback: () => void);
  81470. /**
  81471. * Observable raised after a loader extension is created.
  81472. * Set additional options for a loader extension in this event.
  81473. */
  81474. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81475. private _onExtensionLoadedObserver;
  81476. /**
  81477. * Callback raised after a loader extension is created.
  81478. */
  81479. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81480. /**
  81481. * Defines if the loader logging is enabled.
  81482. */
  81483. get loggingEnabled(): boolean;
  81484. set loggingEnabled(value: boolean);
  81485. /**
  81486. * Defines if the loader should capture performance counters.
  81487. */
  81488. get capturePerformanceCounters(): boolean;
  81489. set capturePerformanceCounters(value: boolean);
  81490. /**
  81491. * Defines if the loader should validate the asset.
  81492. */
  81493. validate: boolean;
  81494. /**
  81495. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81496. */
  81497. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81498. private _onValidatedObserver;
  81499. /**
  81500. * Callback raised after a loader extension is created.
  81501. */
  81502. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81503. private _loader;
  81504. private _progressCallback?;
  81505. private _requests;
  81506. private static magicBase64Encoded;
  81507. /**
  81508. * Name of the loader ("gltf")
  81509. */
  81510. name: string;
  81511. /** @hidden */
  81512. extensions: ISceneLoaderPluginExtensions;
  81513. /**
  81514. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81515. */
  81516. dispose(): void;
  81517. /** @hidden */
  81518. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81519. /** @hidden */
  81520. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81521. /** @hidden */
  81522. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81523. meshes: AbstractMesh[];
  81524. particleSystems: IParticleSystem[];
  81525. skeletons: Skeleton[];
  81526. animationGroups: AnimationGroup[];
  81527. }>;
  81528. /** @hidden */
  81529. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81530. /** @hidden */
  81531. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81532. /** @hidden */
  81533. canDirectLoad(data: string): boolean;
  81534. /** @hidden */
  81535. directLoad(scene: Scene, data: string): Promise<any>;
  81536. /**
  81537. * The callback that allows custom handling of the root url based on the response url.
  81538. * @param rootUrl the original root url
  81539. * @param responseURL the response url if available
  81540. * @returns the new root url
  81541. */
  81542. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81543. /** @hidden */
  81544. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81545. /**
  81546. * The loader state or null if the loader is not active.
  81547. */
  81548. get loaderState(): Nullable<GLTFLoaderState>;
  81549. /**
  81550. * Returns a promise that resolves when the asset is completely loaded.
  81551. * @returns a promise that resolves when the asset is completely loaded.
  81552. */
  81553. whenCompleteAsync(): Promise<void>;
  81554. /** @hidden */
  81555. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81556. /** @hidden */
  81557. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81558. private _onProgress;
  81559. private _validate;
  81560. private _getLoader;
  81561. private _parseJson;
  81562. private _unpackBinaryAsync;
  81563. private _unpackBinaryV1Async;
  81564. private _unpackBinaryV2Async;
  81565. private static _parseVersion;
  81566. private static _compareVersion;
  81567. private static readonly _logSpaces;
  81568. private _logIndentLevel;
  81569. private _loggingEnabled;
  81570. /** @hidden */
  81571. _log: (message: string) => void;
  81572. /** @hidden */
  81573. _logOpen(message: string): void;
  81574. /** @hidden */
  81575. _logClose(): void;
  81576. private _logEnabled;
  81577. private _logDisabled;
  81578. private _capturePerformanceCounters;
  81579. /** @hidden */
  81580. _startPerformanceCounter: (counterName: string) => void;
  81581. /** @hidden */
  81582. _endPerformanceCounter: (counterName: string) => void;
  81583. private _startPerformanceCounterEnabled;
  81584. private _startPerformanceCounterDisabled;
  81585. private _endPerformanceCounterEnabled;
  81586. private _endPerformanceCounterDisabled;
  81587. }
  81588. }
  81589. declare module BABYLON.GLTF1 {
  81590. /**
  81591. * Enums
  81592. * @hidden
  81593. */
  81594. export enum EComponentType {
  81595. BYTE = 5120,
  81596. UNSIGNED_BYTE = 5121,
  81597. SHORT = 5122,
  81598. UNSIGNED_SHORT = 5123,
  81599. FLOAT = 5126
  81600. }
  81601. /** @hidden */
  81602. export enum EShaderType {
  81603. FRAGMENT = 35632,
  81604. VERTEX = 35633
  81605. }
  81606. /** @hidden */
  81607. export enum EParameterType {
  81608. BYTE = 5120,
  81609. UNSIGNED_BYTE = 5121,
  81610. SHORT = 5122,
  81611. UNSIGNED_SHORT = 5123,
  81612. INT = 5124,
  81613. UNSIGNED_INT = 5125,
  81614. FLOAT = 5126,
  81615. FLOAT_VEC2 = 35664,
  81616. FLOAT_VEC3 = 35665,
  81617. FLOAT_VEC4 = 35666,
  81618. INT_VEC2 = 35667,
  81619. INT_VEC3 = 35668,
  81620. INT_VEC4 = 35669,
  81621. BOOL = 35670,
  81622. BOOL_VEC2 = 35671,
  81623. BOOL_VEC3 = 35672,
  81624. BOOL_VEC4 = 35673,
  81625. FLOAT_MAT2 = 35674,
  81626. FLOAT_MAT3 = 35675,
  81627. FLOAT_MAT4 = 35676,
  81628. SAMPLER_2D = 35678
  81629. }
  81630. /** @hidden */
  81631. export enum ETextureWrapMode {
  81632. CLAMP_TO_EDGE = 33071,
  81633. MIRRORED_REPEAT = 33648,
  81634. REPEAT = 10497
  81635. }
  81636. /** @hidden */
  81637. export enum ETextureFilterType {
  81638. NEAREST = 9728,
  81639. LINEAR = 9728,
  81640. NEAREST_MIPMAP_NEAREST = 9984,
  81641. LINEAR_MIPMAP_NEAREST = 9985,
  81642. NEAREST_MIPMAP_LINEAR = 9986,
  81643. LINEAR_MIPMAP_LINEAR = 9987
  81644. }
  81645. /** @hidden */
  81646. export enum ETextureFormat {
  81647. ALPHA = 6406,
  81648. RGB = 6407,
  81649. RGBA = 6408,
  81650. LUMINANCE = 6409,
  81651. LUMINANCE_ALPHA = 6410
  81652. }
  81653. /** @hidden */
  81654. export enum ECullingType {
  81655. FRONT = 1028,
  81656. BACK = 1029,
  81657. FRONT_AND_BACK = 1032
  81658. }
  81659. /** @hidden */
  81660. export enum EBlendingFunction {
  81661. ZERO = 0,
  81662. ONE = 1,
  81663. SRC_COLOR = 768,
  81664. ONE_MINUS_SRC_COLOR = 769,
  81665. DST_COLOR = 774,
  81666. ONE_MINUS_DST_COLOR = 775,
  81667. SRC_ALPHA = 770,
  81668. ONE_MINUS_SRC_ALPHA = 771,
  81669. DST_ALPHA = 772,
  81670. ONE_MINUS_DST_ALPHA = 773,
  81671. CONSTANT_COLOR = 32769,
  81672. ONE_MINUS_CONSTANT_COLOR = 32770,
  81673. CONSTANT_ALPHA = 32771,
  81674. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81675. SRC_ALPHA_SATURATE = 776
  81676. }
  81677. /** @hidden */
  81678. export interface IGLTFProperty {
  81679. extensions?: {
  81680. [key: string]: any;
  81681. };
  81682. extras?: Object;
  81683. }
  81684. /** @hidden */
  81685. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81686. name?: string;
  81687. }
  81688. /** @hidden */
  81689. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81690. bufferView: string;
  81691. byteOffset: number;
  81692. byteStride: number;
  81693. count: number;
  81694. type: string;
  81695. componentType: EComponentType;
  81696. max?: number[];
  81697. min?: number[];
  81698. name?: string;
  81699. }
  81700. /** @hidden */
  81701. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81702. buffer: string;
  81703. byteOffset: number;
  81704. byteLength: number;
  81705. byteStride: number;
  81706. target?: number;
  81707. }
  81708. /** @hidden */
  81709. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81710. uri: string;
  81711. byteLength?: number;
  81712. type?: string;
  81713. }
  81714. /** @hidden */
  81715. export interface IGLTFShader extends IGLTFChildRootProperty {
  81716. uri: string;
  81717. type: EShaderType;
  81718. }
  81719. /** @hidden */
  81720. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81721. attributes: string[];
  81722. fragmentShader: string;
  81723. vertexShader: string;
  81724. }
  81725. /** @hidden */
  81726. export interface IGLTFTechniqueParameter {
  81727. type: number;
  81728. count?: number;
  81729. semantic?: string;
  81730. node?: string;
  81731. value?: number | boolean | string | Array<any>;
  81732. source?: string;
  81733. babylonValue?: any;
  81734. }
  81735. /** @hidden */
  81736. export interface IGLTFTechniqueCommonProfile {
  81737. lightingModel: string;
  81738. texcoordBindings: Object;
  81739. parameters?: Array<any>;
  81740. }
  81741. /** @hidden */
  81742. export interface IGLTFTechniqueStatesFunctions {
  81743. blendColor?: number[];
  81744. blendEquationSeparate?: number[];
  81745. blendFuncSeparate?: number[];
  81746. colorMask: boolean[];
  81747. cullFace: number[];
  81748. }
  81749. /** @hidden */
  81750. export interface IGLTFTechniqueStates {
  81751. enable: number[];
  81752. functions: IGLTFTechniqueStatesFunctions;
  81753. }
  81754. /** @hidden */
  81755. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81756. parameters: {
  81757. [key: string]: IGLTFTechniqueParameter;
  81758. };
  81759. program: string;
  81760. attributes: {
  81761. [key: string]: string;
  81762. };
  81763. uniforms: {
  81764. [key: string]: string;
  81765. };
  81766. states: IGLTFTechniqueStates;
  81767. }
  81768. /** @hidden */
  81769. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81770. technique?: string;
  81771. values: string[];
  81772. }
  81773. /** @hidden */
  81774. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81775. attributes: {
  81776. [key: string]: string;
  81777. };
  81778. indices: string;
  81779. material: string;
  81780. mode?: number;
  81781. }
  81782. /** @hidden */
  81783. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81784. primitives: IGLTFMeshPrimitive[];
  81785. }
  81786. /** @hidden */
  81787. export interface IGLTFImage extends IGLTFChildRootProperty {
  81788. uri: string;
  81789. }
  81790. /** @hidden */
  81791. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81792. magFilter?: number;
  81793. minFilter?: number;
  81794. wrapS?: number;
  81795. wrapT?: number;
  81796. }
  81797. /** @hidden */
  81798. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81799. sampler: string;
  81800. source: string;
  81801. format?: ETextureFormat;
  81802. internalFormat?: ETextureFormat;
  81803. target?: number;
  81804. type?: number;
  81805. babylonTexture?: Texture;
  81806. }
  81807. /** @hidden */
  81808. export interface IGLTFAmbienLight {
  81809. color?: number[];
  81810. }
  81811. /** @hidden */
  81812. export interface IGLTFDirectionalLight {
  81813. color?: number[];
  81814. }
  81815. /** @hidden */
  81816. export interface IGLTFPointLight {
  81817. color?: number[];
  81818. constantAttenuation?: number;
  81819. linearAttenuation?: number;
  81820. quadraticAttenuation?: number;
  81821. }
  81822. /** @hidden */
  81823. export interface IGLTFSpotLight {
  81824. color?: number[];
  81825. constantAttenuation?: number;
  81826. fallOfAngle?: number;
  81827. fallOffExponent?: number;
  81828. linearAttenuation?: number;
  81829. quadraticAttenuation?: number;
  81830. }
  81831. /** @hidden */
  81832. export interface IGLTFLight extends IGLTFChildRootProperty {
  81833. type: string;
  81834. }
  81835. /** @hidden */
  81836. export interface IGLTFCameraOrthographic {
  81837. xmag: number;
  81838. ymag: number;
  81839. zfar: number;
  81840. znear: number;
  81841. }
  81842. /** @hidden */
  81843. export interface IGLTFCameraPerspective {
  81844. aspectRatio: number;
  81845. yfov: number;
  81846. zfar: number;
  81847. znear: number;
  81848. }
  81849. /** @hidden */
  81850. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81851. type: string;
  81852. }
  81853. /** @hidden */
  81854. export interface IGLTFAnimationChannelTarget {
  81855. id: string;
  81856. path: string;
  81857. }
  81858. /** @hidden */
  81859. export interface IGLTFAnimationChannel {
  81860. sampler: string;
  81861. target: IGLTFAnimationChannelTarget;
  81862. }
  81863. /** @hidden */
  81864. export interface IGLTFAnimationSampler {
  81865. input: string;
  81866. output: string;
  81867. interpolation?: string;
  81868. }
  81869. /** @hidden */
  81870. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81871. channels?: IGLTFAnimationChannel[];
  81872. parameters?: {
  81873. [key: string]: string;
  81874. };
  81875. samplers?: {
  81876. [key: string]: IGLTFAnimationSampler;
  81877. };
  81878. }
  81879. /** @hidden */
  81880. export interface IGLTFNodeInstanceSkin {
  81881. skeletons: string[];
  81882. skin: string;
  81883. meshes: string[];
  81884. }
  81885. /** @hidden */
  81886. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81887. bindShapeMatrix: number[];
  81888. inverseBindMatrices: string;
  81889. jointNames: string[];
  81890. babylonSkeleton?: Skeleton;
  81891. }
  81892. /** @hidden */
  81893. export interface IGLTFNode extends IGLTFChildRootProperty {
  81894. camera?: string;
  81895. children: string[];
  81896. skin?: string;
  81897. jointName?: string;
  81898. light?: string;
  81899. matrix: number[];
  81900. mesh?: string;
  81901. meshes?: string[];
  81902. rotation?: number[];
  81903. scale?: number[];
  81904. translation?: number[];
  81905. babylonNode?: Node;
  81906. }
  81907. /** @hidden */
  81908. export interface IGLTFScene extends IGLTFChildRootProperty {
  81909. nodes: string[];
  81910. }
  81911. /** @hidden */
  81912. export interface IGLTFRuntime {
  81913. extensions: {
  81914. [key: string]: any;
  81915. };
  81916. accessors: {
  81917. [key: string]: IGLTFAccessor;
  81918. };
  81919. buffers: {
  81920. [key: string]: IGLTFBuffer;
  81921. };
  81922. bufferViews: {
  81923. [key: string]: IGLTFBufferView;
  81924. };
  81925. meshes: {
  81926. [key: string]: IGLTFMesh;
  81927. };
  81928. lights: {
  81929. [key: string]: IGLTFLight;
  81930. };
  81931. cameras: {
  81932. [key: string]: IGLTFCamera;
  81933. };
  81934. nodes: {
  81935. [key: string]: IGLTFNode;
  81936. };
  81937. images: {
  81938. [key: string]: IGLTFImage;
  81939. };
  81940. textures: {
  81941. [key: string]: IGLTFTexture;
  81942. };
  81943. shaders: {
  81944. [key: string]: IGLTFShader;
  81945. };
  81946. programs: {
  81947. [key: string]: IGLTFProgram;
  81948. };
  81949. samplers: {
  81950. [key: string]: IGLTFSampler;
  81951. };
  81952. techniques: {
  81953. [key: string]: IGLTFTechnique;
  81954. };
  81955. materials: {
  81956. [key: string]: IGLTFMaterial;
  81957. };
  81958. animations: {
  81959. [key: string]: IGLTFAnimation;
  81960. };
  81961. skins: {
  81962. [key: string]: IGLTFSkins;
  81963. };
  81964. currentScene?: Object;
  81965. scenes: {
  81966. [key: string]: IGLTFScene;
  81967. };
  81968. extensionsUsed: string[];
  81969. extensionsRequired?: string[];
  81970. buffersCount: number;
  81971. shaderscount: number;
  81972. scene: Scene;
  81973. rootUrl: string;
  81974. loadedBufferCount: number;
  81975. loadedBufferViews: {
  81976. [name: string]: ArrayBufferView;
  81977. };
  81978. loadedShaderCount: number;
  81979. importOnlyMeshes: boolean;
  81980. importMeshesNames?: string[];
  81981. dummyNodes: Node[];
  81982. forAssetContainer: boolean;
  81983. }
  81984. /** @hidden */
  81985. export interface INodeToRoot {
  81986. bone: Bone;
  81987. node: IGLTFNode;
  81988. id: string;
  81989. }
  81990. /** @hidden */
  81991. export interface IJointNode {
  81992. node: IGLTFNode;
  81993. id: string;
  81994. }
  81995. }
  81996. declare module BABYLON.GLTF1 {
  81997. /**
  81998. * Utils functions for GLTF
  81999. * @hidden
  82000. */
  82001. export class GLTFUtils {
  82002. /**
  82003. * Sets the given "parameter" matrix
  82004. * @param scene: the Scene object
  82005. * @param source: the source node where to pick the matrix
  82006. * @param parameter: the GLTF technique parameter
  82007. * @param uniformName: the name of the shader's uniform
  82008. * @param shaderMaterial: the shader material
  82009. */
  82010. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82011. /**
  82012. * Sets the given "parameter" matrix
  82013. * @param shaderMaterial: the shader material
  82014. * @param uniform: the name of the shader's uniform
  82015. * @param value: the value of the uniform
  82016. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82017. */
  82018. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82019. /**
  82020. * Returns the wrap mode of the texture
  82021. * @param mode: the mode value
  82022. */
  82023. static GetWrapMode(mode: number): number;
  82024. /**
  82025. * Returns the byte stride giving an accessor
  82026. * @param accessor: the GLTF accessor objet
  82027. */
  82028. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82029. /**
  82030. * Returns the texture filter mode giving a mode value
  82031. * @param mode: the filter mode value
  82032. */
  82033. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82034. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82035. /**
  82036. * Returns a buffer from its accessor
  82037. * @param gltfRuntime: the GLTF runtime
  82038. * @param accessor: the GLTF accessor
  82039. */
  82040. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82041. /**
  82042. * Decodes a buffer view into a string
  82043. * @param view: the buffer view
  82044. */
  82045. static DecodeBufferToText(view: ArrayBufferView): string;
  82046. /**
  82047. * Returns the default material of gltf. Related to
  82048. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82049. * @param scene: the Babylon.js scene
  82050. */
  82051. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82052. private static _DefaultMaterial;
  82053. }
  82054. }
  82055. declare module BABYLON.GLTF1 {
  82056. /**
  82057. * Implementation of the base glTF spec
  82058. * @hidden
  82059. */
  82060. export class GLTFLoaderBase {
  82061. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82062. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82063. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82064. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82065. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82066. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82067. }
  82068. /**
  82069. * glTF V1 Loader
  82070. * @hidden
  82071. */
  82072. export class GLTFLoader implements IGLTFLoader {
  82073. static Extensions: {
  82074. [name: string]: GLTFLoaderExtension;
  82075. };
  82076. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82077. state: Nullable<GLTFLoaderState>;
  82078. dispose(): void;
  82079. private _importMeshAsync;
  82080. /**
  82081. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82082. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82083. * @param scene the scene the meshes should be added to
  82084. * @param forAssetContainer defines if the entities must be stored in the scene
  82085. * @param data gltf data containing information of the meshes in a loaded file
  82086. * @param rootUrl root url to load from
  82087. * @param onProgress event that fires when loading progress has occured
  82088. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82089. */
  82090. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82091. private _loadAsync;
  82092. /**
  82093. * Imports all objects from a loaded gltf file and adds them to the scene
  82094. * @param scene the scene the objects should be added to
  82095. * @param data gltf data containing information of the meshes in a loaded file
  82096. * @param rootUrl root url to load from
  82097. * @param onProgress event that fires when loading progress has occured
  82098. * @returns a promise which completes when objects have been loaded to the scene
  82099. */
  82100. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82101. private _loadShadersAsync;
  82102. private _loadBuffersAsync;
  82103. private _createNodes;
  82104. }
  82105. /** @hidden */
  82106. export abstract class GLTFLoaderExtension {
  82107. private _name;
  82108. constructor(name: string);
  82109. get name(): string;
  82110. /**
  82111. * Defines an override for loading the runtime
  82112. * Return true to stop further extensions from loading the runtime
  82113. */
  82114. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82115. /**
  82116. * Defines an onverride for creating gltf runtime
  82117. * Return true to stop further extensions from creating the runtime
  82118. */
  82119. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82120. /**
  82121. * Defines an override for loading buffers
  82122. * Return true to stop further extensions from loading this buffer
  82123. */
  82124. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82125. /**
  82126. * Defines an override for loading texture buffers
  82127. * Return true to stop further extensions from loading this texture data
  82128. */
  82129. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82130. /**
  82131. * Defines an override for creating textures
  82132. * Return true to stop further extensions from loading this texture
  82133. */
  82134. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82135. /**
  82136. * Defines an override for loading shader strings
  82137. * Return true to stop further extensions from loading this shader data
  82138. */
  82139. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82140. /**
  82141. * Defines an override for loading materials
  82142. * Return true to stop further extensions from loading this material
  82143. */
  82144. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82145. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82146. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82147. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82148. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82149. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82150. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82151. private static LoadTextureBufferAsync;
  82152. private static CreateTextureAsync;
  82153. private static ApplyExtensions;
  82154. }
  82155. }
  82156. declare module BABYLON.GLTF1 {
  82157. /** @hidden */
  82158. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82159. private _bin;
  82160. constructor();
  82161. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82162. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82163. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82164. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82165. }
  82166. }
  82167. declare module BABYLON.GLTF1 {
  82168. /** @hidden */
  82169. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82170. constructor();
  82171. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82172. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82173. private _loadTexture;
  82174. }
  82175. }
  82176. declare module BABYLON.GLTF2.Loader {
  82177. /**
  82178. * Loader interface with an index field.
  82179. */
  82180. export interface IArrayItem {
  82181. /**
  82182. * The index of this item in the array.
  82183. */
  82184. index: number;
  82185. }
  82186. /**
  82187. * Loader interface with additional members.
  82188. */
  82189. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82190. /** @hidden */
  82191. _data?: Promise<ArrayBufferView>;
  82192. /** @hidden */
  82193. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82194. }
  82195. /**
  82196. * Loader interface with additional members.
  82197. */
  82198. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82199. }
  82200. /** @hidden */
  82201. export interface _IAnimationSamplerData {
  82202. input: Float32Array;
  82203. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82204. output: Float32Array;
  82205. }
  82206. /**
  82207. * Loader interface with additional members.
  82208. */
  82209. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82210. /** @hidden */
  82211. _data?: Promise<_IAnimationSamplerData>;
  82212. }
  82213. /**
  82214. * Loader interface with additional members.
  82215. */
  82216. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82217. channels: IAnimationChannel[];
  82218. samplers: IAnimationSampler[];
  82219. /** @hidden */
  82220. _babylonAnimationGroup?: AnimationGroup;
  82221. }
  82222. /**
  82223. * Loader interface with additional members.
  82224. */
  82225. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82226. /** @hidden */
  82227. _data?: Promise<ArrayBufferView>;
  82228. }
  82229. /**
  82230. * Loader interface with additional members.
  82231. */
  82232. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82233. /** @hidden */
  82234. _data?: Promise<ArrayBufferView>;
  82235. /** @hidden */
  82236. _babylonBuffer?: Promise<Buffer>;
  82237. }
  82238. /**
  82239. * Loader interface with additional members.
  82240. */
  82241. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82242. }
  82243. /**
  82244. * Loader interface with additional members.
  82245. */
  82246. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82247. /** @hidden */
  82248. _data?: Promise<ArrayBufferView>;
  82249. }
  82250. /**
  82251. * Loader interface with additional members.
  82252. */
  82253. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82254. }
  82255. /**
  82256. * Loader interface with additional members.
  82257. */
  82258. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82259. }
  82260. /**
  82261. * Loader interface with additional members.
  82262. */
  82263. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82264. baseColorTexture?: ITextureInfo;
  82265. metallicRoughnessTexture?: ITextureInfo;
  82266. }
  82267. /**
  82268. * Loader interface with additional members.
  82269. */
  82270. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82271. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82272. normalTexture?: IMaterialNormalTextureInfo;
  82273. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82274. emissiveTexture?: ITextureInfo;
  82275. /** @hidden */
  82276. _data?: {
  82277. [babylonDrawMode: number]: {
  82278. babylonMaterial: Material;
  82279. babylonMeshes: AbstractMesh[];
  82280. promise: Promise<void>;
  82281. };
  82282. };
  82283. }
  82284. /**
  82285. * Loader interface with additional members.
  82286. */
  82287. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82288. primitives: IMeshPrimitive[];
  82289. }
  82290. /**
  82291. * Loader interface with additional members.
  82292. */
  82293. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82294. /** @hidden */
  82295. _instanceData?: {
  82296. babylonSourceMesh: Mesh;
  82297. promise: Promise<any>;
  82298. };
  82299. }
  82300. /**
  82301. * Loader interface with additional members.
  82302. */
  82303. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82304. /**
  82305. * The parent glTF node.
  82306. */
  82307. parent?: INode;
  82308. /** @hidden */
  82309. _babylonTransformNode?: TransformNode;
  82310. /** @hidden */
  82311. _primitiveBabylonMeshes?: AbstractMesh[];
  82312. /** @hidden */
  82313. _babylonBones?: Bone[];
  82314. /** @hidden */
  82315. _numMorphTargets?: number;
  82316. }
  82317. /** @hidden */
  82318. export interface _ISamplerData {
  82319. noMipMaps: boolean;
  82320. samplingMode: number;
  82321. wrapU: number;
  82322. wrapV: number;
  82323. }
  82324. /**
  82325. * Loader interface with additional members.
  82326. */
  82327. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82328. /** @hidden */
  82329. _data?: _ISamplerData;
  82330. }
  82331. /**
  82332. * Loader interface with additional members.
  82333. */
  82334. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82335. }
  82336. /**
  82337. * Loader interface with additional members.
  82338. */
  82339. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82340. /** @hidden */
  82341. _data?: {
  82342. babylonSkeleton: Skeleton;
  82343. promise: Promise<void>;
  82344. };
  82345. }
  82346. /**
  82347. * Loader interface with additional members.
  82348. */
  82349. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82350. }
  82351. /**
  82352. * Loader interface with additional members.
  82353. */
  82354. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82355. }
  82356. /**
  82357. * Loader interface with additional members.
  82358. */
  82359. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82360. accessors?: IAccessor[];
  82361. animations?: IAnimation[];
  82362. buffers?: IBuffer[];
  82363. bufferViews?: IBufferView[];
  82364. cameras?: ICamera[];
  82365. images?: IImage[];
  82366. materials?: IMaterial[];
  82367. meshes?: IMesh[];
  82368. nodes?: INode[];
  82369. samplers?: ISampler[];
  82370. scenes?: IScene[];
  82371. skins?: ISkin[];
  82372. textures?: ITexture[];
  82373. }
  82374. }
  82375. declare module BABYLON.GLTF2 {
  82376. /**
  82377. * Interface for a glTF loader extension.
  82378. */
  82379. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82380. /**
  82381. * Called after the loader state changes to LOADING.
  82382. */
  82383. onLoading?(): void;
  82384. /**
  82385. * Called after the loader state changes to READY.
  82386. */
  82387. onReady?(): void;
  82388. /**
  82389. * Define this method to modify the default behavior when loading scenes.
  82390. * @param context The context when loading the asset
  82391. * @param scene The glTF scene property
  82392. * @returns A promise that resolves when the load is complete or null if not handled
  82393. */
  82394. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82395. /**
  82396. * Define this method to modify the default behavior when loading nodes.
  82397. * @param context The context when loading the asset
  82398. * @param node The glTF node property
  82399. * @param assign A function called synchronously after parsing the glTF properties
  82400. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82401. */
  82402. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82403. /**
  82404. * Define this method to modify the default behavior when loading cameras.
  82405. * @param context The context when loading the asset
  82406. * @param camera The glTF camera property
  82407. * @param assign A function called synchronously after parsing the glTF properties
  82408. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82409. */
  82410. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82411. /**
  82412. * @hidden
  82413. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82414. * @param context The context when loading the asset
  82415. * @param primitive The glTF mesh primitive property
  82416. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82417. */
  82418. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82419. /**
  82420. * @hidden
  82421. * Define this method to modify the default behavior when loading data for mesh primitives.
  82422. * @param context The context when loading the asset
  82423. * @param name The mesh name when loading the asset
  82424. * @param node The glTF node when loading the asset
  82425. * @param mesh The glTF mesh when loading the asset
  82426. * @param primitive The glTF mesh primitive property
  82427. * @param assign A function called synchronously after parsing the glTF properties
  82428. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82429. */
  82430. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82431. /**
  82432. * @hidden
  82433. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82434. * @param context The context when loading the asset
  82435. * @param material The glTF material property
  82436. * @param assign A function called synchronously after parsing the glTF properties
  82437. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82438. */
  82439. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82440. /**
  82441. * Define this method to modify the default behavior when creating materials.
  82442. * @param context The context when loading the asset
  82443. * @param material The glTF material property
  82444. * @param babylonDrawMode The draw mode for the Babylon material
  82445. * @returns The Babylon material or null if not handled
  82446. */
  82447. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82448. /**
  82449. * Define this method to modify the default behavior when loading material properties.
  82450. * @param context The context when loading the asset
  82451. * @param material The glTF material property
  82452. * @param babylonMaterial The Babylon material
  82453. * @returns A promise that resolves when the load is complete or null if not handled
  82454. */
  82455. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82456. /**
  82457. * Define this method to modify the default behavior when loading texture infos.
  82458. * @param context The context when loading the asset
  82459. * @param textureInfo The glTF texture info property
  82460. * @param assign A function called synchronously after parsing the glTF properties
  82461. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82462. */
  82463. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82464. /**
  82465. * @hidden
  82466. * Define this method to modify the default behavior when loading textures.
  82467. * @param context The context when loading the asset
  82468. * @param texture The glTF texture property
  82469. * @param assign A function called synchronously after parsing the glTF properties
  82470. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82471. */
  82472. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82473. /**
  82474. * Define this method to modify the default behavior when loading animations.
  82475. * @param context The context when loading the asset
  82476. * @param animation The glTF animation property
  82477. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82478. */
  82479. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82480. /**
  82481. * @hidden
  82482. * Define this method to modify the default behavior when loading skins.
  82483. * @param context The context when loading the asset
  82484. * @param node The glTF node property
  82485. * @param skin The glTF skin property
  82486. * @returns A promise that resolves when the load is complete or null if not handled
  82487. */
  82488. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82489. /**
  82490. * @hidden
  82491. * Define this method to modify the default behavior when loading uris.
  82492. * @param context The context when loading the asset
  82493. * @param property The glTF property associated with the uri
  82494. * @param uri The uri to load
  82495. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82496. */
  82497. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82498. /**
  82499. * Define this method to modify the default behavior when loading buffer views.
  82500. * @param context The context when loading the asset
  82501. * @param bufferView The glTF buffer view property
  82502. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82503. */
  82504. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82505. /**
  82506. * Define this method to modify the default behavior when loading buffers.
  82507. * @param context The context when loading the asset
  82508. * @param buffer The glTF buffer property
  82509. * @param byteOffset The byte offset to load
  82510. * @param byteLength The byte length to load
  82511. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82512. */
  82513. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82514. }
  82515. }
  82516. declare module BABYLON.GLTF2 {
  82517. /**
  82518. * Helper class for working with arrays when loading the glTF asset
  82519. */
  82520. export class ArrayItem {
  82521. /**
  82522. * Gets an item from the given array.
  82523. * @param context The context when loading the asset
  82524. * @param array The array to get the item from
  82525. * @param index The index to the array
  82526. * @returns The array item
  82527. */
  82528. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82529. /**
  82530. * Assign an `index` field to each item of the given array.
  82531. * @param array The array of items
  82532. */
  82533. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82534. }
  82535. /**
  82536. * The glTF 2.0 loader
  82537. */
  82538. export class GLTFLoader implements IGLTFLoader {
  82539. /** @hidden */
  82540. _completePromises: Promise<any>[];
  82541. /** @hidden */
  82542. _forAssetContainer: boolean;
  82543. /** Storage */
  82544. _babylonLights: Light[];
  82545. /** @hidden */
  82546. _disableInstancedMesh: number;
  82547. private _disposed;
  82548. private _parent;
  82549. private _state;
  82550. private _extensions;
  82551. private _rootUrl;
  82552. private _fileName;
  82553. private _uniqueRootUrl;
  82554. private _gltf;
  82555. private _bin;
  82556. private _babylonScene;
  82557. private _rootBabylonMesh;
  82558. private _defaultBabylonMaterialData;
  82559. private static _RegisteredExtensions;
  82560. /**
  82561. * The default glTF sampler.
  82562. */
  82563. static readonly DefaultSampler: ISampler;
  82564. /**
  82565. * Registers a loader extension.
  82566. * @param name The name of the loader extension.
  82567. * @param factory The factory function that creates the loader extension.
  82568. */
  82569. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82570. /**
  82571. * Unregisters a loader extension.
  82572. * @param name The name of the loader extension.
  82573. * @returns A boolean indicating whether the extension has been unregistered
  82574. */
  82575. static UnregisterExtension(name: string): boolean;
  82576. /**
  82577. * The loader state.
  82578. */
  82579. get state(): Nullable<GLTFLoaderState>;
  82580. /**
  82581. * The object that represents the glTF JSON.
  82582. */
  82583. get gltf(): IGLTF;
  82584. /**
  82585. * The BIN chunk of a binary glTF.
  82586. */
  82587. get bin(): Nullable<IDataBuffer>;
  82588. /**
  82589. * The parent file loader.
  82590. */
  82591. get parent(): GLTFFileLoader;
  82592. /**
  82593. * The Babylon scene when loading the asset.
  82594. */
  82595. get babylonScene(): Scene;
  82596. /**
  82597. * The root Babylon mesh when loading the asset.
  82598. */
  82599. get rootBabylonMesh(): Mesh;
  82600. /** @hidden */
  82601. constructor(parent: GLTFFileLoader);
  82602. /** @hidden */
  82603. dispose(): void;
  82604. /** @hidden */
  82605. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82606. /** @hidden */
  82607. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82608. private _loadAsync;
  82609. private _loadData;
  82610. private _setupData;
  82611. private _loadExtensions;
  82612. private _checkExtensions;
  82613. private _setState;
  82614. private _createRootNode;
  82615. /**
  82616. * Loads a glTF scene.
  82617. * @param context The context when loading the asset
  82618. * @param scene The glTF scene property
  82619. * @returns A promise that resolves when the load is complete
  82620. */
  82621. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82622. private _forEachPrimitive;
  82623. private _getMeshes;
  82624. private _getTransformNodes;
  82625. private _getSkeletons;
  82626. private _getAnimationGroups;
  82627. private _startAnimations;
  82628. /**
  82629. * Loads a glTF node.
  82630. * @param context The context when loading the asset
  82631. * @param node The glTF node property
  82632. * @param assign A function called synchronously after parsing the glTF properties
  82633. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82634. */
  82635. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82636. private _loadMeshAsync;
  82637. /**
  82638. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82639. * @param context The context when loading the asset
  82640. * @param name The mesh name when loading the asset
  82641. * @param node The glTF node when loading the asset
  82642. * @param mesh The glTF mesh when loading the asset
  82643. * @param primitive The glTF mesh primitive property
  82644. * @param assign A function called synchronously after parsing the glTF properties
  82645. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82646. */
  82647. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82648. private _loadVertexDataAsync;
  82649. private _createMorphTargets;
  82650. private _loadMorphTargetsAsync;
  82651. private _loadMorphTargetVertexDataAsync;
  82652. private static _LoadTransform;
  82653. private _loadSkinAsync;
  82654. private _loadBones;
  82655. private _loadBone;
  82656. private _loadSkinInverseBindMatricesDataAsync;
  82657. private _updateBoneMatrices;
  82658. private _getNodeMatrix;
  82659. /**
  82660. * Loads a glTF camera.
  82661. * @param context The context when loading the asset
  82662. * @param camera The glTF camera property
  82663. * @param assign A function called synchronously after parsing the glTF properties
  82664. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82665. */
  82666. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82667. private _loadAnimationsAsync;
  82668. /**
  82669. * Loads a glTF animation.
  82670. * @param context The context when loading the asset
  82671. * @param animation The glTF animation property
  82672. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82673. */
  82674. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82675. /**
  82676. * @hidden Loads a glTF animation channel.
  82677. * @param context The context when loading the asset
  82678. * @param animationContext The context of the animation when loading the asset
  82679. * @param animation The glTF animation property
  82680. * @param channel The glTF animation channel property
  82681. * @param babylonAnimationGroup The babylon animation group property
  82682. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82683. * @returns A void promise when the channel load is complete
  82684. */
  82685. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82686. private _loadAnimationSamplerAsync;
  82687. private _loadBufferAsync;
  82688. /**
  82689. * Loads a glTF buffer view.
  82690. * @param context The context when loading the asset
  82691. * @param bufferView The glTF buffer view property
  82692. * @returns A promise that resolves with the loaded data when the load is complete
  82693. */
  82694. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82695. private _loadAccessorAsync;
  82696. /** @hidden */
  82697. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82698. private _loadIndicesAccessorAsync;
  82699. private _loadVertexBufferViewAsync;
  82700. private _loadVertexAccessorAsync;
  82701. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82702. /** @hidden */
  82703. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82704. private _createDefaultMaterial;
  82705. /**
  82706. * Creates a Babylon material from a glTF material.
  82707. * @param context The context when loading the asset
  82708. * @param material The glTF material property
  82709. * @param babylonDrawMode The draw mode for the Babylon material
  82710. * @returns The Babylon material
  82711. */
  82712. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82713. /**
  82714. * Loads properties from a glTF material into a Babylon material.
  82715. * @param context The context when loading the asset
  82716. * @param material The glTF material property
  82717. * @param babylonMaterial The Babylon material
  82718. * @returns A promise that resolves when the load is complete
  82719. */
  82720. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82721. /**
  82722. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82723. * @param context The context when loading the asset
  82724. * @param material The glTF material property
  82725. * @param babylonMaterial The Babylon material
  82726. * @returns A promise that resolves when the load is complete
  82727. */
  82728. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82729. /**
  82730. * Loads the alpha properties from a glTF material into a Babylon material.
  82731. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82732. * @param context The context when loading the asset
  82733. * @param material The glTF material property
  82734. * @param babylonMaterial The Babylon material
  82735. */
  82736. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82737. /**
  82738. * Loads a glTF texture info.
  82739. * @param context The context when loading the asset
  82740. * @param textureInfo The glTF texture info property
  82741. * @param assign A function called synchronously after parsing the glTF properties
  82742. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82743. */
  82744. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82745. /** @hidden */
  82746. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82747. /** @hidden */
  82748. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82749. private _loadSampler;
  82750. /**
  82751. * Loads a glTF image.
  82752. * @param context The context when loading the asset
  82753. * @param image The glTF image property
  82754. * @returns A promise that resolves with the loaded data when the load is complete
  82755. */
  82756. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82757. /**
  82758. * Loads a glTF uri.
  82759. * @param context The context when loading the asset
  82760. * @param property The glTF property associated with the uri
  82761. * @param uri The base64 or relative uri
  82762. * @returns A promise that resolves with the loaded data when the load is complete
  82763. */
  82764. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82765. /**
  82766. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82767. * @param babylonObject the Babylon object with metadata
  82768. * @param pointer the JSON pointer
  82769. */
  82770. static AddPointerMetadata(babylonObject: {
  82771. metadata: any;
  82772. }, pointer: string): void;
  82773. private static _GetTextureWrapMode;
  82774. private static _GetTextureSamplingMode;
  82775. private static _GetTypedArrayConstructor;
  82776. private static _GetTypedArray;
  82777. private static _GetNumComponents;
  82778. private static _ValidateUri;
  82779. /** @hidden */
  82780. static _GetDrawMode(context: string, mode: number | undefined): number;
  82781. private _compileMaterialsAsync;
  82782. private _compileShadowGeneratorsAsync;
  82783. private _forEachExtensions;
  82784. private _applyExtensions;
  82785. private _extensionsOnLoading;
  82786. private _extensionsOnReady;
  82787. private _extensionsLoadSceneAsync;
  82788. private _extensionsLoadNodeAsync;
  82789. private _extensionsLoadCameraAsync;
  82790. private _extensionsLoadVertexDataAsync;
  82791. private _extensionsLoadMeshPrimitiveAsync;
  82792. private _extensionsLoadMaterialAsync;
  82793. private _extensionsCreateMaterial;
  82794. private _extensionsLoadMaterialPropertiesAsync;
  82795. private _extensionsLoadTextureInfoAsync;
  82796. private _extensionsLoadTextureAsync;
  82797. private _extensionsLoadAnimationAsync;
  82798. private _extensionsLoadSkinAsync;
  82799. private _extensionsLoadUriAsync;
  82800. private _extensionsLoadBufferViewAsync;
  82801. private _extensionsLoadBufferAsync;
  82802. /**
  82803. * Helper method called by a loader extension to load an glTF extension.
  82804. * @param context The context when loading the asset
  82805. * @param property The glTF property to load the extension from
  82806. * @param extensionName The name of the extension to load
  82807. * @param actionAsync The action to run
  82808. * @returns The promise returned by actionAsync or null if the extension does not exist
  82809. */
  82810. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82811. /**
  82812. * Helper method called by a loader extension to load a glTF extra.
  82813. * @param context The context when loading the asset
  82814. * @param property The glTF property to load the extra from
  82815. * @param extensionName The name of the extension to load
  82816. * @param actionAsync The action to run
  82817. * @returns The promise returned by actionAsync or null if the extra does not exist
  82818. */
  82819. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82820. /**
  82821. * Checks for presence of an extension.
  82822. * @param name The name of the extension to check
  82823. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82824. */
  82825. isExtensionUsed(name: string): boolean;
  82826. /**
  82827. * Increments the indentation level and logs a message.
  82828. * @param message The message to log
  82829. */
  82830. logOpen(message: string): void;
  82831. /**
  82832. * Decrements the indentation level.
  82833. */
  82834. logClose(): void;
  82835. /**
  82836. * Logs a message
  82837. * @param message The message to log
  82838. */
  82839. log(message: string): void;
  82840. /**
  82841. * Starts a performance counter.
  82842. * @param counterName The name of the performance counter
  82843. */
  82844. startPerformanceCounter(counterName: string): void;
  82845. /**
  82846. * Ends a performance counter.
  82847. * @param counterName The name of the performance counter
  82848. */
  82849. endPerformanceCounter(counterName: string): void;
  82850. }
  82851. }
  82852. declare module BABYLON.GLTF2.Loader.Extensions {
  82853. /** @hidden */
  82854. interface IEXTLightsImageBased_LightImageBased {
  82855. _babylonTexture?: BaseTexture;
  82856. _loaded?: Promise<void>;
  82857. }
  82858. /**
  82859. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82860. */
  82861. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82862. /**
  82863. * The name of this extension.
  82864. */
  82865. readonly name: string;
  82866. /**
  82867. * Defines whether this extension is enabled.
  82868. */
  82869. enabled: boolean;
  82870. private _loader;
  82871. private _lights?;
  82872. /** @hidden */
  82873. constructor(loader: GLTFLoader);
  82874. /** @hidden */
  82875. dispose(): void;
  82876. /** @hidden */
  82877. onLoading(): void;
  82878. /** @hidden */
  82879. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82880. private _loadLightAsync;
  82881. }
  82882. }
  82883. declare module BABYLON.GLTF2.Loader.Extensions {
  82884. /**
  82885. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82886. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82887. * !!! Experimental Extension Subject to Changes !!!
  82888. */
  82889. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82890. /**
  82891. * The name of this extension.
  82892. */
  82893. readonly name: string;
  82894. /**
  82895. * Defines whether this extension is enabled.
  82896. */
  82897. enabled: boolean;
  82898. private _loader;
  82899. /** @hidden */
  82900. constructor(loader: GLTFLoader);
  82901. /** @hidden */
  82902. dispose(): void;
  82903. /** @hidden */
  82904. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82905. }
  82906. }
  82907. declare module BABYLON.GLTF2.Loader.Extensions {
  82908. /**
  82909. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82910. */
  82911. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82912. /** The name of this extension. */
  82913. readonly name: string;
  82914. /** Defines whether this extension is enabled. */
  82915. enabled: boolean;
  82916. private _loader;
  82917. /** @hidden */
  82918. constructor(loader: GLTFLoader);
  82919. /** @hidden */
  82920. dispose(): void;
  82921. /** @hidden */
  82922. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82923. }
  82924. }
  82925. declare module BABYLON.GLTF2.Loader.Extensions {
  82926. /**
  82927. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82928. */
  82929. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82930. /**
  82931. * The name of this extension.
  82932. */
  82933. readonly name: string;
  82934. /**
  82935. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82936. */
  82937. dracoCompression?: DracoCompression;
  82938. /**
  82939. * Defines whether this extension is enabled.
  82940. */
  82941. enabled: boolean;
  82942. private _loader;
  82943. /** @hidden */
  82944. constructor(loader: GLTFLoader);
  82945. /** @hidden */
  82946. dispose(): void;
  82947. /** @hidden */
  82948. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82949. }
  82950. }
  82951. declare module BABYLON.GLTF2.Loader.Extensions {
  82952. /**
  82953. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82954. */
  82955. export class KHR_lights implements IGLTFLoaderExtension {
  82956. /**
  82957. * The name of this extension.
  82958. */
  82959. readonly name: string;
  82960. /**
  82961. * Defines whether this extension is enabled.
  82962. */
  82963. enabled: boolean;
  82964. private _loader;
  82965. private _lights?;
  82966. /** @hidden */
  82967. constructor(loader: GLTFLoader);
  82968. /** @hidden */
  82969. dispose(): void;
  82970. /** @hidden */
  82971. onLoading(): 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/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82979. */
  82980. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82981. /**
  82982. * The name of this extension.
  82983. */
  82984. readonly name: string;
  82985. /**
  82986. * Defines whether this extension is enabled.
  82987. */
  82988. enabled: boolean;
  82989. /**
  82990. * Defines a number that determines the order the extensions are applied.
  82991. */
  82992. order: number;
  82993. private _loader;
  82994. /** @hidden */
  82995. constructor(loader: GLTFLoader);
  82996. /** @hidden */
  82997. dispose(): void;
  82998. /** @hidden */
  82999. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83000. private _loadSpecularGlossinessPropertiesAsync;
  83001. }
  83002. }
  83003. declare module BABYLON.GLTF2.Loader.Extensions {
  83004. /**
  83005. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83006. */
  83007. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83008. /**
  83009. * The name of this extension.
  83010. */
  83011. readonly name: string;
  83012. /**
  83013. * Defines whether this extension is enabled.
  83014. */
  83015. enabled: boolean;
  83016. /**
  83017. * Defines a number that determines the order the extensions are applied.
  83018. */
  83019. order: number;
  83020. private _loader;
  83021. /** @hidden */
  83022. constructor(loader: GLTFLoader);
  83023. /** @hidden */
  83024. dispose(): void;
  83025. /** @hidden */
  83026. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83027. private _loadUnlitPropertiesAsync;
  83028. }
  83029. }
  83030. declare module BABYLON.GLTF2.Loader.Extensions {
  83031. /**
  83032. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  83033. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83034. * !!! Experimental Extension Subject to Changes !!!
  83035. */
  83036. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83037. /**
  83038. * The name of this extension.
  83039. */
  83040. readonly name: string;
  83041. /**
  83042. * Defines whether this extension is enabled.
  83043. */
  83044. enabled: boolean;
  83045. /**
  83046. * Defines a number that determines the order the extensions are applied.
  83047. */
  83048. order: number;
  83049. private _loader;
  83050. /** @hidden */
  83051. constructor(loader: GLTFLoader);
  83052. /** @hidden */
  83053. dispose(): void;
  83054. /** @hidden */
  83055. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83056. private _loadClearCoatPropertiesAsync;
  83057. }
  83058. }
  83059. declare module BABYLON.GLTF2.Loader.Extensions {
  83060. /**
  83061. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83062. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83063. * !!! Experimental Extension Subject to Changes !!!
  83064. */
  83065. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83066. /**
  83067. * The name of this extension.
  83068. */
  83069. readonly name: string;
  83070. /**
  83071. * Defines whether this extension is enabled.
  83072. */
  83073. enabled: boolean;
  83074. /**
  83075. * Defines a number that determines the order the extensions are applied.
  83076. */
  83077. order: number;
  83078. private _loader;
  83079. /** @hidden */
  83080. constructor(loader: GLTFLoader);
  83081. /** @hidden */
  83082. dispose(): void;
  83083. /** @hidden */
  83084. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83085. private _loadSheenPropertiesAsync;
  83086. }
  83087. }
  83088. declare module BABYLON.GLTF2.Loader.Extensions {
  83089. /**
  83090. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83091. * !!! Experimental Extension Subject to Changes !!!
  83092. */
  83093. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83094. /**
  83095. * The name of this extension.
  83096. */
  83097. readonly name: string;
  83098. /**
  83099. * Defines whether this extension is enabled.
  83100. */
  83101. enabled: boolean;
  83102. /**
  83103. * Defines a number that determines the order the extensions are applied.
  83104. */
  83105. order: number;
  83106. private _loader;
  83107. /** @hidden */
  83108. constructor(loader: GLTFLoader);
  83109. /** @hidden */
  83110. dispose(): void;
  83111. /** @hidden */
  83112. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83113. private _loadSpecularPropertiesAsync;
  83114. }
  83115. }
  83116. declare module BABYLON.GLTF2.Loader.Extensions {
  83117. /**
  83118. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83119. * !!! Experimental Extension Subject to Changes !!!
  83120. */
  83121. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83122. /**
  83123. * Default ior Value from the spec.
  83124. */
  83125. private static readonly _DEFAULT_IOR;
  83126. /**
  83127. * The name of this extension.
  83128. */
  83129. readonly name: string;
  83130. /**
  83131. * Defines whether this extension is enabled.
  83132. */
  83133. enabled: boolean;
  83134. /**
  83135. * Defines a number that determines the order the extensions are applied.
  83136. */
  83137. order: number;
  83138. private _loader;
  83139. /** @hidden */
  83140. constructor(loader: GLTFLoader);
  83141. /** @hidden */
  83142. dispose(): void;
  83143. /** @hidden */
  83144. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83145. private _loadIorPropertiesAsync;
  83146. }
  83147. }
  83148. declare module BABYLON.GLTF2.Loader.Extensions {
  83149. /**
  83150. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83151. * !!! Experimental Extension Subject to Changes !!!
  83152. */
  83153. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83154. /**
  83155. * The name of this extension.
  83156. */
  83157. readonly name: string;
  83158. /**
  83159. * Defines whether this extension is enabled.
  83160. */
  83161. enabled: boolean;
  83162. private _loader;
  83163. private _variants?;
  83164. /** @hidden */
  83165. constructor(loader: GLTFLoader);
  83166. /** @hidden */
  83167. dispose(): void;
  83168. /**
  83169. * Gets the list of available variant names for this asset.
  83170. * @param rootMesh The glTF root mesh
  83171. * @returns the list of all the variant names for this model
  83172. */
  83173. static GetAvailableVariants(rootMesh: Mesh): string[];
  83174. /**
  83175. * Gets the list of available variant names for this asset.
  83176. * @param rootMesh The glTF root mesh
  83177. * @returns the list of all the variant names for this model
  83178. */
  83179. getAvailableVariants(rootMesh: Mesh): string[];
  83180. /**
  83181. * Select a variant given a variant name or a list of variant names.
  83182. * @param rootMesh The glTF root mesh
  83183. * @param variantName The variant name(s) to select.
  83184. */
  83185. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83186. /**
  83187. * Select a variant given a variant name or a list of variant names.
  83188. * @param rootMesh The glTF root mesh
  83189. * @param variantName The variant name(s) to select.
  83190. */
  83191. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83192. /**
  83193. * Reset back to the original before selecting a variant.
  83194. * @param rootMesh The glTF root mesh
  83195. */
  83196. static Reset(rootMesh: Mesh): void;
  83197. /**
  83198. * Reset back to the original before selecting a variant.
  83199. * @param rootMesh The glTF root mesh
  83200. */
  83201. reset(rootMesh: Mesh): void;
  83202. /**
  83203. * Gets the last selected variant name(s) or null if original.
  83204. * @param rootMesh The glTF root mesh
  83205. * @returns The selected variant name(s).
  83206. */
  83207. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83208. /**
  83209. * Gets the last selected variant name(s) or null if original.
  83210. * @param rootMesh The glTF root mesh
  83211. * @returns The selected variant name(s).
  83212. */
  83213. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83214. private static _GetExtensionMetadata;
  83215. /** @hidden */
  83216. onLoading(): void;
  83217. /** @hidden */
  83218. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83219. }
  83220. }
  83221. declare module BABYLON.GLTF2.Loader.Extensions {
  83222. /**
  83223. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83224. * !!! Experimental Extension Subject to Changes !!!
  83225. */
  83226. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83227. /**
  83228. * The name of this extension.
  83229. */
  83230. readonly name: string;
  83231. /**
  83232. * Defines whether this extension is enabled.
  83233. */
  83234. enabled: boolean;
  83235. /**
  83236. * Defines a number that determines the order the extensions are applied.
  83237. */
  83238. order: number;
  83239. private _loader;
  83240. /** @hidden */
  83241. constructor(loader: GLTFLoader);
  83242. /** @hidden */
  83243. dispose(): void;
  83244. /** @hidden */
  83245. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83246. private _loadTransparentPropertiesAsync;
  83247. }
  83248. }
  83249. declare module BABYLON.GLTF2.Loader.Extensions {
  83250. /**
  83251. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83252. */
  83253. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83254. /**
  83255. * The name of this extension.
  83256. */
  83257. readonly name: string;
  83258. /**
  83259. * Defines whether this extension is enabled.
  83260. */
  83261. enabled: boolean;
  83262. /** @hidden */
  83263. constructor(loader: GLTFLoader);
  83264. /** @hidden */
  83265. dispose(): void;
  83266. }
  83267. }
  83268. declare module BABYLON.GLTF2.Loader.Extensions {
  83269. /**
  83270. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83271. * !!! Experimental Extension Subject to Changes !!!
  83272. */
  83273. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83274. /** The name of this extension. */
  83275. readonly name: string;
  83276. /** Defines whether this extension is enabled. */
  83277. enabled: boolean;
  83278. private _loader;
  83279. /** @hidden */
  83280. constructor(loader: GLTFLoader);
  83281. /** @hidden */
  83282. dispose(): void;
  83283. /** @hidden */
  83284. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83285. }
  83286. }
  83287. declare module BABYLON.GLTF2.Loader.Extensions {
  83288. /**
  83289. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83290. */
  83291. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83292. /**
  83293. * The name of this extension.
  83294. */
  83295. readonly name: string;
  83296. /**
  83297. * Defines whether this extension is enabled.
  83298. */
  83299. enabled: boolean;
  83300. private _loader;
  83301. /** @hidden */
  83302. constructor(loader: GLTFLoader);
  83303. /** @hidden */
  83304. dispose(): void;
  83305. /** @hidden */
  83306. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83307. }
  83308. }
  83309. declare module BABYLON.GLTF2.Loader.Extensions {
  83310. /**
  83311. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83312. * !!! Experimental Extension Subject to Changes !!!
  83313. */
  83314. export class KHR_xmp implements IGLTFLoaderExtension {
  83315. /**
  83316. * The name of this extension.
  83317. */
  83318. readonly name: string;
  83319. /**
  83320. * Defines whether this extension is enabled.
  83321. */
  83322. enabled: boolean;
  83323. /**
  83324. * Defines a number that determines the order the extensions are applied.
  83325. */
  83326. order: number;
  83327. private _loader;
  83328. /** @hidden */
  83329. constructor(loader: GLTFLoader);
  83330. /** @hidden */
  83331. dispose(): void;
  83332. /**
  83333. * Called after the loader state changes to LOADING.
  83334. */
  83335. onLoading(): void;
  83336. }
  83337. }
  83338. declare module BABYLON.GLTF2.Loader.Extensions {
  83339. /**
  83340. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83341. */
  83342. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83343. /**
  83344. * The name of this extension.
  83345. */
  83346. readonly name: string;
  83347. /**
  83348. * Defines whether this extension is enabled.
  83349. */
  83350. enabled: boolean;
  83351. private _loader;
  83352. private _clips;
  83353. private _emitters;
  83354. /** @hidden */
  83355. constructor(loader: GLTFLoader);
  83356. /** @hidden */
  83357. dispose(): void;
  83358. /** @hidden */
  83359. onLoading(): void;
  83360. /** @hidden */
  83361. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83362. /** @hidden */
  83363. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83364. /** @hidden */
  83365. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83366. private _loadClipAsync;
  83367. private _loadEmitterAsync;
  83368. private _getEventAction;
  83369. private _loadAnimationEventAsync;
  83370. }
  83371. }
  83372. declare module BABYLON.GLTF2.Loader.Extensions {
  83373. /**
  83374. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83375. */
  83376. export class MSFT_lod implements IGLTFLoaderExtension {
  83377. /**
  83378. * The name of this extension.
  83379. */
  83380. readonly name: string;
  83381. /**
  83382. * Defines whether this extension is enabled.
  83383. */
  83384. enabled: boolean;
  83385. /**
  83386. * Defines a number that determines the order the extensions are applied.
  83387. */
  83388. order: number;
  83389. /**
  83390. * Maximum number of LODs to load, starting from the lowest LOD.
  83391. */
  83392. maxLODsToLoad: number;
  83393. /**
  83394. * Observable raised when all node LODs of one level are loaded.
  83395. * The event data is the index of the loaded LOD starting from zero.
  83396. * Dispose the loader to cancel the loading of the next level of LODs.
  83397. */
  83398. onNodeLODsLoadedObservable: Observable<number>;
  83399. /**
  83400. * Observable raised when all material LODs of one level are loaded.
  83401. * The event data is the index of the loaded LOD starting from zero.
  83402. * Dispose the loader to cancel the loading of the next level of LODs.
  83403. */
  83404. onMaterialLODsLoadedObservable: Observable<number>;
  83405. private _loader;
  83406. private _bufferLODs;
  83407. private _nodeIndexLOD;
  83408. private _nodeSignalLODs;
  83409. private _nodePromiseLODs;
  83410. private _nodeBufferLODs;
  83411. private _materialIndexLOD;
  83412. private _materialSignalLODs;
  83413. private _materialPromiseLODs;
  83414. private _materialBufferLODs;
  83415. /** @hidden */
  83416. constructor(loader: GLTFLoader);
  83417. /** @hidden */
  83418. dispose(): void;
  83419. /** @hidden */
  83420. onReady(): void;
  83421. /** @hidden */
  83422. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83423. /** @hidden */
  83424. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83425. /** @hidden */
  83426. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83427. /** @hidden */
  83428. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83429. /** @hidden */
  83430. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83431. private _loadBufferLOD;
  83432. /**
  83433. * Gets an array of LOD properties from lowest to highest.
  83434. */
  83435. private _getLODs;
  83436. private _disposeTransformNode;
  83437. private _disposeMaterials;
  83438. }
  83439. }
  83440. declare module BABYLON.GLTF2.Loader.Extensions {
  83441. /** @hidden */
  83442. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83443. readonly name: string;
  83444. enabled: boolean;
  83445. private _loader;
  83446. constructor(loader: GLTFLoader);
  83447. dispose(): void;
  83448. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83449. }
  83450. }
  83451. declare module BABYLON.GLTF2.Loader.Extensions {
  83452. /** @hidden */
  83453. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83454. readonly name: string;
  83455. enabled: boolean;
  83456. private _loader;
  83457. constructor(loader: GLTFLoader);
  83458. dispose(): void;
  83459. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83460. }
  83461. }
  83462. declare module BABYLON.GLTF2.Loader.Extensions {
  83463. /**
  83464. * Store glTF extras (if present) in BJS objects' metadata
  83465. */
  83466. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83467. /**
  83468. * The name of this extension.
  83469. */
  83470. readonly name: string;
  83471. /**
  83472. * Defines whether this extension is enabled.
  83473. */
  83474. enabled: boolean;
  83475. private _loader;
  83476. private _assignExtras;
  83477. /** @hidden */
  83478. constructor(loader: GLTFLoader);
  83479. /** @hidden */
  83480. dispose(): void;
  83481. /** @hidden */
  83482. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83483. /** @hidden */
  83484. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83485. /** @hidden */
  83486. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83487. }
  83488. }
  83489. declare module BABYLON {
  83490. /**
  83491. * Class reading and parsing the MTL file bundled with the obj file.
  83492. */
  83493. export class MTLFileLoader {
  83494. /**
  83495. * Invert Y-Axis of referenced textures on load
  83496. */
  83497. static INVERT_TEXTURE_Y: boolean;
  83498. /**
  83499. * All material loaded from the mtl will be set here
  83500. */
  83501. materials: StandardMaterial[];
  83502. /**
  83503. * This function will read the mtl file and create each material described inside
  83504. * This function could be improve by adding :
  83505. * -some component missing (Ni, Tf...)
  83506. * -including the specific options available
  83507. *
  83508. * @param scene defines the scene the material will be created in
  83509. * @param data defines the mtl data to parse
  83510. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83511. * @param forAssetContainer defines if the material should be registered in the scene
  83512. */
  83513. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83514. /**
  83515. * Gets the texture for the material.
  83516. *
  83517. * If the material is imported from input file,
  83518. * We sanitize the url to ensure it takes the textre from aside the material.
  83519. *
  83520. * @param rootUrl The root url to load from
  83521. * @param value The value stored in the mtl
  83522. * @return The Texture
  83523. */
  83524. private static _getTexture;
  83525. }
  83526. }
  83527. declare module BABYLON {
  83528. /**
  83529. * Options for loading OBJ/MTL files
  83530. */
  83531. type MeshLoadOptions = {
  83532. /**
  83533. * Defines if UVs are optimized by default during load.
  83534. */
  83535. OptimizeWithUV: boolean;
  83536. /**
  83537. * Defines custom scaling of UV coordinates of loaded meshes.
  83538. */
  83539. UVScaling: Vector2;
  83540. /**
  83541. * Invert model on y-axis (does a model scaling inversion)
  83542. */
  83543. InvertY: boolean;
  83544. /**
  83545. * Invert Y-Axis of referenced textures on load
  83546. */
  83547. InvertTextureY: boolean;
  83548. /**
  83549. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83550. */
  83551. ImportVertexColors: boolean;
  83552. /**
  83553. * Compute the normals for the model, even if normals are present in the file.
  83554. */
  83555. ComputeNormals: boolean;
  83556. /**
  83557. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83558. */
  83559. SkipMaterials: boolean;
  83560. /**
  83561. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83562. */
  83563. MaterialLoadingFailsSilently: boolean;
  83564. };
  83565. /**
  83566. * OBJ file type loader.
  83567. * This is a babylon scene loader plugin.
  83568. */
  83569. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83570. /**
  83571. * Defines if UVs are optimized by default during load.
  83572. */
  83573. static OPTIMIZE_WITH_UV: boolean;
  83574. /**
  83575. * Invert model on y-axis (does a model scaling inversion)
  83576. */
  83577. static INVERT_Y: boolean;
  83578. /**
  83579. * Invert Y-Axis of referenced textures on load
  83580. */
  83581. static get INVERT_TEXTURE_Y(): boolean;
  83582. static set INVERT_TEXTURE_Y(value: boolean);
  83583. /**
  83584. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83585. */
  83586. static IMPORT_VERTEX_COLORS: boolean;
  83587. /**
  83588. * Compute the normals for the model, even if normals are present in the file.
  83589. */
  83590. static COMPUTE_NORMALS: boolean;
  83591. /**
  83592. * Defines custom scaling of UV coordinates of loaded meshes.
  83593. */
  83594. static UV_SCALING: Vector2;
  83595. /**
  83596. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83597. */
  83598. static SKIP_MATERIALS: boolean;
  83599. /**
  83600. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83601. *
  83602. * Defaults to true for backwards compatibility.
  83603. */
  83604. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83605. /**
  83606. * Defines the name of the plugin.
  83607. */
  83608. name: string;
  83609. /**
  83610. * Defines the extension the plugin is able to load.
  83611. */
  83612. extensions: string;
  83613. /** @hidden */
  83614. obj: RegExp;
  83615. /** @hidden */
  83616. group: RegExp;
  83617. /** @hidden */
  83618. mtllib: RegExp;
  83619. /** @hidden */
  83620. usemtl: RegExp;
  83621. /** @hidden */
  83622. smooth: RegExp;
  83623. /** @hidden */
  83624. vertexPattern: RegExp;
  83625. /** @hidden */
  83626. normalPattern: RegExp;
  83627. /** @hidden */
  83628. uvPattern: RegExp;
  83629. /** @hidden */
  83630. facePattern1: RegExp;
  83631. /** @hidden */
  83632. facePattern2: RegExp;
  83633. /** @hidden */
  83634. facePattern3: RegExp;
  83635. /** @hidden */
  83636. facePattern4: RegExp;
  83637. /** @hidden */
  83638. facePattern5: RegExp;
  83639. private _forAssetContainer;
  83640. private _meshLoadOptions;
  83641. /**
  83642. * Creates loader for .OBJ files
  83643. *
  83644. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83645. */
  83646. constructor(meshLoadOptions?: MeshLoadOptions);
  83647. private static get currentMeshLoadOptions();
  83648. /**
  83649. * Calls synchronously the MTL file attached to this obj.
  83650. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83651. * Without this function materials are not displayed in the first frame (but displayed after).
  83652. * In consequence it is impossible to get material information in your HTML file
  83653. *
  83654. * @param url The URL of the MTL file
  83655. * @param rootUrl
  83656. * @param onSuccess Callback function to be called when the MTL file is loaded
  83657. * @private
  83658. */
  83659. private _loadMTL;
  83660. /**
  83661. * Instantiates a OBJ file loader plugin.
  83662. * @returns the created plugin
  83663. */
  83664. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83665. /**
  83666. * If the data string can be loaded directly.
  83667. *
  83668. * @param data string containing the file data
  83669. * @returns if the data can be loaded directly
  83670. */
  83671. canDirectLoad(data: string): boolean;
  83672. /**
  83673. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83674. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83675. * @param scene the scene the meshes should be added to
  83676. * @param data the OBJ data to load
  83677. * @param rootUrl root url to load from
  83678. * @param onProgress event that fires when loading progress has occured
  83679. * @param fileName Defines the name of the file to load
  83680. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83681. */
  83682. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83683. meshes: AbstractMesh[];
  83684. particleSystems: IParticleSystem[];
  83685. skeletons: Skeleton[];
  83686. animationGroups: AnimationGroup[];
  83687. }>;
  83688. /**
  83689. * Imports all objects from the loaded OBJ data and adds them to the scene
  83690. * @param scene the scene the objects should be added to
  83691. * @param data the OBJ data to load
  83692. * @param rootUrl root url to load from
  83693. * @param onProgress event that fires when loading progress has occured
  83694. * @param fileName Defines the name of the file to load
  83695. * @returns a promise which completes when objects have been loaded to the scene
  83696. */
  83697. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83698. /**
  83699. * Load into an asset container.
  83700. * @param scene The scene to load into
  83701. * @param data The data to import
  83702. * @param rootUrl The root url for scene and resources
  83703. * @param onProgress The callback when the load progresses
  83704. * @param fileName Defines the name of the file to load
  83705. * @returns The loaded asset container
  83706. */
  83707. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83708. /**
  83709. * Read the OBJ file and create an Array of meshes.
  83710. * Each mesh contains all information given by the OBJ and the MTL file.
  83711. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83712. *
  83713. * @param meshesNames
  83714. * @param scene Scene The scene where are displayed the data
  83715. * @param data String The content of the obj file
  83716. * @param rootUrl String The path to the folder
  83717. * @returns Array<AbstractMesh>
  83718. * @private
  83719. */
  83720. private _parseSolid;
  83721. }
  83722. }
  83723. declare module BABYLON {
  83724. /**
  83725. * STL file type loader.
  83726. * This is a babylon scene loader plugin.
  83727. */
  83728. export class STLFileLoader implements ISceneLoaderPlugin {
  83729. /** @hidden */
  83730. solidPattern: RegExp;
  83731. /** @hidden */
  83732. facetsPattern: RegExp;
  83733. /** @hidden */
  83734. normalPattern: RegExp;
  83735. /** @hidden */
  83736. vertexPattern: RegExp;
  83737. /**
  83738. * Defines the name of the plugin.
  83739. */
  83740. name: string;
  83741. /**
  83742. * Defines the extensions the stl loader is able to load.
  83743. * force data to come in as an ArrayBuffer
  83744. * we'll convert to string if it looks like it's an ASCII .stl
  83745. */
  83746. extensions: ISceneLoaderPluginExtensions;
  83747. /**
  83748. * Import meshes into a scene.
  83749. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83750. * @param scene The scene to import into
  83751. * @param data The data to import
  83752. * @param rootUrl The root url for scene and resources
  83753. * @param meshes The meshes array to import into
  83754. * @param particleSystems The particle systems array to import into
  83755. * @param skeletons The skeletons array to import into
  83756. * @param onError The callback when import fails
  83757. * @returns True if successful or false otherwise
  83758. */
  83759. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83760. /**
  83761. * Load into a scene.
  83762. * @param scene The scene to load into
  83763. * @param data The data to import
  83764. * @param rootUrl The root url for scene and resources
  83765. * @param onError The callback when import fails
  83766. * @returns true if successful or false otherwise
  83767. */
  83768. load(scene: Scene, data: any, rootUrl: string): boolean;
  83769. /**
  83770. * Load into an asset container.
  83771. * @param scene The scene to load into
  83772. * @param data The data to import
  83773. * @param rootUrl The root url for scene and resources
  83774. * @param onError The callback when import fails
  83775. * @returns The loaded asset container
  83776. */
  83777. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83778. private _isBinary;
  83779. private _parseBinary;
  83780. private _parseASCII;
  83781. }
  83782. }
  83783. declare module BABYLON {
  83784. /**
  83785. * Class for generating OBJ data from a Babylon scene.
  83786. */
  83787. export class OBJExport {
  83788. /**
  83789. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83790. * @param mesh defines the list of meshes to serialize
  83791. * @param materials defines if materials should be exported
  83792. * @param matlibname defines the name of the associated mtl file
  83793. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83794. * @returns the OBJ content
  83795. */
  83796. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83797. /**
  83798. * Exports the material(s) of a mesh in .MTL file format (text)
  83799. * @param mesh defines the mesh to extract the material from
  83800. * @returns the mtl content
  83801. */
  83802. static MTL(mesh: Mesh): string;
  83803. }
  83804. }
  83805. declare module BABYLON {
  83806. /** @hidden */
  83807. export var __IGLTFExporterExtension: number;
  83808. /**
  83809. * Interface for extending the exporter
  83810. * @hidden
  83811. */
  83812. export interface IGLTFExporterExtension {
  83813. /**
  83814. * The name of this extension
  83815. */
  83816. readonly name: string;
  83817. /**
  83818. * Defines whether this extension is enabled
  83819. */
  83820. enabled: boolean;
  83821. /**
  83822. * Defines whether this extension is required
  83823. */
  83824. required: boolean;
  83825. }
  83826. }
  83827. declare module BABYLON.GLTF2.Exporter {
  83828. /** @hidden */
  83829. export var __IGLTFExporterExtensionV2: number;
  83830. /**
  83831. * Interface for a glTF exporter extension
  83832. * @hidden
  83833. */
  83834. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83835. /**
  83836. * Define this method to modify the default behavior before exporting a texture
  83837. * @param context The context when loading the asset
  83838. * @param babylonTexture The Babylon.js texture
  83839. * @param mimeType The mime-type of the generated image
  83840. * @returns A promise that resolves with the exported texture
  83841. */
  83842. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83843. /**
  83844. * Define this method to get notified when a texture info is created
  83845. * @param context The context when loading the asset
  83846. * @param textureInfo The glTF texture info
  83847. * @param babylonTexture The Babylon.js texture
  83848. */
  83849. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83850. /**
  83851. * Define this method to modify the default behavior when exporting texture info
  83852. * @param context The context when loading the asset
  83853. * @param meshPrimitive glTF mesh primitive
  83854. * @param babylonSubMesh Babylon submesh
  83855. * @param binaryWriter glTF serializer binary writer instance
  83856. * @returns nullable IMeshPrimitive promise
  83857. */
  83858. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83859. /**
  83860. * Define this method to modify the default behavior when exporting a node
  83861. * @param context The context when exporting the node
  83862. * @param node glTF node
  83863. * @param babylonNode BabylonJS node
  83864. * @returns nullable INode promise
  83865. */
  83866. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83867. [key: number]: number;
  83868. }): Promise<Nullable<INode>>;
  83869. /**
  83870. * Define this method to modify the default behavior when exporting a material
  83871. * @param material glTF material
  83872. * @param babylonMaterial BabylonJS material
  83873. * @returns nullable IMaterial promise
  83874. */
  83875. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83876. /**
  83877. * Define this method to return additional textures to export from a material
  83878. * @param material glTF material
  83879. * @param babylonMaterial BabylonJS material
  83880. * @returns List of textures
  83881. */
  83882. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83883. /** Gets a boolean indicating that this extension was used */
  83884. wasUsed: boolean;
  83885. /** Gets a boolean indicating that this extension is required for the file to work */
  83886. required: boolean;
  83887. /**
  83888. * Called after the exporter state changes to EXPORTING
  83889. */
  83890. onExporting?(): void;
  83891. }
  83892. }
  83893. declare module BABYLON.GLTF2.Exporter {
  83894. /**
  83895. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83896. * @hidden
  83897. */
  83898. export class _GLTFMaterialExporter {
  83899. /**
  83900. * Represents the dielectric specular values for R, G and B
  83901. */
  83902. private static readonly _DielectricSpecular;
  83903. /**
  83904. * Allows the maximum specular power to be defined for material calculations
  83905. */
  83906. private static readonly _MaxSpecularPower;
  83907. /**
  83908. * Mapping to store textures
  83909. */
  83910. private _textureMap;
  83911. /**
  83912. * Numeric tolerance value
  83913. */
  83914. private static readonly _Epsilon;
  83915. /**
  83916. * Reference to the glTF Exporter
  83917. */
  83918. private _exporter;
  83919. constructor(exporter: _Exporter);
  83920. /**
  83921. * Specifies if two colors are approximately equal in value
  83922. * @param color1 first color to compare to
  83923. * @param color2 second color to compare to
  83924. * @param epsilon threshold value
  83925. */
  83926. private static FuzzyEquals;
  83927. /**
  83928. * Gets the materials from a Babylon scene and converts them to glTF materials
  83929. * @param scene babylonjs scene
  83930. * @param mimeType texture mime type
  83931. * @param images array of images
  83932. * @param textures array of textures
  83933. * @param materials array of materials
  83934. * @param imageData mapping of texture names to base64 textures
  83935. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83936. */
  83937. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83938. /**
  83939. * Makes a copy of the glTF material without the texture parameters
  83940. * @param originalMaterial original glTF material
  83941. * @returns glTF material without texture parameters
  83942. */
  83943. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83944. /**
  83945. * Specifies if the material has any texture parameters present
  83946. * @param material glTF Material
  83947. * @returns boolean specifying if texture parameters are present
  83948. */
  83949. _hasTexturesPresent(material: IMaterial): boolean;
  83950. /**
  83951. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83952. * @param babylonStandardMaterial
  83953. * @returns glTF Metallic Roughness Material representation
  83954. */
  83955. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83956. /**
  83957. * Computes the metallic factor
  83958. * @param diffuse diffused value
  83959. * @param specular specular value
  83960. * @param oneMinusSpecularStrength one minus the specular strength
  83961. * @returns metallic value
  83962. */
  83963. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83964. /**
  83965. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83966. * @param glTFMaterial glTF material
  83967. * @param babylonMaterial Babylon material
  83968. */
  83969. private static _SetAlphaMode;
  83970. /**
  83971. * Converts a Babylon Standard Material to a glTF Material
  83972. * @param babylonStandardMaterial BJS Standard Material
  83973. * @param mimeType mime type to use for the textures
  83974. * @param images array of glTF image interfaces
  83975. * @param textures array of glTF texture interfaces
  83976. * @param materials array of glTF material interfaces
  83977. * @param imageData map of image file name to data
  83978. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83979. */
  83980. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83981. private _finishMaterial;
  83982. /**
  83983. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83984. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83985. * @param mimeType mime type to use for the textures
  83986. * @param images array of glTF image interfaces
  83987. * @param textures array of glTF texture interfaces
  83988. * @param materials array of glTF material interfaces
  83989. * @param imageData map of image file name to data
  83990. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83991. */
  83992. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83993. /**
  83994. * Converts an image typed array buffer to a base64 image
  83995. * @param buffer typed array buffer
  83996. * @param width width of the image
  83997. * @param height height of the image
  83998. * @param mimeType mimetype of the image
  83999. * @returns base64 image string
  84000. */
  84001. private _createBase64FromCanvasAsync;
  84002. /**
  84003. * Generates a white texture based on the specified width and height
  84004. * @param width width of the texture in pixels
  84005. * @param height height of the texture in pixels
  84006. * @param scene babylonjs scene
  84007. * @returns white texture
  84008. */
  84009. private _createWhiteTexture;
  84010. /**
  84011. * 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
  84012. * @param texture1 first texture to resize
  84013. * @param texture2 second texture to resize
  84014. * @param scene babylonjs scene
  84015. * @returns resized textures or null
  84016. */
  84017. private _resizeTexturesToSameDimensions;
  84018. /**
  84019. * Converts an array of pixels to a Float32Array
  84020. * Throws an error if the pixel format is not supported
  84021. * @param pixels - array buffer containing pixel values
  84022. * @returns Float32 of pixels
  84023. */
  84024. private _convertPixelArrayToFloat32;
  84025. /**
  84026. * Convert Specular Glossiness Textures to Metallic Roughness
  84027. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84028. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84029. * @param diffuseTexture texture used to store diffuse information
  84030. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84031. * @param factors specular glossiness material factors
  84032. * @param mimeType the mime type to use for the texture
  84033. * @returns pbr metallic roughness interface or null
  84034. */
  84035. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84036. /**
  84037. * Converts specular glossiness material properties to metallic roughness
  84038. * @param specularGlossiness interface with specular glossiness material properties
  84039. * @returns interface with metallic roughness material properties
  84040. */
  84041. private _convertSpecularGlossinessToMetallicRoughness;
  84042. /**
  84043. * Calculates the surface reflectance, independent of lighting conditions
  84044. * @param color Color source to calculate brightness from
  84045. * @returns number representing the perceived brightness, or zero if color is undefined
  84046. */
  84047. private _getPerceivedBrightness;
  84048. /**
  84049. * Returns the maximum color component value
  84050. * @param color
  84051. * @returns maximum color component value, or zero if color is null or undefined
  84052. */
  84053. private _getMaxComponent;
  84054. /**
  84055. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84056. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84057. * @param mimeType mime type to use for the textures
  84058. * @param images array of glTF image interfaces
  84059. * @param textures array of glTF texture interfaces
  84060. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84061. * @param imageData map of image file name to data
  84062. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84063. * @returns glTF PBR Metallic Roughness factors
  84064. */
  84065. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84066. private _getGLTFTextureSampler;
  84067. private _getGLTFTextureWrapMode;
  84068. private _getGLTFTextureWrapModesSampler;
  84069. /**
  84070. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84071. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84072. * @param mimeType mime type to use for the textures
  84073. * @param images array of glTF image interfaces
  84074. * @param textures array of glTF texture interfaces
  84075. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84076. * @param imageData map of image file name to data
  84077. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84078. * @returns glTF PBR Metallic Roughness factors
  84079. */
  84080. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84081. /**
  84082. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84083. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84084. * @param mimeType mime type to use for the textures
  84085. * @param images array of glTF image interfaces
  84086. * @param textures array of glTF texture interfaces
  84087. * @param materials array of glTF material interfaces
  84088. * @param imageData map of image file name to data
  84089. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84090. */
  84091. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84092. private setMetallicRoughnessPbrMaterial;
  84093. private getPixelsFromTexture;
  84094. /**
  84095. * Extracts a texture from a Babylon texture into file data and glTF data
  84096. * @param babylonTexture Babylon texture to extract
  84097. * @param mimeType Mime Type of the babylonTexture
  84098. * @return glTF texture info, or null if the texture format is not supported
  84099. */
  84100. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84101. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84102. /**
  84103. * Builds a texture from base64 string
  84104. * @param base64Texture base64 texture string
  84105. * @param baseTextureName Name to use for the texture
  84106. * @param mimeType image mime type for the texture
  84107. * @param images array of images
  84108. * @param textures array of textures
  84109. * @param imageData map of image data
  84110. * @returns glTF texture info, or null if the texture format is not supported
  84111. */
  84112. private _getTextureInfoFromBase64;
  84113. }
  84114. }
  84115. declare module BABYLON {
  84116. /**
  84117. * Class for holding and downloading glTF file data
  84118. */
  84119. export class GLTFData {
  84120. /**
  84121. * Object which contains the file name as the key and its data as the value
  84122. */
  84123. glTFFiles: {
  84124. [fileName: string]: string | Blob;
  84125. };
  84126. /**
  84127. * Initializes the glTF file object
  84128. */
  84129. constructor();
  84130. /**
  84131. * Downloads the glTF data as files based on their names and data
  84132. */
  84133. downloadFiles(): void;
  84134. }
  84135. }
  84136. declare module BABYLON {
  84137. /**
  84138. * Holds a collection of exporter options and parameters
  84139. */
  84140. export interface IExportOptions {
  84141. /**
  84142. * Function which indicates whether a babylon node should be exported or not
  84143. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84144. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84145. */
  84146. shouldExportNode?(node: Node): boolean;
  84147. /**
  84148. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84149. * @param metadata source metadata to read from
  84150. * @returns the data to store to glTF node extras
  84151. */
  84152. metadataSelector?(metadata: any): any;
  84153. /**
  84154. * The sample rate to bake animation curves
  84155. */
  84156. animationSampleRate?: number;
  84157. /**
  84158. * Begin serialization without waiting for the scene to be ready
  84159. */
  84160. exportWithoutWaitingForScene?: boolean;
  84161. /**
  84162. * Indicates if coordinate system swapping root nodes should be included in export
  84163. */
  84164. includeCoordinateSystemConversionNodes?: boolean;
  84165. }
  84166. /**
  84167. * Class for generating glTF data from a Babylon scene.
  84168. */
  84169. export class GLTF2Export {
  84170. /**
  84171. * Exports the geometry of the scene to .gltf file format asynchronously
  84172. * @param scene Babylon scene with scene hierarchy information
  84173. * @param filePrefix File prefix to use when generating the glTF file
  84174. * @param options Exporter options
  84175. * @returns Returns an object with a .gltf file and associates texture names
  84176. * as keys and their data and paths as values
  84177. */
  84178. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84179. private static _PreExportAsync;
  84180. private static _PostExportAsync;
  84181. /**
  84182. * Exports the geometry of the scene to .glb file format asychronously
  84183. * @param scene Babylon scene with scene hierarchy information
  84184. * @param filePrefix File prefix to use when generating glb file
  84185. * @param options Exporter options
  84186. * @returns Returns an object with a .glb filename as key and data as value
  84187. */
  84188. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84189. }
  84190. }
  84191. declare module BABYLON.GLTF2.Exporter {
  84192. /**
  84193. * @hidden
  84194. */
  84195. export class _GLTFUtilities {
  84196. /**
  84197. * Creates a buffer view based on the supplied arguments
  84198. * @param bufferIndex index value of the specified buffer
  84199. * @param byteOffset byte offset value
  84200. * @param byteLength byte length of the bufferView
  84201. * @param byteStride byte distance between conequential elements
  84202. * @param name name of the buffer view
  84203. * @returns bufferView for glTF
  84204. */
  84205. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84206. /**
  84207. * Creates an accessor based on the supplied arguments
  84208. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84209. * @param name The name of the accessor
  84210. * @param type The type of the accessor
  84211. * @param componentType The datatype of components in the attribute
  84212. * @param count The number of attributes referenced by this accessor
  84213. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84214. * @param min Minimum value of each component in this attribute
  84215. * @param max Maximum value of each component in this attribute
  84216. * @returns accessor for glTF
  84217. */
  84218. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84219. /**
  84220. * Calculates the minimum and maximum values of an array of position floats
  84221. * @param positions Positions array of a mesh
  84222. * @param vertexStart Starting vertex offset to calculate min and max values
  84223. * @param vertexCount Number of vertices to check for min and max values
  84224. * @returns min number array and max number array
  84225. */
  84226. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84227. min: number[];
  84228. max: number[];
  84229. };
  84230. /**
  84231. * Converts a new right-handed Vector3
  84232. * @param vector vector3 array
  84233. * @returns right-handed Vector3
  84234. */
  84235. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84236. /**
  84237. * Converts a Vector3 to right-handed
  84238. * @param vector Vector3 to convert to right-handed
  84239. */
  84240. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84241. /**
  84242. * Converts a three element number array to right-handed
  84243. * @param vector number array to convert to right-handed
  84244. */
  84245. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84246. /**
  84247. * Converts a new right-handed Vector3
  84248. * @param vector vector3 array
  84249. * @returns right-handed Vector3
  84250. */
  84251. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84252. /**
  84253. * Converts a Vector3 to right-handed
  84254. * @param vector Vector3 to convert to right-handed
  84255. */
  84256. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84257. /**
  84258. * Converts a three element number array to right-handed
  84259. * @param vector number array to convert to right-handed
  84260. */
  84261. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84262. /**
  84263. * Converts a Vector4 to right-handed
  84264. * @param vector Vector4 to convert to right-handed
  84265. */
  84266. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84267. /**
  84268. * Converts a Vector4 to right-handed
  84269. * @param vector Vector4 to convert to right-handed
  84270. */
  84271. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84272. /**
  84273. * Converts a Quaternion to right-handed
  84274. * @param quaternion Source quaternion to convert to right-handed
  84275. */
  84276. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84277. /**
  84278. * Converts a Quaternion to right-handed
  84279. * @param quaternion Source quaternion to convert to right-handed
  84280. */
  84281. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84282. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84283. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84284. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84285. }
  84286. }
  84287. declare module BABYLON.GLTF2.Exporter {
  84288. /**
  84289. * Converts Babylon Scene into glTF 2.0.
  84290. * @hidden
  84291. */
  84292. export class _Exporter {
  84293. /**
  84294. * Stores the glTF to export
  84295. */
  84296. _glTF: IGLTF;
  84297. /**
  84298. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84299. */
  84300. _bufferViews: IBufferView[];
  84301. /**
  84302. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84303. */
  84304. _accessors: IAccessor[];
  84305. /**
  84306. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84307. */
  84308. _nodes: INode[];
  84309. /**
  84310. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84311. */
  84312. private _scenes;
  84313. /**
  84314. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84315. */
  84316. private _meshes;
  84317. /**
  84318. * Stores all the generated material information, which represents the appearance of each primitive
  84319. */
  84320. _materials: IMaterial[];
  84321. _materialMap: {
  84322. [materialID: number]: number;
  84323. };
  84324. /**
  84325. * Stores all the generated texture information, which is referenced by glTF materials
  84326. */
  84327. _textures: ITexture[];
  84328. /**
  84329. * Stores all the generated image information, which is referenced by glTF textures
  84330. */
  84331. _images: IImage[];
  84332. /**
  84333. * Stores all the texture samplers
  84334. */
  84335. _samplers: ISampler[];
  84336. /**
  84337. * Stores all the generated glTF skins
  84338. */
  84339. _skins: ISkin[];
  84340. /**
  84341. * Stores all the generated animation samplers, which is referenced by glTF animations
  84342. */
  84343. /**
  84344. * Stores the animations for glTF models
  84345. */
  84346. private _animations;
  84347. /**
  84348. * Stores the total amount of bytes stored in the glTF buffer
  84349. */
  84350. private _totalByteLength;
  84351. /**
  84352. * Stores a reference to the Babylon scene containing the source geometry and material information
  84353. */
  84354. _babylonScene: Scene;
  84355. /**
  84356. * Stores a map of the image data, where the key is the file name and the value
  84357. * is the image data
  84358. */
  84359. _imageData: {
  84360. [fileName: string]: {
  84361. data: Uint8Array;
  84362. mimeType: ImageMimeType;
  84363. };
  84364. };
  84365. protected _orderedImageData: Array<{
  84366. data: Uint8Array;
  84367. mimeType: ImageMimeType;
  84368. }>;
  84369. /**
  84370. * Stores a map of the unique id of a node to its index in the node array
  84371. */
  84372. _nodeMap: {
  84373. [key: number]: number;
  84374. };
  84375. /**
  84376. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84377. */
  84378. _convertToRightHandedSystem: boolean;
  84379. /**
  84380. * Specifies if a Babylon node should be converted to right-handed on export
  84381. */
  84382. _convertToRightHandedSystemMap: {
  84383. [nodeId: number]: boolean;
  84384. };
  84385. _includeCoordinateSystemConversionNodes: boolean;
  84386. /**
  84387. * Baked animation sample rate
  84388. */
  84389. private _animationSampleRate;
  84390. private _options;
  84391. private _localEngine;
  84392. _glTFMaterialExporter: _GLTFMaterialExporter;
  84393. private _extensions;
  84394. private static _ExtensionNames;
  84395. private static _ExtensionFactories;
  84396. private _applyExtension;
  84397. private _applyExtensions;
  84398. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84399. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84400. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84401. [key: number]: number;
  84402. }): Promise<Nullable<INode>>;
  84403. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84404. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84405. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84406. private _forEachExtensions;
  84407. private _extensionsOnExporting;
  84408. /**
  84409. * Load glTF serializer extensions
  84410. */
  84411. private _loadExtensions;
  84412. /**
  84413. * Creates a glTF Exporter instance, which can accept optional exporter options
  84414. * @param babylonScene Babylon scene object
  84415. * @param options Options to modify the behavior of the exporter
  84416. */
  84417. constructor(babylonScene: Scene, options?: IExportOptions);
  84418. dispose(): void;
  84419. /**
  84420. * Registers a glTF exporter extension
  84421. * @param name Name of the extension to export
  84422. * @param factory The factory function that creates the exporter extension
  84423. */
  84424. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84425. /**
  84426. * Un-registers an exporter extension
  84427. * @param name The name fo the exporter extension
  84428. * @returns A boolean indicating whether the extension has been un-registered
  84429. */
  84430. static UnregisterExtension(name: string): boolean;
  84431. /**
  84432. * Lazy load a local engine
  84433. */
  84434. _getLocalEngine(): Engine;
  84435. private reorderIndicesBasedOnPrimitiveMode;
  84436. /**
  84437. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84438. * clock-wise during export to glTF
  84439. * @param submesh BabylonJS submesh
  84440. * @param primitiveMode Primitive mode of the mesh
  84441. * @param sideOrientation the winding order of the submesh
  84442. * @param vertexBufferKind The type of vertex attribute
  84443. * @param meshAttributeArray The vertex attribute data
  84444. * @param byteOffset The offset to the binary data
  84445. * @param binaryWriter The binary data for the glTF file
  84446. * @param convertToRightHandedSystem Converts the values to right-handed
  84447. */
  84448. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84449. /**
  84450. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84451. * clock-wise during export to glTF
  84452. * @param submesh BabylonJS submesh
  84453. * @param primitiveMode Primitive mode of the mesh
  84454. * @param sideOrientation the winding order of the submesh
  84455. * @param vertexBufferKind The type of vertex attribute
  84456. * @param meshAttributeArray The vertex attribute data
  84457. * @param byteOffset The offset to the binary data
  84458. * @param binaryWriter The binary data for the glTF file
  84459. * @param convertToRightHandedSystem Converts the values to right-handed
  84460. */
  84461. private reorderTriangleFillMode;
  84462. /**
  84463. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84464. * clock-wise during export to glTF
  84465. * @param submesh BabylonJS submesh
  84466. * @param primitiveMode Primitive mode of the mesh
  84467. * @param sideOrientation the winding order of the submesh
  84468. * @param vertexBufferKind The type of vertex attribute
  84469. * @param meshAttributeArray The vertex attribute data
  84470. * @param byteOffset The offset to the binary data
  84471. * @param binaryWriter The binary data for the glTF file
  84472. * @param convertToRightHandedSystem Converts the values to right-handed
  84473. */
  84474. private reorderTriangleStripDrawMode;
  84475. /**
  84476. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84477. * clock-wise during export to glTF
  84478. * @param submesh BabylonJS submesh
  84479. * @param primitiveMode Primitive mode of the mesh
  84480. * @param sideOrientation the winding order of the submesh
  84481. * @param vertexBufferKind The type of vertex attribute
  84482. * @param meshAttributeArray The vertex attribute data
  84483. * @param byteOffset The offset to the binary data
  84484. * @param binaryWriter The binary data for the glTF file
  84485. * @param convertToRightHandedSystem Converts the values to right-handed
  84486. */
  84487. private reorderTriangleFanMode;
  84488. /**
  84489. * Writes the vertex attribute data to binary
  84490. * @param vertices The vertices to write to the binary writer
  84491. * @param byteOffset The offset into the binary writer to overwrite binary data
  84492. * @param vertexAttributeKind The vertex attribute type
  84493. * @param meshAttributeArray The vertex attribute data
  84494. * @param binaryWriter The writer containing the binary data
  84495. * @param convertToRightHandedSystem Converts the values to right-handed
  84496. */
  84497. private writeVertexAttributeData;
  84498. /**
  84499. * Writes mesh attribute data to a data buffer
  84500. * Returns the bytelength of the data
  84501. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84502. * @param meshAttributeArray Array containing the attribute data
  84503. * @param byteStride Specifies the space between data
  84504. * @param binaryWriter The buffer to write the binary data to
  84505. * @param convertToRightHandedSystem Converts the values to right-handed
  84506. */
  84507. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84508. /**
  84509. * Writes mesh attribute data to a data buffer
  84510. * Returns the bytelength of the data
  84511. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84512. * @param meshAttributeArray Array containing the attribute data
  84513. * @param byteStride Specifies the space between data
  84514. * @param binaryWriter The buffer to write the binary data to
  84515. * @param convertToRightHandedSystem Converts the values to right-handed
  84516. */
  84517. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84518. /**
  84519. * Generates glTF json data
  84520. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84521. * @param glTFPrefix Text to use when prefixing a glTF file
  84522. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84523. * @returns json data as string
  84524. */
  84525. private generateJSON;
  84526. /**
  84527. * Generates data for .gltf and .bin files based on the glTF prefix string
  84528. * @param glTFPrefix Text to use when prefixing a glTF file
  84529. * @param dispose Dispose the exporter
  84530. * @returns GLTFData with glTF file data
  84531. */
  84532. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84533. /**
  84534. * Creates a binary buffer for glTF
  84535. * @returns array buffer for binary data
  84536. */
  84537. private _generateBinaryAsync;
  84538. /**
  84539. * Pads the number to a multiple of 4
  84540. * @param num number to pad
  84541. * @returns padded number
  84542. */
  84543. private _getPadding;
  84544. /**
  84545. * @hidden
  84546. */
  84547. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84548. /**
  84549. * Sets the TRS for each node
  84550. * @param node glTF Node for storing the transformation data
  84551. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84552. * @param convertToRightHandedSystem Converts the values to right-handed
  84553. */
  84554. private setNodeTransformation;
  84555. private getVertexBufferFromMesh;
  84556. /**
  84557. * Creates a bufferview based on the vertices type for the Babylon mesh
  84558. * @param kind Indicates the type of vertices data
  84559. * @param componentType Indicates the numerical type used to store the data
  84560. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84561. * @param binaryWriter The buffer to write the bufferview data to
  84562. * @param convertToRightHandedSystem Converts the values to right-handed
  84563. */
  84564. private createBufferViewKind;
  84565. /**
  84566. * Creates a bufferview based on the vertices type for the Babylon mesh
  84567. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84568. * @param babylonMorphTarget the morph target to be exported
  84569. * @param binaryWriter The buffer to write the bufferview data to
  84570. * @param convertToRightHandedSystem Converts the values to right-handed
  84571. */
  84572. private setMorphTargetAttributes;
  84573. /**
  84574. * The primitive mode of the Babylon mesh
  84575. * @param babylonMesh The BabylonJS mesh
  84576. */
  84577. private getMeshPrimitiveMode;
  84578. /**
  84579. * Sets the primitive mode of the glTF mesh primitive
  84580. * @param meshPrimitive glTF mesh primitive
  84581. * @param primitiveMode The primitive mode
  84582. */
  84583. private setPrimitiveMode;
  84584. /**
  84585. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84586. * @param meshPrimitive glTF mesh primitive
  84587. * @param attributeKind vertex attribute
  84588. * @returns boolean specifying if uv coordinates are present
  84589. */
  84590. private setAttributeKind;
  84591. /**
  84592. * Sets data for the primitive attributes of each submesh
  84593. * @param mesh glTF Mesh object to store the primitive attribute information
  84594. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84595. * @param binaryWriter Buffer to write the attribute data to
  84596. * @param convertToRightHandedSystem Converts the values to right-handed
  84597. */
  84598. private setPrimitiveAttributesAsync;
  84599. /**
  84600. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84601. * @param node The node to check
  84602. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84603. */
  84604. private isBabylonCoordinateSystemConvertingNode;
  84605. /**
  84606. * Creates a glTF scene based on the array of meshes
  84607. * Returns the the total byte offset
  84608. * @param babylonScene Babylon scene to get the mesh data from
  84609. * @param binaryWriter Buffer to write binary data to
  84610. */
  84611. private createSceneAsync;
  84612. /**
  84613. * Creates a mapping of Node unique id to node index and handles animations
  84614. * @param babylonScene Babylon Scene
  84615. * @param nodes Babylon transform nodes
  84616. * @param binaryWriter Buffer to write binary data to
  84617. * @returns Node mapping of unique id to index
  84618. */
  84619. private createNodeMapAndAnimationsAsync;
  84620. /**
  84621. * Creates a glTF node from a Babylon mesh
  84622. * @param babylonMesh Source Babylon mesh
  84623. * @param binaryWriter Buffer for storing geometry data
  84624. * @param convertToRightHandedSystem Converts the values to right-handed
  84625. * @param nodeMap Node mapping of unique id to glTF node index
  84626. * @returns glTF node
  84627. */
  84628. private createNodeAsync;
  84629. /**
  84630. * Creates a glTF skin from a Babylon skeleton
  84631. * @param babylonScene Babylon Scene
  84632. * @param nodes Babylon transform nodes
  84633. * @param binaryWriter Buffer to write binary data to
  84634. * @returns Node mapping of unique id to index
  84635. */
  84636. private createSkinsAsync;
  84637. }
  84638. /**
  84639. * @hidden
  84640. *
  84641. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84642. */
  84643. export class _BinaryWriter {
  84644. /**
  84645. * Array buffer which stores all binary data
  84646. */
  84647. private _arrayBuffer;
  84648. /**
  84649. * View of the array buffer
  84650. */
  84651. private _dataView;
  84652. /**
  84653. * byte offset of data in array buffer
  84654. */
  84655. private _byteOffset;
  84656. /**
  84657. * Initialize binary writer with an initial byte length
  84658. * @param byteLength Initial byte length of the array buffer
  84659. */
  84660. constructor(byteLength: number);
  84661. /**
  84662. * Resize the array buffer to the specified byte length
  84663. * @param byteLength
  84664. */
  84665. private resizeBuffer;
  84666. /**
  84667. * Get an array buffer with the length of the byte offset
  84668. * @returns ArrayBuffer resized to the byte offset
  84669. */
  84670. getArrayBuffer(): ArrayBuffer;
  84671. /**
  84672. * Get the byte offset of the array buffer
  84673. * @returns byte offset
  84674. */
  84675. getByteOffset(): number;
  84676. /**
  84677. * Stores an UInt8 in the array buffer
  84678. * @param entry
  84679. * @param byteOffset If defined, specifies where to set the value as an offset.
  84680. */
  84681. setUInt8(entry: number, byteOffset?: number): void;
  84682. /**
  84683. * Stores an UInt16 in the array buffer
  84684. * @param entry
  84685. * @param byteOffset If defined, specifies where to set the value as an offset.
  84686. */
  84687. setUInt16(entry: number, byteOffset?: number): void;
  84688. /**
  84689. * Gets an UInt32 in the array buffer
  84690. * @param entry
  84691. * @param byteOffset If defined, specifies where to set the value as an offset.
  84692. */
  84693. getUInt32(byteOffset: number): number;
  84694. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84695. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84696. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84697. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84698. /**
  84699. * Stores a Float32 in the array buffer
  84700. * @param entry
  84701. */
  84702. setFloat32(entry: number, byteOffset?: number): void;
  84703. /**
  84704. * Stores an UInt32 in the array buffer
  84705. * @param entry
  84706. * @param byteOffset If defined, specifies where to set the value as an offset.
  84707. */
  84708. setUInt32(entry: number, byteOffset?: number): void;
  84709. }
  84710. }
  84711. declare module BABYLON.GLTF2.Exporter {
  84712. /**
  84713. * @hidden
  84714. * Interface to store animation data.
  84715. */
  84716. export interface _IAnimationData {
  84717. /**
  84718. * Keyframe data.
  84719. */
  84720. inputs: number[];
  84721. /**
  84722. * Value data.
  84723. */
  84724. outputs: number[][];
  84725. /**
  84726. * Animation interpolation data.
  84727. */
  84728. samplerInterpolation: AnimationSamplerInterpolation;
  84729. /**
  84730. * Minimum keyframe value.
  84731. */
  84732. inputsMin: number;
  84733. /**
  84734. * Maximum keyframe value.
  84735. */
  84736. inputsMax: number;
  84737. }
  84738. /**
  84739. * @hidden
  84740. */
  84741. export interface _IAnimationInfo {
  84742. /**
  84743. * The target channel for the animation
  84744. */
  84745. animationChannelTargetPath: AnimationChannelTargetPath;
  84746. /**
  84747. * The glTF accessor type for the data.
  84748. */
  84749. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84750. /**
  84751. * Specifies if quaternions should be used.
  84752. */
  84753. useQuaternion: boolean;
  84754. }
  84755. /**
  84756. * @hidden
  84757. * Utility class for generating glTF animation data from BabylonJS.
  84758. */
  84759. export class _GLTFAnimation {
  84760. /**
  84761. * @ignore
  84762. *
  84763. * Creates glTF channel animation from BabylonJS animation.
  84764. * @param babylonTransformNode - BabylonJS mesh.
  84765. * @param animation - animation.
  84766. * @param animationChannelTargetPath - The target animation channel.
  84767. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84768. * @param useQuaternion - Specifies if quaternions are used.
  84769. * @returns nullable IAnimationData
  84770. */
  84771. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84772. private static _DeduceAnimationInfo;
  84773. /**
  84774. * @ignore
  84775. * Create node animations from the transform node animations
  84776. * @param babylonNode
  84777. * @param runtimeGLTFAnimation
  84778. * @param idleGLTFAnimations
  84779. * @param nodeMap
  84780. * @param nodes
  84781. * @param binaryWriter
  84782. * @param bufferViews
  84783. * @param accessors
  84784. * @param convertToRightHandedSystem
  84785. * @param animationSampleRate
  84786. */
  84787. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84788. [key: number]: number;
  84789. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84790. /**
  84791. * @ignore
  84792. * Create individual morph animations from the mesh's morph target animation tracks
  84793. * @param babylonNode
  84794. * @param runtimeGLTFAnimation
  84795. * @param idleGLTFAnimations
  84796. * @param nodeMap
  84797. * @param nodes
  84798. * @param binaryWriter
  84799. * @param bufferViews
  84800. * @param accessors
  84801. * @param convertToRightHandedSystem
  84802. * @param animationSampleRate
  84803. */
  84804. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84805. [key: number]: number;
  84806. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84807. /**
  84808. * @ignore
  84809. * Create node and morph animations from the animation groups
  84810. * @param babylonScene
  84811. * @param glTFAnimations
  84812. * @param nodeMap
  84813. * @param nodes
  84814. * @param binaryWriter
  84815. * @param bufferViews
  84816. * @param accessors
  84817. * @param convertToRightHandedSystemMap
  84818. * @param animationSampleRate
  84819. */
  84820. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84821. [key: number]: number;
  84822. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84823. [nodeId: number]: boolean;
  84824. }, animationSampleRate: number): void;
  84825. private static AddAnimation;
  84826. /**
  84827. * Create a baked animation
  84828. * @param babylonTransformNode BabylonJS mesh
  84829. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84830. * @param animationChannelTargetPath animation target channel
  84831. * @param minFrame minimum animation frame
  84832. * @param maxFrame maximum animation frame
  84833. * @param fps frames per second of the animation
  84834. * @param inputs input key frames of the animation
  84835. * @param outputs output key frame data of the animation
  84836. * @param convertToRightHandedSystem converts the values to right-handed
  84837. * @param useQuaternion specifies if quaternions should be used
  84838. */
  84839. private static _CreateBakedAnimation;
  84840. private static _ConvertFactorToVector3OrQuaternion;
  84841. private static _SetInterpolatedValue;
  84842. /**
  84843. * Creates linear animation from the animation key frames
  84844. * @param babylonTransformNode BabylonJS mesh
  84845. * @param animation BabylonJS animation
  84846. * @param animationChannelTargetPath The target animation channel
  84847. * @param frameDelta The difference between the last and first frame of the animation
  84848. * @param inputs Array to store the key frame times
  84849. * @param outputs Array to store the key frame data
  84850. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84851. * @param useQuaternion Specifies if quaternions are used in the animation
  84852. */
  84853. private static _CreateLinearOrStepAnimation;
  84854. /**
  84855. * Creates cubic spline animation from the animation key frames
  84856. * @param babylonTransformNode BabylonJS mesh
  84857. * @param animation BabylonJS animation
  84858. * @param animationChannelTargetPath The target animation channel
  84859. * @param frameDelta The difference between the last and first frame of the animation
  84860. * @param inputs Array to store the key frame times
  84861. * @param outputs Array to store the key frame data
  84862. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84863. * @param useQuaternion Specifies if quaternions are used in the animation
  84864. */
  84865. private static _CreateCubicSplineAnimation;
  84866. private static _GetBasePositionRotationOrScale;
  84867. /**
  84868. * Adds a key frame value
  84869. * @param keyFrame
  84870. * @param animation
  84871. * @param outputs
  84872. * @param animationChannelTargetPath
  84873. * @param basePositionRotationOrScale
  84874. * @param convertToRightHandedSystem
  84875. * @param useQuaternion
  84876. */
  84877. private static _AddKeyframeValue;
  84878. /**
  84879. * Determine the interpolation based on the key frames
  84880. * @param keyFrames
  84881. * @param animationChannelTargetPath
  84882. * @param useQuaternion
  84883. */
  84884. private static _DeduceInterpolation;
  84885. /**
  84886. * Adds an input tangent or output tangent to the output data
  84887. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84888. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84889. * @param outputs The animation data by keyframe
  84890. * @param animationChannelTargetPath The target animation channel
  84891. * @param interpolation The interpolation type
  84892. * @param keyFrame The key frame with the animation data
  84893. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84894. * @param useQuaternion Specifies if quaternions are used
  84895. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84896. */
  84897. private static AddSplineTangent;
  84898. /**
  84899. * Get the minimum and maximum key frames' frame values
  84900. * @param keyFrames animation key frames
  84901. * @returns the minimum and maximum key frame value
  84902. */
  84903. private static calculateMinMaxKeyFrames;
  84904. }
  84905. }
  84906. declare module BABYLON.GLTF2.Exporter {
  84907. /** @hidden */
  84908. export var textureTransformPixelShader: {
  84909. name: string;
  84910. shader: string;
  84911. };
  84912. }
  84913. declare module BABYLON.GLTF2.Exporter.Extensions {
  84914. /**
  84915. * @hidden
  84916. */
  84917. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84918. private _recordedTextures;
  84919. /** Name of this extension */
  84920. readonly name: string;
  84921. /** Defines whether this extension is enabled */
  84922. enabled: boolean;
  84923. /** Defines whether this extension is required */
  84924. required: boolean;
  84925. /** Reference to the glTF exporter */
  84926. private _wasUsed;
  84927. constructor(exporter: _Exporter);
  84928. dispose(): void;
  84929. /** @hidden */
  84930. get wasUsed(): boolean;
  84931. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84932. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84933. /**
  84934. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84935. * @param babylonTexture
  84936. * @param offset
  84937. * @param rotation
  84938. * @param scale
  84939. * @param scene
  84940. */
  84941. private _textureTransformTextureAsync;
  84942. }
  84943. }
  84944. declare module BABYLON.GLTF2.Exporter.Extensions {
  84945. /**
  84946. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84947. */
  84948. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84949. /** The name of this extension. */
  84950. readonly name: string;
  84951. /** Defines whether this extension is enabled. */
  84952. enabled: boolean;
  84953. /** Defines whether this extension is required */
  84954. required: boolean;
  84955. /** Reference to the glTF exporter */
  84956. private _exporter;
  84957. private _lights;
  84958. /** @hidden */
  84959. constructor(exporter: _Exporter);
  84960. /** @hidden */
  84961. dispose(): void;
  84962. /** @hidden */
  84963. get wasUsed(): boolean;
  84964. /** @hidden */
  84965. onExporting(): void;
  84966. /**
  84967. * Define this method to modify the default behavior when exporting a node
  84968. * @param context The context when exporting the node
  84969. * @param node glTF node
  84970. * @param babylonNode BabylonJS node
  84971. * @param nodeMap Node mapping of unique id to glTF node index
  84972. * @returns nullable INode promise
  84973. */
  84974. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84975. [key: number]: number;
  84976. }): Promise<Nullable<INode>>;
  84977. }
  84978. }
  84979. declare module BABYLON.GLTF2.Exporter.Extensions {
  84980. /**
  84981. * @hidden
  84982. */
  84983. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84984. /** Name of this extension */
  84985. readonly name: string;
  84986. /** Defines whether this extension is enabled */
  84987. enabled: boolean;
  84988. /** Defines whether this extension is required */
  84989. required: boolean;
  84990. /** Reference to the glTF exporter */
  84991. private _textureInfos;
  84992. private _exportedTextures;
  84993. private _wasUsed;
  84994. constructor(exporter: _Exporter);
  84995. dispose(): void;
  84996. /** @hidden */
  84997. get wasUsed(): boolean;
  84998. private _getTextureIndex;
  84999. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85000. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85001. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85002. }
  85003. }
  85004. declare module BABYLON.GLTF2.Exporter.Extensions {
  85005. /**
  85006. * @hidden
  85007. */
  85008. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85009. /** Name of this extension */
  85010. readonly name: string;
  85011. /** Defines whether this extension is enabled */
  85012. enabled: boolean;
  85013. /** Defines whether this extension is required */
  85014. required: boolean;
  85015. private _wasUsed;
  85016. constructor(exporter: _Exporter);
  85017. /** @hidden */
  85018. get wasUsed(): boolean;
  85019. dispose(): void;
  85020. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85021. }
  85022. }
  85023. declare module BABYLON {
  85024. /**
  85025. * Class for generating STL data from a Babylon scene.
  85026. */
  85027. export class STLExport {
  85028. /**
  85029. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85030. * @param meshes list defines the mesh to serialize
  85031. * @param download triggers the automatic download of the file.
  85032. * @param fileName changes the downloads fileName.
  85033. * @param binary changes the STL to a binary type.
  85034. * @param isLittleEndian toggle for binary type exporter.
  85035. * @returns the STL as UTF8 string
  85036. */
  85037. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85038. }
  85039. }
  85040. declare module "babylonjs-gltf2interface" {
  85041. export = BABYLON.GLTF2;
  85042. }
  85043. /**
  85044. * Module for glTF 2.0 Interface
  85045. */
  85046. declare module BABYLON.GLTF2 {
  85047. /**
  85048. * The datatype of the components in the attribute
  85049. */
  85050. const enum AccessorComponentType {
  85051. /**
  85052. * Byte
  85053. */
  85054. BYTE = 5120,
  85055. /**
  85056. * Unsigned Byte
  85057. */
  85058. UNSIGNED_BYTE = 5121,
  85059. /**
  85060. * Short
  85061. */
  85062. SHORT = 5122,
  85063. /**
  85064. * Unsigned Short
  85065. */
  85066. UNSIGNED_SHORT = 5123,
  85067. /**
  85068. * Unsigned Int
  85069. */
  85070. UNSIGNED_INT = 5125,
  85071. /**
  85072. * Float
  85073. */
  85074. FLOAT = 5126,
  85075. }
  85076. /**
  85077. * Specifies if the attirbute is a scalar, vector, or matrix
  85078. */
  85079. const enum AccessorType {
  85080. /**
  85081. * Scalar
  85082. */
  85083. SCALAR = "SCALAR",
  85084. /**
  85085. * Vector2
  85086. */
  85087. VEC2 = "VEC2",
  85088. /**
  85089. * Vector3
  85090. */
  85091. VEC3 = "VEC3",
  85092. /**
  85093. * Vector4
  85094. */
  85095. VEC4 = "VEC4",
  85096. /**
  85097. * Matrix2x2
  85098. */
  85099. MAT2 = "MAT2",
  85100. /**
  85101. * Matrix3x3
  85102. */
  85103. MAT3 = "MAT3",
  85104. /**
  85105. * Matrix4x4
  85106. */
  85107. MAT4 = "MAT4",
  85108. }
  85109. /**
  85110. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85111. */
  85112. const enum AnimationChannelTargetPath {
  85113. /**
  85114. * Translation
  85115. */
  85116. TRANSLATION = "translation",
  85117. /**
  85118. * Rotation
  85119. */
  85120. ROTATION = "rotation",
  85121. /**
  85122. * Scale
  85123. */
  85124. SCALE = "scale",
  85125. /**
  85126. * Weights
  85127. */
  85128. WEIGHTS = "weights",
  85129. }
  85130. /**
  85131. * Interpolation algorithm
  85132. */
  85133. const enum AnimationSamplerInterpolation {
  85134. /**
  85135. * The animated values are linearly interpolated between keyframes
  85136. */
  85137. LINEAR = "LINEAR",
  85138. /**
  85139. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85140. */
  85141. STEP = "STEP",
  85142. /**
  85143. * The animation's interpolation is computed using a cubic spline with specified tangents
  85144. */
  85145. CUBICSPLINE = "CUBICSPLINE",
  85146. }
  85147. /**
  85148. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85149. */
  85150. const enum CameraType {
  85151. /**
  85152. * A perspective camera containing properties to create a perspective projection matrix
  85153. */
  85154. PERSPECTIVE = "perspective",
  85155. /**
  85156. * An orthographic camera containing properties to create an orthographic projection matrix
  85157. */
  85158. ORTHOGRAPHIC = "orthographic",
  85159. }
  85160. /**
  85161. * The mime-type of the image
  85162. */
  85163. const enum ImageMimeType {
  85164. /**
  85165. * JPEG Mime-type
  85166. */
  85167. JPEG = "image/jpeg",
  85168. /**
  85169. * PNG Mime-type
  85170. */
  85171. PNG = "image/png",
  85172. }
  85173. /**
  85174. * The alpha rendering mode of the material
  85175. */
  85176. const enum MaterialAlphaMode {
  85177. /**
  85178. * The alpha value is ignored and the rendered output is fully opaque
  85179. */
  85180. OPAQUE = "OPAQUE",
  85181. /**
  85182. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85183. */
  85184. MASK = "MASK",
  85185. /**
  85186. * 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)
  85187. */
  85188. BLEND = "BLEND",
  85189. }
  85190. /**
  85191. * The type of the primitives to render
  85192. */
  85193. const enum MeshPrimitiveMode {
  85194. /**
  85195. * Points
  85196. */
  85197. POINTS = 0,
  85198. /**
  85199. * Lines
  85200. */
  85201. LINES = 1,
  85202. /**
  85203. * Line Loop
  85204. */
  85205. LINE_LOOP = 2,
  85206. /**
  85207. * Line Strip
  85208. */
  85209. LINE_STRIP = 3,
  85210. /**
  85211. * Triangles
  85212. */
  85213. TRIANGLES = 4,
  85214. /**
  85215. * Triangle Strip
  85216. */
  85217. TRIANGLE_STRIP = 5,
  85218. /**
  85219. * Triangle Fan
  85220. */
  85221. TRIANGLE_FAN = 6,
  85222. }
  85223. /**
  85224. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85225. */
  85226. const enum TextureMagFilter {
  85227. /**
  85228. * Nearest
  85229. */
  85230. NEAREST = 9728,
  85231. /**
  85232. * Linear
  85233. */
  85234. LINEAR = 9729,
  85235. }
  85236. /**
  85237. * Minification filter. All valid values correspond to WebGL enums
  85238. */
  85239. const enum TextureMinFilter {
  85240. /**
  85241. * Nearest
  85242. */
  85243. NEAREST = 9728,
  85244. /**
  85245. * Linear
  85246. */
  85247. LINEAR = 9729,
  85248. /**
  85249. * Nearest Mip-Map Nearest
  85250. */
  85251. NEAREST_MIPMAP_NEAREST = 9984,
  85252. /**
  85253. * Linear Mipmap Nearest
  85254. */
  85255. LINEAR_MIPMAP_NEAREST = 9985,
  85256. /**
  85257. * Nearest Mipmap Linear
  85258. */
  85259. NEAREST_MIPMAP_LINEAR = 9986,
  85260. /**
  85261. * Linear Mipmap Linear
  85262. */
  85263. LINEAR_MIPMAP_LINEAR = 9987,
  85264. }
  85265. /**
  85266. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85267. */
  85268. const enum TextureWrapMode {
  85269. /**
  85270. * Clamp to Edge
  85271. */
  85272. CLAMP_TO_EDGE = 33071,
  85273. /**
  85274. * Mirrored Repeat
  85275. */
  85276. MIRRORED_REPEAT = 33648,
  85277. /**
  85278. * Repeat
  85279. */
  85280. REPEAT = 10497,
  85281. }
  85282. /**
  85283. * glTF Property
  85284. */
  85285. interface IProperty {
  85286. /**
  85287. * Dictionary object with extension-specific objects
  85288. */
  85289. extensions?: {
  85290. [key: string]: any;
  85291. };
  85292. /**
  85293. * Application-Specific data
  85294. */
  85295. extras?: any;
  85296. }
  85297. /**
  85298. * glTF Child of Root Property
  85299. */
  85300. interface IChildRootProperty extends IProperty {
  85301. /**
  85302. * The user-defined name of this object
  85303. */
  85304. name?: string;
  85305. }
  85306. /**
  85307. * Indices of those attributes that deviate from their initialization value
  85308. */
  85309. interface IAccessorSparseIndices extends IProperty {
  85310. /**
  85311. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85312. */
  85313. bufferView: number;
  85314. /**
  85315. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85316. */
  85317. byteOffset?: number;
  85318. /**
  85319. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85320. */
  85321. componentType: AccessorComponentType;
  85322. }
  85323. /**
  85324. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85325. */
  85326. interface IAccessorSparseValues extends IProperty {
  85327. /**
  85328. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85329. */
  85330. bufferView: number;
  85331. /**
  85332. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85333. */
  85334. byteOffset?: number;
  85335. }
  85336. /**
  85337. * Sparse storage of attributes that deviate from their initialization value
  85338. */
  85339. interface IAccessorSparse extends IProperty {
  85340. /**
  85341. * The number of attributes encoded in this sparse accessor
  85342. */
  85343. count: number;
  85344. /**
  85345. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85346. */
  85347. indices: IAccessorSparseIndices;
  85348. /**
  85349. * 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
  85350. */
  85351. values: IAccessorSparseValues;
  85352. }
  85353. /**
  85354. * 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
  85355. */
  85356. interface IAccessor extends IChildRootProperty {
  85357. /**
  85358. * The index of the bufferview
  85359. */
  85360. bufferView?: number;
  85361. /**
  85362. * The offset relative to the start of the bufferView in bytes
  85363. */
  85364. byteOffset?: number;
  85365. /**
  85366. * The datatype of components in the attribute
  85367. */
  85368. componentType: AccessorComponentType;
  85369. /**
  85370. * Specifies whether integer data values should be normalized
  85371. */
  85372. normalized?: boolean;
  85373. /**
  85374. * The number of attributes referenced by this accessor
  85375. */
  85376. count: number;
  85377. /**
  85378. * Specifies if the attribute is a scalar, vector, or matrix
  85379. */
  85380. type: AccessorType;
  85381. /**
  85382. * Maximum value of each component in this attribute
  85383. */
  85384. max?: number[];
  85385. /**
  85386. * Minimum value of each component in this attribute
  85387. */
  85388. min?: number[];
  85389. /**
  85390. * Sparse storage of attributes that deviate from their initialization value
  85391. */
  85392. sparse?: IAccessorSparse;
  85393. }
  85394. /**
  85395. * Targets an animation's sampler at a node's property
  85396. */
  85397. interface IAnimationChannel extends IProperty {
  85398. /**
  85399. * The index of a sampler in this animation used to compute the value for the target
  85400. */
  85401. sampler: number;
  85402. /**
  85403. * The index of the node and TRS property to target
  85404. */
  85405. target: IAnimationChannelTarget;
  85406. }
  85407. /**
  85408. * The index of the node and TRS property that an animation channel targets
  85409. */
  85410. interface IAnimationChannelTarget extends IProperty {
  85411. /**
  85412. * The index of the node to target
  85413. */
  85414. node: number;
  85415. /**
  85416. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85417. */
  85418. path: AnimationChannelTargetPath;
  85419. }
  85420. /**
  85421. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85422. */
  85423. interface IAnimationSampler extends IProperty {
  85424. /**
  85425. * The index of an accessor containing keyframe input values, e.g., time
  85426. */
  85427. input: number;
  85428. /**
  85429. * Interpolation algorithm
  85430. */
  85431. interpolation?: AnimationSamplerInterpolation;
  85432. /**
  85433. * The index of an accessor, containing keyframe output values
  85434. */
  85435. output: number;
  85436. }
  85437. /**
  85438. * A keyframe animation
  85439. */
  85440. interface IAnimation extends IChildRootProperty {
  85441. /**
  85442. * An array of channels, each of which targets an animation's sampler at a node's property
  85443. */
  85444. channels: IAnimationChannel[];
  85445. /**
  85446. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85447. */
  85448. samplers: IAnimationSampler[];
  85449. }
  85450. /**
  85451. * Metadata about the glTF asset
  85452. */
  85453. interface IAsset extends IChildRootProperty {
  85454. /**
  85455. * A copyright message suitable for display to credit the content creator
  85456. */
  85457. copyright?: string;
  85458. /**
  85459. * Tool that generated this glTF model. Useful for debugging
  85460. */
  85461. generator?: string;
  85462. /**
  85463. * The glTF version that this asset targets
  85464. */
  85465. version: string;
  85466. /**
  85467. * The minimum glTF version that this asset targets
  85468. */
  85469. minVersion?: string;
  85470. }
  85471. /**
  85472. * A buffer points to binary geometry, animation, or skins
  85473. */
  85474. interface IBuffer extends IChildRootProperty {
  85475. /**
  85476. * 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
  85477. */
  85478. uri?: string;
  85479. /**
  85480. * The length of the buffer in bytes
  85481. */
  85482. byteLength: number;
  85483. }
  85484. /**
  85485. * A view into a buffer generally representing a subset of the buffer
  85486. */
  85487. interface IBufferView extends IChildRootProperty {
  85488. /**
  85489. * The index of the buffer
  85490. */
  85491. buffer: number;
  85492. /**
  85493. * The offset into the buffer in bytes
  85494. */
  85495. byteOffset?: number;
  85496. /**
  85497. * The lenth of the bufferView in bytes
  85498. */
  85499. byteLength: number;
  85500. /**
  85501. * The stride, in bytes
  85502. */
  85503. byteStride?: number;
  85504. }
  85505. /**
  85506. * An orthographic camera containing properties to create an orthographic projection matrix
  85507. */
  85508. interface ICameraOrthographic extends IProperty {
  85509. /**
  85510. * The floating-point horizontal magnification of the view. Must not be zero
  85511. */
  85512. xmag: number;
  85513. /**
  85514. * The floating-point vertical magnification of the view. Must not be zero
  85515. */
  85516. ymag: number;
  85517. /**
  85518. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85519. */
  85520. zfar: number;
  85521. /**
  85522. * The floating-point distance to the near clipping plane
  85523. */
  85524. znear: number;
  85525. }
  85526. /**
  85527. * A perspective camera containing properties to create a perspective projection matrix
  85528. */
  85529. interface ICameraPerspective extends IProperty {
  85530. /**
  85531. * The floating-point aspect ratio of the field of view
  85532. */
  85533. aspectRatio?: number;
  85534. /**
  85535. * The floating-point vertical field of view in radians
  85536. */
  85537. yfov: number;
  85538. /**
  85539. * The floating-point distance to the far clipping plane
  85540. */
  85541. zfar?: number;
  85542. /**
  85543. * The floating-point distance to the near clipping plane
  85544. */
  85545. znear: number;
  85546. }
  85547. /**
  85548. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85549. */
  85550. interface ICamera extends IChildRootProperty {
  85551. /**
  85552. * An orthographic camera containing properties to create an orthographic projection matrix
  85553. */
  85554. orthographic?: ICameraOrthographic;
  85555. /**
  85556. * A perspective camera containing properties to create a perspective projection matrix
  85557. */
  85558. perspective?: ICameraPerspective;
  85559. /**
  85560. * Specifies if the camera uses a perspective or orthographic projection
  85561. */
  85562. type: CameraType;
  85563. }
  85564. /**
  85565. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85566. */
  85567. interface IImage extends IChildRootProperty {
  85568. /**
  85569. * 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
  85570. */
  85571. uri?: string;
  85572. /**
  85573. * The image's MIME type
  85574. */
  85575. mimeType?: ImageMimeType;
  85576. /**
  85577. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85578. */
  85579. bufferView?: number;
  85580. }
  85581. /**
  85582. * Material Normal Texture Info
  85583. */
  85584. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85585. /**
  85586. * The scalar multiplier applied to each normal vector of the normal texture
  85587. */
  85588. scale?: number;
  85589. }
  85590. /**
  85591. * Material Occlusion Texture Info
  85592. */
  85593. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85594. /**
  85595. * A scalar multiplier controlling the amount of occlusion applied
  85596. */
  85597. strength?: number;
  85598. }
  85599. /**
  85600. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85601. */
  85602. interface IMaterialPbrMetallicRoughness {
  85603. /**
  85604. * The material's base color factor
  85605. */
  85606. baseColorFactor?: number[];
  85607. /**
  85608. * The base color texture
  85609. */
  85610. baseColorTexture?: ITextureInfo;
  85611. /**
  85612. * The metalness of the material
  85613. */
  85614. metallicFactor?: number;
  85615. /**
  85616. * The roughness of the material
  85617. */
  85618. roughnessFactor?: number;
  85619. /**
  85620. * The metallic-roughness texture
  85621. */
  85622. metallicRoughnessTexture?: ITextureInfo;
  85623. }
  85624. /**
  85625. * The material appearance of a primitive
  85626. */
  85627. interface IMaterial extends IChildRootProperty {
  85628. /**
  85629. * 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
  85630. */
  85631. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85632. /**
  85633. * The normal map texture
  85634. */
  85635. normalTexture?: IMaterialNormalTextureInfo;
  85636. /**
  85637. * The occlusion map texture
  85638. */
  85639. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85640. /**
  85641. * The emissive map texture
  85642. */
  85643. emissiveTexture?: ITextureInfo;
  85644. /**
  85645. * 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
  85646. */
  85647. emissiveFactor?: number[];
  85648. /**
  85649. * The alpha rendering mode of the material
  85650. */
  85651. alphaMode?: MaterialAlphaMode;
  85652. /**
  85653. * The alpha cutoff value of the material
  85654. */
  85655. alphaCutoff?: number;
  85656. /**
  85657. * Specifies whether the material is double sided
  85658. */
  85659. doubleSided?: boolean;
  85660. }
  85661. /**
  85662. * Geometry to be rendered with the given material
  85663. */
  85664. interface IMeshPrimitive extends IProperty {
  85665. /**
  85666. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85667. */
  85668. attributes: {
  85669. [name: string]: number;
  85670. };
  85671. /**
  85672. * The index of the accessor that contains the indices
  85673. */
  85674. indices?: number;
  85675. /**
  85676. * The index of the material to apply to this primitive when rendering
  85677. */
  85678. material?: number;
  85679. /**
  85680. * The type of primitives to render. All valid values correspond to WebGL enums
  85681. */
  85682. mode?: MeshPrimitiveMode;
  85683. /**
  85684. * 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
  85685. */
  85686. targets?: {
  85687. [name: string]: number;
  85688. }[];
  85689. }
  85690. /**
  85691. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85692. */
  85693. interface IMesh extends IChildRootProperty {
  85694. /**
  85695. * An array of primitives, each defining geometry to be rendered with a material
  85696. */
  85697. primitives: IMeshPrimitive[];
  85698. /**
  85699. * Array of weights to be applied to the Morph Targets
  85700. */
  85701. weights?: number[];
  85702. }
  85703. /**
  85704. * A node in the node hierarchy
  85705. */
  85706. interface INode extends IChildRootProperty {
  85707. /**
  85708. * The index of the camera referenced by this node
  85709. */
  85710. camera?: number;
  85711. /**
  85712. * The indices of this node's children
  85713. */
  85714. children?: number[];
  85715. /**
  85716. * The index of the skin referenced by this node
  85717. */
  85718. skin?: number;
  85719. /**
  85720. * A floating-point 4x4 transformation matrix stored in column-major order
  85721. */
  85722. matrix?: number[];
  85723. /**
  85724. * The index of the mesh in this node
  85725. */
  85726. mesh?: number;
  85727. /**
  85728. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85729. */
  85730. rotation?: number[];
  85731. /**
  85732. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85733. */
  85734. scale?: number[];
  85735. /**
  85736. * The node's translation along the x, y, and z axes
  85737. */
  85738. translation?: number[];
  85739. /**
  85740. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85741. */
  85742. weights?: number[];
  85743. }
  85744. /**
  85745. * Texture sampler properties for filtering and wrapping modes
  85746. */
  85747. interface ISampler extends IChildRootProperty {
  85748. /**
  85749. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85750. */
  85751. magFilter?: TextureMagFilter;
  85752. /**
  85753. * Minification filter. All valid values correspond to WebGL enums
  85754. */
  85755. minFilter?: TextureMinFilter;
  85756. /**
  85757. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85758. */
  85759. wrapS?: TextureWrapMode;
  85760. /**
  85761. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85762. */
  85763. wrapT?: TextureWrapMode;
  85764. }
  85765. /**
  85766. * The root nodes of a scene
  85767. */
  85768. interface IScene extends IChildRootProperty {
  85769. /**
  85770. * The indices of each root node
  85771. */
  85772. nodes: number[];
  85773. }
  85774. /**
  85775. * Joints and matrices defining a skin
  85776. */
  85777. interface ISkin extends IChildRootProperty {
  85778. /**
  85779. * 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
  85780. */
  85781. inverseBindMatrices?: number;
  85782. /**
  85783. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85784. */
  85785. skeleton?: number;
  85786. /**
  85787. * 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)
  85788. */
  85789. joints: number[];
  85790. }
  85791. /**
  85792. * A texture and its sampler
  85793. */
  85794. interface ITexture extends IChildRootProperty {
  85795. /**
  85796. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85797. */
  85798. sampler?: number;
  85799. /**
  85800. * The index of the image used by this texture
  85801. */
  85802. source: number;
  85803. }
  85804. /**
  85805. * Reference to a texture
  85806. */
  85807. interface ITextureInfo extends IProperty {
  85808. /**
  85809. * The index of the texture
  85810. */
  85811. index: number;
  85812. /**
  85813. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85814. */
  85815. texCoord?: number;
  85816. }
  85817. /**
  85818. * The root object for a glTF asset
  85819. */
  85820. interface IGLTF extends IProperty {
  85821. /**
  85822. * An array of accessors. An accessor is a typed view into a bufferView
  85823. */
  85824. accessors?: IAccessor[];
  85825. /**
  85826. * An array of keyframe animations
  85827. */
  85828. animations?: IAnimation[];
  85829. /**
  85830. * Metadata about the glTF asset
  85831. */
  85832. asset: IAsset;
  85833. /**
  85834. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85835. */
  85836. buffers?: IBuffer[];
  85837. /**
  85838. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85839. */
  85840. bufferViews?: IBufferView[];
  85841. /**
  85842. * An array of cameras
  85843. */
  85844. cameras?: ICamera[];
  85845. /**
  85846. * Names of glTF extensions used somewhere in this asset
  85847. */
  85848. extensionsUsed?: string[];
  85849. /**
  85850. * Names of glTF extensions required to properly load this asset
  85851. */
  85852. extensionsRequired?: string[];
  85853. /**
  85854. * An array of images. An image defines data used to create a texture
  85855. */
  85856. images?: IImage[];
  85857. /**
  85858. * An array of materials. A material defines the appearance of a primitive
  85859. */
  85860. materials?: IMaterial[];
  85861. /**
  85862. * An array of meshes. A mesh is a set of primitives to be rendered
  85863. */
  85864. meshes?: IMesh[];
  85865. /**
  85866. * An array of nodes
  85867. */
  85868. nodes?: INode[];
  85869. /**
  85870. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85871. */
  85872. samplers?: ISampler[];
  85873. /**
  85874. * The index of the default scene
  85875. */
  85876. scene?: number;
  85877. /**
  85878. * An array of scenes
  85879. */
  85880. scenes?: IScene[];
  85881. /**
  85882. * An array of skins. A skin is defined by joints and matrices
  85883. */
  85884. skins?: ISkin[];
  85885. /**
  85886. * An array of textures
  85887. */
  85888. textures?: ITexture[];
  85889. }
  85890. /**
  85891. * The glTF validation results
  85892. * @ignore
  85893. */
  85894. interface IGLTFValidationResults {
  85895. info: {
  85896. generator: string;
  85897. hasAnimations: boolean;
  85898. hasDefaultScene: boolean;
  85899. hasMaterials: boolean;
  85900. hasMorphTargets: boolean;
  85901. hasSkins: boolean;
  85902. hasTextures: boolean;
  85903. maxAttributesUsed: number;
  85904. primitivesCount: number
  85905. };
  85906. issues: {
  85907. messages: Array<string>;
  85908. numErrors: number;
  85909. numHints: number;
  85910. numInfos: number;
  85911. numWarnings: number;
  85912. truncated: boolean
  85913. };
  85914. mimeType: string;
  85915. uri: string;
  85916. validatedAt: string;
  85917. validatorVersion: string;
  85918. }
  85919. /**
  85920. * The glTF validation options
  85921. */
  85922. interface IGLTFValidationOptions {
  85923. /** Uri to use */
  85924. uri?: string;
  85925. /** Function used to load external resources */
  85926. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85927. /** Boolean indicating that we need to validate accessor data */
  85928. validateAccessorData?: boolean;
  85929. /** max number of issues allowed */
  85930. maxIssues?: number;
  85931. /** Ignored issues */
  85932. ignoredIssues?: Array<string>;
  85933. /** Value to override severy settings */
  85934. severityOverrides?: Object;
  85935. }
  85936. /**
  85937. * The glTF validator object
  85938. * @ignore
  85939. */
  85940. interface IGLTFValidator {
  85941. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85942. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85943. }
  85944. /**
  85945. * Interfaces from the EXT_lights_image_based extension
  85946. */
  85947. /** @hidden */
  85948. interface IEXTLightsImageBased_LightReferenceImageBased {
  85949. light: number;
  85950. }
  85951. /** @hidden */
  85952. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85953. intensity: number;
  85954. rotation: number[];
  85955. specularImageSize: number;
  85956. specularImages: number[][];
  85957. irradianceCoefficients: number[][];
  85958. }
  85959. /** @hidden */
  85960. interface IEXTLightsImageBased {
  85961. lights: IEXTLightsImageBased_LightImageBased[];
  85962. }
  85963. /**
  85964. * Interfaces from the EXT_mesh_gpu_instancing extension
  85965. * !!! Experimental Extension Subject to Changes !!!
  85966. */
  85967. /** @hidden */
  85968. interface IEXTMeshGpuInstancing {
  85969. mesh?: number;
  85970. attributes: { [name: string]: number };
  85971. }
  85972. /**
  85973. * Interfaces from the KHR_draco_mesh_compression extension
  85974. */
  85975. /** @hidden */
  85976. interface IKHRDracoMeshCompression {
  85977. bufferView: number;
  85978. attributes: { [name: string]: number };
  85979. }
  85980. /**
  85981. * Interfaces from the KHR_lights_punctual extension
  85982. */
  85983. /** @hidden */
  85984. const enum IKHRLightsPunctual_LightType {
  85985. DIRECTIONAL = "directional",
  85986. POINT = "point",
  85987. SPOT = "spot"
  85988. }
  85989. /** @hidden */
  85990. interface IKHRLightsPunctual_LightReference {
  85991. light: number;
  85992. }
  85993. /** @hidden */
  85994. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85995. type: IKHRLightsPunctual_LightType;
  85996. color?: number[];
  85997. intensity?: number;
  85998. range?: number;
  85999. spot?: {
  86000. innerConeAngle?: number;
  86001. outerConeAngle?: number;
  86002. };
  86003. }
  86004. /** @hidden */
  86005. interface IKHRLightsPunctual {
  86006. lights: IKHRLightsPunctual_Light[];
  86007. }
  86008. /**
  86009. * Interfaces from the KHR_materials_clearcoat extension
  86010. * !!! Experimental Extension Subject to Changes !!!
  86011. */
  86012. /** @hidden */
  86013. interface IKHRMaterialsClearcoat {
  86014. clearcoatFactor: number;
  86015. clearcoatTexture: ITextureInfo;
  86016. clearcoatRoughnessFactor: number;
  86017. clearcoatRoughnessTexture: ITextureInfo;
  86018. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86019. }
  86020. /**
  86021. * Interfaces from the KHR_materials_ior extension
  86022. * !!! Experimental Extension Subject to Changes !!!
  86023. */
  86024. /** @hidden */
  86025. interface IKHRMaterialsIor {
  86026. ior: number;
  86027. }
  86028. /**
  86029. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86030. */
  86031. /** @hidden */
  86032. interface IKHRMaterialsPbrSpecularGlossiness {
  86033. diffuseFactor: number[];
  86034. diffuseTexture: ITextureInfo;
  86035. specularFactor: number[];
  86036. glossinessFactor: number;
  86037. specularGlossinessTexture: ITextureInfo;
  86038. }
  86039. /**
  86040. * Interfaces from the KHR_materials_sheen extension
  86041. * !!! Experimental Extension Subject to Changes !!!
  86042. */
  86043. /** @hidden */
  86044. interface IKHRMaterialsSheen {
  86045. sheenColorFactor?: number[];
  86046. sheenColorTexture?: ITextureInfo;
  86047. sheenRoughnessFactor?: number;
  86048. sheenRoughnessTexture?: ITextureInfo;
  86049. }
  86050. /**
  86051. * Interfaces from the KHR_materials_specular extension
  86052. * !!! Experimental Extension Subject to Changes !!!
  86053. */
  86054. /** @hidden */
  86055. interface IKHRMaterialsSpecular {
  86056. specularFactor: number;
  86057. specularColorFactor: number[];
  86058. specularTexture: ITextureInfo;
  86059. }
  86060. /**
  86061. * Interfaces from the KHR_materials_transmission extension
  86062. * !!! Experimental Extension Subject to Changes !!!
  86063. */
  86064. /** @hidden */
  86065. interface IKHRMaterialsTransmission {
  86066. transmissionFactor?: number;
  86067. transmissionTexture?: ITextureInfo;
  86068. }
  86069. /**
  86070. * Interfaces from the KHR_materials_variants extension
  86071. * !!! Experimental Extension Subject to Changes !!!
  86072. */
  86073. /** @hidden */
  86074. interface IKHRMaterialVariants_Mapping extends IProperty {
  86075. mappings: Array<{
  86076. variants: number[];
  86077. material: number;
  86078. }>;
  86079. }
  86080. /** @hidden */
  86081. interface IKHRMaterialVariants_Variant extends IProperty {
  86082. name: string;
  86083. }
  86084. /** @hidden */
  86085. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86086. variants: Array<IKHRMaterialVariants_Variant>;
  86087. }
  86088. /**
  86089. * Interfaces from the KHR_texture_basisu extension
  86090. * !!! Experimental Extension Subject to Changes !!!
  86091. */
  86092. /** @hidden */
  86093. interface IKHRTextureBasisU {
  86094. source: number;
  86095. }
  86096. /**
  86097. * Interfaces from the EXT_texture_webp extension
  86098. */
  86099. /** @hidden */
  86100. interface IEXTTextureWebP {
  86101. source: number;
  86102. }
  86103. /**
  86104. * Interfaces from the KHR_texture_transform extension
  86105. */
  86106. /** @hidden */
  86107. interface IKHRTextureTransform {
  86108. offset?: number[];
  86109. rotation?: number;
  86110. scale?: number[];
  86111. texCoord?: number;
  86112. }
  86113. /**
  86114. * Interfaces from the KHR_xmp extension
  86115. * !!! Experimental Extension Subject to Changes !!!
  86116. */
  86117. /** @hidden */
  86118. interface IKHRXmp_Data {
  86119. [key: string]: unknown;
  86120. }
  86121. /** @hidden */
  86122. interface IKHRXmp_Gltf {
  86123. packets: IKHRXmp_Data[];
  86124. }
  86125. /** @hidden */
  86126. interface IKHRXmp_Node {
  86127. packet: number;
  86128. }
  86129. /**
  86130. * Interfaces from the MSFT_audio_emitter extension
  86131. */
  86132. /** @hidden */
  86133. interface IMSFTAudioEmitter_ClipReference {
  86134. clip: number;
  86135. weight?: number;
  86136. }
  86137. /** @hidden */
  86138. interface IMSFTAudioEmitter_EmittersReference {
  86139. emitters: number[];
  86140. }
  86141. /** @hidden */
  86142. const enum IMSFTAudioEmitter_DistanceModel {
  86143. linear = "linear",
  86144. inverse = "inverse",
  86145. exponential = "exponential",
  86146. }
  86147. /** @hidden */
  86148. interface IMSFTAudioEmitter_Emitter {
  86149. name?: string;
  86150. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86151. refDistance?: number;
  86152. maxDistance?: number;
  86153. rolloffFactor?: number;
  86154. innerAngle?: number;
  86155. outerAngle?: number;
  86156. loop?: boolean;
  86157. volume?: number;
  86158. clips: IMSFTAudioEmitter_ClipReference[];
  86159. }
  86160. /** @hidden */
  86161. const enum IMSFTAudioEmitter_AudioMimeType {
  86162. WAV = "audio/wav",
  86163. }
  86164. /** @hidden */
  86165. interface IMSFTAudioEmitter_Clip extends IProperty {
  86166. uri?: string;
  86167. bufferView?: number;
  86168. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86169. }
  86170. /** @hidden */
  86171. const enum IMSFTAudioEmitter_AnimationEventAction {
  86172. play = "play",
  86173. pause = "pause",
  86174. stop = "stop",
  86175. }
  86176. /** @hidden */
  86177. interface IMSFTAudioEmitter_AnimationEvent {
  86178. action: IMSFTAudioEmitter_AnimationEventAction;
  86179. emitter: number;
  86180. time: number;
  86181. startOffset?: number;
  86182. }
  86183. /**
  86184. * Interfaces from the MSFT_lod extension
  86185. */
  86186. /** @hidden */
  86187. interface IMSFTLOD {
  86188. ids: number[];
  86189. }
  86190. }
  86191. declare module BABYLON {
  86192. /** @hidden */
  86193. export var cellPixelShader: {
  86194. name: string;
  86195. shader: string;
  86196. };
  86197. }
  86198. declare module BABYLON {
  86199. /** @hidden */
  86200. export var cellVertexShader: {
  86201. name: string;
  86202. shader: string;
  86203. };
  86204. }
  86205. declare module BABYLON {
  86206. export class CellMaterial extends BABYLON.PushMaterial {
  86207. private _diffuseTexture;
  86208. diffuseTexture: BABYLON.BaseTexture;
  86209. diffuseColor: BABYLON.Color3;
  86210. _computeHighLevel: boolean;
  86211. computeHighLevel: boolean;
  86212. private _disableLighting;
  86213. disableLighting: boolean;
  86214. private _maxSimultaneousLights;
  86215. maxSimultaneousLights: number;
  86216. constructor(name: string, scene: BABYLON.Scene);
  86217. needAlphaBlending(): boolean;
  86218. needAlphaTesting(): boolean;
  86219. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86220. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86221. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86222. getAnimatables(): BABYLON.IAnimatable[];
  86223. getActiveTextures(): BABYLON.BaseTexture[];
  86224. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86225. dispose(forceDisposeEffect?: boolean): void;
  86226. getClassName(): string;
  86227. clone(name: string): CellMaterial;
  86228. serialize(): any;
  86229. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86230. }
  86231. }
  86232. declare module BABYLON {
  86233. export class CustomShaderStructure {
  86234. FragmentStore: string;
  86235. VertexStore: string;
  86236. constructor();
  86237. }
  86238. export class ShaderSpecialParts {
  86239. constructor();
  86240. Fragment_Begin: string;
  86241. Fragment_Definitions: string;
  86242. Fragment_MainBegin: string;
  86243. Fragment_Custom_Diffuse: string;
  86244. Fragment_Before_Lights: string;
  86245. Fragment_Before_Fog: string;
  86246. Fragment_Custom_Alpha: string;
  86247. Fragment_Before_FragColor: string;
  86248. Vertex_Begin: string;
  86249. Vertex_Definitions: string;
  86250. Vertex_MainBegin: string;
  86251. Vertex_Before_PositionUpdated: string;
  86252. Vertex_Before_NormalUpdated: string;
  86253. Vertex_After_WorldPosComputed: string;
  86254. Vertex_MainEnd: string;
  86255. }
  86256. export class CustomMaterial extends BABYLON.StandardMaterial {
  86257. static ShaderIndexer: number;
  86258. CustomParts: ShaderSpecialParts;
  86259. _isCreatedShader: boolean;
  86260. _createdShaderName: string;
  86261. _customUniform: string[];
  86262. _newUniforms: string[];
  86263. _newUniformInstances: {
  86264. [name: string]: any;
  86265. };
  86266. _newSamplerInstances: {
  86267. [name: string]: BABYLON.Texture;
  86268. };
  86269. _customAttributes: string[];
  86270. FragmentShader: string;
  86271. VertexShader: string;
  86272. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86273. ReviewUniform(name: string, arr: string[]): string[];
  86274. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86275. constructor(name: string, scene: BABYLON.Scene);
  86276. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86277. AddAttribute(name: string): CustomMaterial;
  86278. Fragment_Begin(shaderPart: string): CustomMaterial;
  86279. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86280. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86281. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86282. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86283. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86284. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86285. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86286. Vertex_Begin(shaderPart: string): CustomMaterial;
  86287. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86288. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86289. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86290. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86291. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86292. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86293. }
  86294. }
  86295. declare module BABYLON {
  86296. export class ShaderAlebdoParts {
  86297. constructor();
  86298. Fragment_Begin: string;
  86299. Fragment_Definitions: string;
  86300. Fragment_MainBegin: string;
  86301. Fragment_Custom_Albedo: string;
  86302. Fragment_Before_Lights: string;
  86303. Fragment_Custom_MetallicRoughness: string;
  86304. Fragment_Custom_MicroSurface: string;
  86305. Fragment_Before_Fog: string;
  86306. Fragment_Custom_Alpha: string;
  86307. Fragment_Before_FragColor: string;
  86308. Vertex_Begin: string;
  86309. Vertex_Definitions: string;
  86310. Vertex_MainBegin: string;
  86311. Vertex_Before_PositionUpdated: string;
  86312. Vertex_Before_NormalUpdated: string;
  86313. Vertex_After_WorldPosComputed: string;
  86314. Vertex_MainEnd: string;
  86315. }
  86316. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86317. static ShaderIndexer: number;
  86318. CustomParts: ShaderAlebdoParts;
  86319. _isCreatedShader: boolean;
  86320. _createdShaderName: string;
  86321. _customUniform: string[];
  86322. _newUniforms: string[];
  86323. _newUniformInstances: {
  86324. [name: string]: any;
  86325. };
  86326. _newSamplerInstances: {
  86327. [name: string]: BABYLON.Texture;
  86328. };
  86329. _customAttributes: string[];
  86330. FragmentShader: string;
  86331. VertexShader: string;
  86332. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86333. ReviewUniform(name: string, arr: string[]): string[];
  86334. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86335. constructor(name: string, scene: BABYLON.Scene);
  86336. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86337. AddAttribute(name: string): PBRCustomMaterial;
  86338. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86339. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86340. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86341. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86342. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86343. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86344. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86345. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86346. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86347. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86348. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86349. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86350. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86351. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86352. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86353. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86354. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86355. }
  86356. }
  86357. declare module BABYLON {
  86358. /** @hidden */
  86359. export var firePixelShader: {
  86360. name: string;
  86361. shader: string;
  86362. };
  86363. }
  86364. declare module BABYLON {
  86365. /** @hidden */
  86366. export var fireVertexShader: {
  86367. name: string;
  86368. shader: string;
  86369. };
  86370. }
  86371. declare module BABYLON {
  86372. export class FireMaterial extends BABYLON.PushMaterial {
  86373. private _diffuseTexture;
  86374. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86375. private _distortionTexture;
  86376. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86377. private _opacityTexture;
  86378. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86379. diffuseColor: BABYLON.Color3;
  86380. speed: number;
  86381. private _scaledDiffuse;
  86382. private _lastTime;
  86383. constructor(name: string, scene: BABYLON.Scene);
  86384. needAlphaBlending(): boolean;
  86385. needAlphaTesting(): boolean;
  86386. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86387. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86388. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86389. getAnimatables(): BABYLON.IAnimatable[];
  86390. getActiveTextures(): BABYLON.BaseTexture[];
  86391. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86392. getClassName(): string;
  86393. dispose(forceDisposeEffect?: boolean): void;
  86394. clone(name: string): FireMaterial;
  86395. serialize(): any;
  86396. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86397. }
  86398. }
  86399. declare module BABYLON {
  86400. /** @hidden */
  86401. export var furPixelShader: {
  86402. name: string;
  86403. shader: string;
  86404. };
  86405. }
  86406. declare module BABYLON {
  86407. /** @hidden */
  86408. export var furVertexShader: {
  86409. name: string;
  86410. shader: string;
  86411. };
  86412. }
  86413. declare module BABYLON {
  86414. export class FurMaterial extends BABYLON.PushMaterial {
  86415. private _diffuseTexture;
  86416. diffuseTexture: BABYLON.BaseTexture;
  86417. private _heightTexture;
  86418. heightTexture: BABYLON.BaseTexture;
  86419. diffuseColor: BABYLON.Color3;
  86420. furLength: number;
  86421. furAngle: number;
  86422. furColor: BABYLON.Color3;
  86423. furOffset: number;
  86424. furSpacing: number;
  86425. furGravity: BABYLON.Vector3;
  86426. furSpeed: number;
  86427. furDensity: number;
  86428. furOcclusion: number;
  86429. furTexture: BABYLON.DynamicTexture;
  86430. private _disableLighting;
  86431. disableLighting: boolean;
  86432. private _maxSimultaneousLights;
  86433. maxSimultaneousLights: number;
  86434. highLevelFur: boolean;
  86435. _meshes: BABYLON.AbstractMesh[];
  86436. private _furTime;
  86437. constructor(name: string, scene: BABYLON.Scene);
  86438. get furTime(): number;
  86439. set furTime(furTime: number);
  86440. needAlphaBlending(): boolean;
  86441. needAlphaTesting(): boolean;
  86442. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86443. updateFur(): void;
  86444. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86445. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86446. getAnimatables(): BABYLON.IAnimatable[];
  86447. getActiveTextures(): BABYLON.BaseTexture[];
  86448. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86449. dispose(forceDisposeEffect?: boolean): void;
  86450. clone(name: string): FurMaterial;
  86451. serialize(): any;
  86452. getClassName(): string;
  86453. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86454. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86455. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86456. }
  86457. }
  86458. declare module BABYLON {
  86459. /** @hidden */
  86460. export var gradientPixelShader: {
  86461. name: string;
  86462. shader: string;
  86463. };
  86464. }
  86465. declare module BABYLON {
  86466. /** @hidden */
  86467. export var gradientVertexShader: {
  86468. name: string;
  86469. shader: string;
  86470. };
  86471. }
  86472. declare module BABYLON {
  86473. export class GradientMaterial extends BABYLON.PushMaterial {
  86474. private _maxSimultaneousLights;
  86475. maxSimultaneousLights: number;
  86476. topColor: BABYLON.Color3;
  86477. topColorAlpha: number;
  86478. bottomColor: BABYLON.Color3;
  86479. bottomColorAlpha: number;
  86480. offset: number;
  86481. scale: number;
  86482. smoothness: number;
  86483. private _disableLighting;
  86484. disableLighting: boolean;
  86485. constructor(name: string, scene: BABYLON.Scene);
  86486. needAlphaBlending(): boolean;
  86487. needAlphaTesting(): boolean;
  86488. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86489. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86490. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86491. getAnimatables(): BABYLON.IAnimatable[];
  86492. dispose(forceDisposeEffect?: boolean): void;
  86493. clone(name: string): GradientMaterial;
  86494. serialize(): any;
  86495. getClassName(): string;
  86496. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86497. }
  86498. }
  86499. declare module BABYLON {
  86500. /** @hidden */
  86501. export var gridPixelShader: {
  86502. name: string;
  86503. shader: string;
  86504. };
  86505. }
  86506. declare module BABYLON {
  86507. /** @hidden */
  86508. export var gridVertexShader: {
  86509. name: string;
  86510. shader: string;
  86511. };
  86512. }
  86513. declare module BABYLON {
  86514. /**
  86515. * The grid materials allows you to wrap any shape with a grid.
  86516. * Colors are customizable.
  86517. */
  86518. export class GridMaterial extends BABYLON.PushMaterial {
  86519. /**
  86520. * Main color of the grid (e.g. between lines)
  86521. */
  86522. mainColor: BABYLON.Color3;
  86523. /**
  86524. * Color of the grid lines.
  86525. */
  86526. lineColor: BABYLON.Color3;
  86527. /**
  86528. * The scale of the grid compared to unit.
  86529. */
  86530. gridRatio: number;
  86531. /**
  86532. * Allows setting an offset for the grid lines.
  86533. */
  86534. gridOffset: BABYLON.Vector3;
  86535. /**
  86536. * The frequency of thicker lines.
  86537. */
  86538. majorUnitFrequency: number;
  86539. /**
  86540. * The visibility of minor units in the grid.
  86541. */
  86542. minorUnitVisibility: number;
  86543. /**
  86544. * The grid opacity outside of the lines.
  86545. */
  86546. opacity: number;
  86547. /**
  86548. * Determine RBG output is premultiplied by alpha value.
  86549. */
  86550. preMultiplyAlpha: boolean;
  86551. private _opacityTexture;
  86552. opacityTexture: BABYLON.BaseTexture;
  86553. private _gridControl;
  86554. /**
  86555. * constructor
  86556. * @param name The name given to the material in order to identify it afterwards.
  86557. * @param scene The scene the material is used in.
  86558. */
  86559. constructor(name: string, scene: BABYLON.Scene);
  86560. /**
  86561. * Returns wehter or not the grid requires alpha blending.
  86562. */
  86563. needAlphaBlending(): boolean;
  86564. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86565. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86566. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86567. /**
  86568. * Dispose the material and its associated resources.
  86569. * @param forceDisposeEffect will also dispose the used effect when true
  86570. */
  86571. dispose(forceDisposeEffect?: boolean): void;
  86572. clone(name: string): GridMaterial;
  86573. serialize(): any;
  86574. getClassName(): string;
  86575. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86576. }
  86577. }
  86578. declare module BABYLON {
  86579. /** @hidden */
  86580. export var lavaPixelShader: {
  86581. name: string;
  86582. shader: string;
  86583. };
  86584. }
  86585. declare module BABYLON {
  86586. /** @hidden */
  86587. export var lavaVertexShader: {
  86588. name: string;
  86589. shader: string;
  86590. };
  86591. }
  86592. declare module BABYLON {
  86593. export class LavaMaterial extends BABYLON.PushMaterial {
  86594. private _diffuseTexture;
  86595. diffuseTexture: BABYLON.BaseTexture;
  86596. noiseTexture: BABYLON.BaseTexture;
  86597. fogColor: BABYLON.Color3;
  86598. speed: number;
  86599. movingSpeed: number;
  86600. lowFrequencySpeed: number;
  86601. fogDensity: number;
  86602. private _lastTime;
  86603. diffuseColor: BABYLON.Color3;
  86604. private _disableLighting;
  86605. disableLighting: boolean;
  86606. private _unlit;
  86607. unlit: boolean;
  86608. private _maxSimultaneousLights;
  86609. maxSimultaneousLights: number;
  86610. private _scaledDiffuse;
  86611. constructor(name: string, scene: BABYLON.Scene);
  86612. needAlphaBlending(): boolean;
  86613. needAlphaTesting(): boolean;
  86614. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86616. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86617. getAnimatables(): BABYLON.IAnimatable[];
  86618. getActiveTextures(): BABYLON.BaseTexture[];
  86619. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86620. dispose(forceDisposeEffect?: boolean): void;
  86621. clone(name: string): LavaMaterial;
  86622. serialize(): any;
  86623. getClassName(): string;
  86624. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86625. }
  86626. }
  86627. declare module BABYLON {
  86628. /** @hidden */
  86629. export var mixPixelShader: {
  86630. name: string;
  86631. shader: string;
  86632. };
  86633. }
  86634. declare module BABYLON {
  86635. /** @hidden */
  86636. export var mixVertexShader: {
  86637. name: string;
  86638. shader: string;
  86639. };
  86640. }
  86641. declare module BABYLON {
  86642. export class MixMaterial extends BABYLON.PushMaterial {
  86643. /**
  86644. * Mix textures
  86645. */
  86646. private _mixTexture1;
  86647. mixTexture1: BABYLON.BaseTexture;
  86648. private _mixTexture2;
  86649. mixTexture2: BABYLON.BaseTexture;
  86650. /**
  86651. * Diffuse textures
  86652. */
  86653. private _diffuseTexture1;
  86654. diffuseTexture1: BABYLON.Texture;
  86655. private _diffuseTexture2;
  86656. diffuseTexture2: BABYLON.Texture;
  86657. private _diffuseTexture3;
  86658. diffuseTexture3: BABYLON.Texture;
  86659. private _diffuseTexture4;
  86660. diffuseTexture4: BABYLON.Texture;
  86661. private _diffuseTexture5;
  86662. diffuseTexture5: BABYLON.Texture;
  86663. private _diffuseTexture6;
  86664. diffuseTexture6: BABYLON.Texture;
  86665. private _diffuseTexture7;
  86666. diffuseTexture7: BABYLON.Texture;
  86667. private _diffuseTexture8;
  86668. diffuseTexture8: BABYLON.Texture;
  86669. /**
  86670. * Uniforms
  86671. */
  86672. diffuseColor: BABYLON.Color3;
  86673. specularColor: BABYLON.Color3;
  86674. specularPower: number;
  86675. private _disableLighting;
  86676. disableLighting: boolean;
  86677. private _maxSimultaneousLights;
  86678. maxSimultaneousLights: number;
  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): MixMaterial;
  86690. serialize(): any;
  86691. getClassName(): string;
  86692. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86693. }
  86694. }
  86695. declare module BABYLON {
  86696. /** @hidden */
  86697. export var normalPixelShader: {
  86698. name: string;
  86699. shader: string;
  86700. };
  86701. }
  86702. declare module BABYLON {
  86703. /** @hidden */
  86704. export var normalVertexShader: {
  86705. name: string;
  86706. shader: string;
  86707. };
  86708. }
  86709. declare module BABYLON {
  86710. export class NormalMaterial extends BABYLON.PushMaterial {
  86711. private _diffuseTexture;
  86712. diffuseTexture: BABYLON.BaseTexture;
  86713. diffuseColor: BABYLON.Color3;
  86714. private _disableLighting;
  86715. disableLighting: boolean;
  86716. private _maxSimultaneousLights;
  86717. maxSimultaneousLights: number;
  86718. constructor(name: string, scene: BABYLON.Scene);
  86719. needAlphaBlending(): boolean;
  86720. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86721. needAlphaTesting(): boolean;
  86722. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86723. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86724. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86725. getAnimatables(): BABYLON.IAnimatable[];
  86726. getActiveTextures(): BABYLON.BaseTexture[];
  86727. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86728. dispose(forceDisposeEffect?: boolean): void;
  86729. clone(name: string): NormalMaterial;
  86730. serialize(): any;
  86731. getClassName(): string;
  86732. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86733. }
  86734. }
  86735. declare module BABYLON {
  86736. /** @hidden */
  86737. export var shadowOnlyPixelShader: {
  86738. name: string;
  86739. shader: string;
  86740. };
  86741. }
  86742. declare module BABYLON {
  86743. /** @hidden */
  86744. export var shadowOnlyVertexShader: {
  86745. name: string;
  86746. shader: string;
  86747. };
  86748. }
  86749. declare module BABYLON {
  86750. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86751. private _activeLight;
  86752. private _needAlphaBlending;
  86753. constructor(name: string, scene: BABYLON.Scene);
  86754. shadowColor: BABYLON.Color3;
  86755. needAlphaBlending(): boolean;
  86756. needAlphaTesting(): boolean;
  86757. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86758. get activeLight(): BABYLON.IShadowLight;
  86759. set activeLight(light: BABYLON.IShadowLight);
  86760. private _getFirstShadowLightForMesh;
  86761. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86762. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86763. clone(name: string): ShadowOnlyMaterial;
  86764. serialize(): any;
  86765. getClassName(): string;
  86766. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86767. }
  86768. }
  86769. declare module BABYLON {
  86770. /** @hidden */
  86771. export var simplePixelShader: {
  86772. name: string;
  86773. shader: string;
  86774. };
  86775. }
  86776. declare module BABYLON {
  86777. /** @hidden */
  86778. export var simpleVertexShader: {
  86779. name: string;
  86780. shader: string;
  86781. };
  86782. }
  86783. declare module BABYLON {
  86784. export class SimpleMaterial extends BABYLON.PushMaterial {
  86785. private _diffuseTexture;
  86786. diffuseTexture: BABYLON.BaseTexture;
  86787. diffuseColor: BABYLON.Color3;
  86788. private _disableLighting;
  86789. disableLighting: boolean;
  86790. private _maxSimultaneousLights;
  86791. maxSimultaneousLights: number;
  86792. constructor(name: string, scene: BABYLON.Scene);
  86793. needAlphaBlending(): boolean;
  86794. needAlphaTesting(): boolean;
  86795. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86796. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86797. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86798. getAnimatables(): BABYLON.IAnimatable[];
  86799. getActiveTextures(): BABYLON.BaseTexture[];
  86800. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86801. dispose(forceDisposeEffect?: boolean): void;
  86802. clone(name: string): SimpleMaterial;
  86803. serialize(): any;
  86804. getClassName(): string;
  86805. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86806. }
  86807. }
  86808. declare module BABYLON {
  86809. /** @hidden */
  86810. export var skyPixelShader: {
  86811. name: string;
  86812. shader: string;
  86813. };
  86814. }
  86815. declare module BABYLON {
  86816. /** @hidden */
  86817. export var skyVertexShader: {
  86818. name: string;
  86819. shader: string;
  86820. };
  86821. }
  86822. declare module BABYLON {
  86823. /**
  86824. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86825. * @see https://doc.babylonjs.com/extensions/sky
  86826. */
  86827. export class SkyMaterial extends BABYLON.PushMaterial {
  86828. /**
  86829. * Defines the overall luminance of sky in interval ]0, 1[.
  86830. */
  86831. luminance: number;
  86832. /**
  86833. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86834. */
  86835. turbidity: number;
  86836. /**
  86837. * Defines the sky appearance (light intensity).
  86838. */
  86839. rayleigh: number;
  86840. /**
  86841. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86842. */
  86843. mieCoefficient: number;
  86844. /**
  86845. * Defines the amount of haze particles following the Mie scattering theory.
  86846. */
  86847. mieDirectionalG: number;
  86848. /**
  86849. * Defines the distance of the sun according to the active scene camera.
  86850. */
  86851. distance: number;
  86852. /**
  86853. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86854. * "inclined".
  86855. */
  86856. inclination: number;
  86857. /**
  86858. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86859. * an object direction and a reference direction.
  86860. */
  86861. azimuth: number;
  86862. /**
  86863. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86864. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86865. */
  86866. sunPosition: BABYLON.Vector3;
  86867. /**
  86868. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86869. * .sunPosition property.
  86870. */
  86871. useSunPosition: boolean;
  86872. /**
  86873. * Defines an offset vector used to get a horizon offset.
  86874. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86875. */
  86876. cameraOffset: BABYLON.Vector3;
  86877. private _cameraPosition;
  86878. /**
  86879. * Instantiates a new sky material.
  86880. * This material allows to create dynamic and texture free
  86881. * effects for skyboxes by taking care of the atmosphere state.
  86882. * @see https://doc.babylonjs.com/extensions/sky
  86883. * @param name Define the name of the material in the scene
  86884. * @param scene Define the scene the material belong to
  86885. */
  86886. constructor(name: string, scene: BABYLON.Scene);
  86887. /**
  86888. * Specifies if the material will require alpha blending
  86889. * @returns a boolean specifying if alpha blending is needed
  86890. */
  86891. needAlphaBlending(): boolean;
  86892. /**
  86893. * Specifies if this material should be rendered in alpha test mode
  86894. * @returns false as the sky material doesn't need alpha testing.
  86895. */
  86896. needAlphaTesting(): boolean;
  86897. /**
  86898. * Get the texture used for alpha test purpose.
  86899. * @returns null as the sky material has no texture.
  86900. */
  86901. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86902. /**
  86903. * Get if the submesh is ready to be used and all its information available.
  86904. * Child classes can use it to update shaders
  86905. * @param mesh defines the mesh to check
  86906. * @param subMesh defines which submesh to check
  86907. * @param useInstances specifies that instances should be used
  86908. * @returns a boolean indicating that the submesh is ready or not
  86909. */
  86910. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86911. /**
  86912. * Binds the submesh to this material by preparing the effect and shader to draw
  86913. * @param world defines the world transformation matrix
  86914. * @param mesh defines the mesh containing the submesh
  86915. * @param subMesh defines the submesh to bind the material to
  86916. */
  86917. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86918. /**
  86919. * Get the list of animatables in the material.
  86920. * @returns the list of animatables object used in the material
  86921. */
  86922. getAnimatables(): BABYLON.IAnimatable[];
  86923. /**
  86924. * Disposes the material
  86925. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86926. */
  86927. dispose(forceDisposeEffect?: boolean): void;
  86928. /**
  86929. * Makes a duplicate of the material, and gives it a new name
  86930. * @param name defines the new name for the duplicated material
  86931. * @returns the cloned material
  86932. */
  86933. clone(name: string): SkyMaterial;
  86934. /**
  86935. * Serializes this material in a JSON representation
  86936. * @returns the serialized material object
  86937. */
  86938. serialize(): any;
  86939. /**
  86940. * Gets the current class name of the material e.g. "SkyMaterial"
  86941. * Mainly use in serialization.
  86942. * @returns the class name
  86943. */
  86944. getClassName(): string;
  86945. /**
  86946. * Creates a sky material from parsed material data
  86947. * @param source defines the JSON representation of the material
  86948. * @param scene defines the hosting scene
  86949. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86950. * @returns a new sky material
  86951. */
  86952. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86953. }
  86954. }
  86955. declare module BABYLON {
  86956. /** @hidden */
  86957. export var terrainPixelShader: {
  86958. name: string;
  86959. shader: string;
  86960. };
  86961. }
  86962. declare module BABYLON {
  86963. /** @hidden */
  86964. export var terrainVertexShader: {
  86965. name: string;
  86966. shader: string;
  86967. };
  86968. }
  86969. declare module BABYLON {
  86970. export class TerrainMaterial extends BABYLON.PushMaterial {
  86971. private _mixTexture;
  86972. mixTexture: BABYLON.BaseTexture;
  86973. private _diffuseTexture1;
  86974. diffuseTexture1: BABYLON.Texture;
  86975. private _diffuseTexture2;
  86976. diffuseTexture2: BABYLON.Texture;
  86977. private _diffuseTexture3;
  86978. diffuseTexture3: BABYLON.Texture;
  86979. private _bumpTexture1;
  86980. bumpTexture1: BABYLON.Texture;
  86981. private _bumpTexture2;
  86982. bumpTexture2: BABYLON.Texture;
  86983. private _bumpTexture3;
  86984. bumpTexture3: BABYLON.Texture;
  86985. diffuseColor: BABYLON.Color3;
  86986. specularColor: BABYLON.Color3;
  86987. specularPower: number;
  86988. private _disableLighting;
  86989. disableLighting: boolean;
  86990. private _maxSimultaneousLights;
  86991. maxSimultaneousLights: number;
  86992. constructor(name: string, scene: BABYLON.Scene);
  86993. needAlphaBlending(): boolean;
  86994. needAlphaTesting(): boolean;
  86995. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86996. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86997. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86998. getAnimatables(): BABYLON.IAnimatable[];
  86999. getActiveTextures(): BABYLON.BaseTexture[];
  87000. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87001. dispose(forceDisposeEffect?: boolean): void;
  87002. clone(name: string): TerrainMaterial;
  87003. serialize(): any;
  87004. getClassName(): string;
  87005. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87006. }
  87007. }
  87008. declare module BABYLON {
  87009. /** @hidden */
  87010. export var triplanarPixelShader: {
  87011. name: string;
  87012. shader: string;
  87013. };
  87014. }
  87015. declare module BABYLON {
  87016. /** @hidden */
  87017. export var triplanarVertexShader: {
  87018. name: string;
  87019. shader: string;
  87020. };
  87021. }
  87022. declare module BABYLON {
  87023. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87024. mixTexture: BABYLON.BaseTexture;
  87025. private _diffuseTextureX;
  87026. diffuseTextureX: BABYLON.BaseTexture;
  87027. private _diffuseTextureY;
  87028. diffuseTextureY: BABYLON.BaseTexture;
  87029. private _diffuseTextureZ;
  87030. diffuseTextureZ: BABYLON.BaseTexture;
  87031. private _normalTextureX;
  87032. normalTextureX: BABYLON.BaseTexture;
  87033. private _normalTextureY;
  87034. normalTextureY: BABYLON.BaseTexture;
  87035. private _normalTextureZ;
  87036. normalTextureZ: BABYLON.BaseTexture;
  87037. tileSize: number;
  87038. diffuseColor: BABYLON.Color3;
  87039. specularColor: BABYLON.Color3;
  87040. specularPower: number;
  87041. private _disableLighting;
  87042. disableLighting: boolean;
  87043. private _maxSimultaneousLights;
  87044. maxSimultaneousLights: number;
  87045. constructor(name: string, scene: BABYLON.Scene);
  87046. needAlphaBlending(): boolean;
  87047. needAlphaTesting(): boolean;
  87048. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87049. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87050. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87051. getAnimatables(): BABYLON.IAnimatable[];
  87052. getActiveTextures(): BABYLON.BaseTexture[];
  87053. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87054. dispose(forceDisposeEffect?: boolean): void;
  87055. clone(name: string): TriPlanarMaterial;
  87056. serialize(): any;
  87057. getClassName(): string;
  87058. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87059. }
  87060. }
  87061. declare module BABYLON {
  87062. /** @hidden */
  87063. export var waterPixelShader: {
  87064. name: string;
  87065. shader: string;
  87066. };
  87067. }
  87068. declare module BABYLON {
  87069. /** @hidden */
  87070. export var waterVertexShader: {
  87071. name: string;
  87072. shader: string;
  87073. };
  87074. }
  87075. declare module BABYLON {
  87076. export class WaterMaterial extends BABYLON.PushMaterial {
  87077. renderTargetSize: BABYLON.Vector2;
  87078. private _bumpTexture;
  87079. bumpTexture: BABYLON.BaseTexture;
  87080. diffuseColor: BABYLON.Color3;
  87081. specularColor: BABYLON.Color3;
  87082. specularPower: number;
  87083. private _disableLighting;
  87084. disableLighting: boolean;
  87085. private _maxSimultaneousLights;
  87086. maxSimultaneousLights: number;
  87087. /**
  87088. * Defines the wind force.
  87089. */
  87090. windForce: number;
  87091. /**
  87092. * Defines the direction of the wind in the plane (X, Z).
  87093. */
  87094. windDirection: BABYLON.Vector2;
  87095. /**
  87096. * Defines the height of the waves.
  87097. */
  87098. waveHeight: number;
  87099. /**
  87100. * Defines the bump height related to the bump map.
  87101. */
  87102. bumpHeight: number;
  87103. /**
  87104. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87105. */
  87106. private _bumpSuperimpose;
  87107. bumpSuperimpose: boolean;
  87108. /**
  87109. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87110. */
  87111. private _fresnelSeparate;
  87112. fresnelSeparate: boolean;
  87113. /**
  87114. * Defines wether or not bump Wwves modify the reflection.
  87115. */
  87116. private _bumpAffectsReflection;
  87117. bumpAffectsReflection: boolean;
  87118. /**
  87119. * Defines the water color blended with the refraction (near).
  87120. */
  87121. waterColor: BABYLON.Color3;
  87122. /**
  87123. * Defines the blend factor related to the water color.
  87124. */
  87125. colorBlendFactor: number;
  87126. /**
  87127. * Defines the water color blended with the reflection (far).
  87128. */
  87129. waterColor2: BABYLON.Color3;
  87130. /**
  87131. * Defines the blend factor related to the water color (reflection, far).
  87132. */
  87133. colorBlendFactor2: number;
  87134. /**
  87135. * Defines the maximum length of a wave.
  87136. */
  87137. waveLength: number;
  87138. /**
  87139. * Defines the waves speed.
  87140. */
  87141. waveSpeed: number;
  87142. /**
  87143. * 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.
  87144. */
  87145. waveCount: number;
  87146. /**
  87147. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87148. * will avoid calculating useless pixels in the pixel shader of the water material.
  87149. */
  87150. disableClipPlane: boolean;
  87151. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87152. private _mesh;
  87153. private _refractionRTT;
  87154. private _reflectionRTT;
  87155. private _reflectionTransform;
  87156. private _lastTime;
  87157. private _lastDeltaTime;
  87158. private _useLogarithmicDepth;
  87159. private _waitingRenderList;
  87160. private _imageProcessingConfiguration;
  87161. private _imageProcessingObserver;
  87162. /**
  87163. * Gets a boolean indicating that current material needs to register RTT
  87164. */
  87165. get hasRenderTargetTextures(): boolean;
  87166. /**
  87167. * Constructor
  87168. */
  87169. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87170. get useLogarithmicDepth(): boolean;
  87171. set useLogarithmicDepth(value: boolean);
  87172. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87173. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87174. addToRenderList(node: any): void;
  87175. enableRenderTargets(enable: boolean): void;
  87176. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87177. get renderTargetsEnabled(): boolean;
  87178. needAlphaBlending(): boolean;
  87179. needAlphaTesting(): boolean;
  87180. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87181. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87182. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87183. private _createRenderTargets;
  87184. getAnimatables(): BABYLON.IAnimatable[];
  87185. getActiveTextures(): BABYLON.BaseTexture[];
  87186. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87187. dispose(forceDisposeEffect?: boolean): void;
  87188. clone(name: string): WaterMaterial;
  87189. serialize(): any;
  87190. getClassName(): string;
  87191. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87192. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87193. }
  87194. }
  87195. declare module BABYLON {
  87196. /** @hidden */
  87197. export var asciiartPixelShader: {
  87198. name: string;
  87199. shader: string;
  87200. };
  87201. }
  87202. declare module BABYLON {
  87203. /**
  87204. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87205. *
  87206. * It basically takes care rendering the font front the given font size to a texture.
  87207. * This is used later on in the postprocess.
  87208. */
  87209. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87210. private _font;
  87211. private _text;
  87212. private _charSize;
  87213. /**
  87214. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87215. */
  87216. get charSize(): number;
  87217. /**
  87218. * Create a new instance of the Ascii Art FontTexture class
  87219. * @param name the name of the texture
  87220. * @param font the font to use, use the W3C CSS notation
  87221. * @param text the caracter set to use in the rendering.
  87222. * @param scene the scene that owns the texture
  87223. */
  87224. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87225. /**
  87226. * Gets the max char width of a font.
  87227. * @param font the font to use, use the W3C CSS notation
  87228. * @return the max char width
  87229. */
  87230. private getFontWidth;
  87231. /**
  87232. * Gets the max char height of a font.
  87233. * @param font the font to use, use the W3C CSS notation
  87234. * @return the max char height
  87235. */
  87236. private getFontHeight;
  87237. /**
  87238. * Clones the current AsciiArtTexture.
  87239. * @return the clone of the texture.
  87240. */
  87241. clone(): AsciiArtFontTexture;
  87242. /**
  87243. * Parses a json object representing the texture and returns an instance of it.
  87244. * @param source the source JSON representation
  87245. * @param scene the scene to create the texture for
  87246. * @return the parsed texture
  87247. */
  87248. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87249. }
  87250. /**
  87251. * Option available in the Ascii Art Post Process.
  87252. */
  87253. export interface IAsciiArtPostProcessOptions {
  87254. /**
  87255. * The font to use following the w3c font definition.
  87256. */
  87257. font?: string;
  87258. /**
  87259. * The character set to use in the postprocess.
  87260. */
  87261. characterSet?: string;
  87262. /**
  87263. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87264. * This number is defined between 0 and 1;
  87265. */
  87266. mixToTile?: number;
  87267. /**
  87268. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87269. * This number is defined between 0 and 1;
  87270. */
  87271. mixToNormal?: number;
  87272. }
  87273. /**
  87274. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87275. *
  87276. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87277. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87278. */
  87279. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87280. /**
  87281. * The font texture used to render the char in the post process.
  87282. */
  87283. private _asciiArtFontTexture;
  87284. /**
  87285. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87286. * This number is defined between 0 and 1;
  87287. */
  87288. mixToTile: number;
  87289. /**
  87290. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87291. * This number is defined between 0 and 1;
  87292. */
  87293. mixToNormal: number;
  87294. /**
  87295. * Instantiates a new Ascii Art Post Process.
  87296. * @param name the name to give to the postprocess
  87297. * @camera the camera to apply the post process to.
  87298. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87299. */
  87300. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87301. }
  87302. }
  87303. declare module BABYLON {
  87304. /** @hidden */
  87305. export var digitalrainPixelShader: {
  87306. name: string;
  87307. shader: string;
  87308. };
  87309. }
  87310. declare module BABYLON {
  87311. /**
  87312. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87313. *
  87314. * It basically takes care rendering the font front the given font size to a texture.
  87315. * This is used later on in the postprocess.
  87316. */
  87317. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87318. private _font;
  87319. private _text;
  87320. private _charSize;
  87321. /**
  87322. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87323. */
  87324. get charSize(): number;
  87325. /**
  87326. * Create a new instance of the Digital Rain FontTexture class
  87327. * @param name the name of the texture
  87328. * @param font the font to use, use the W3C CSS notation
  87329. * @param text the caracter set to use in the rendering.
  87330. * @param scene the scene that owns the texture
  87331. */
  87332. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87333. /**
  87334. * Gets the max char width of a font.
  87335. * @param font the font to use, use the W3C CSS notation
  87336. * @return the max char width
  87337. */
  87338. private getFontWidth;
  87339. /**
  87340. * Gets the max char height of a font.
  87341. * @param font the font to use, use the W3C CSS notation
  87342. * @return the max char height
  87343. */
  87344. private getFontHeight;
  87345. /**
  87346. * Clones the current DigitalRainFontTexture.
  87347. * @return the clone of the texture.
  87348. */
  87349. clone(): DigitalRainFontTexture;
  87350. /**
  87351. * Parses a json object representing the texture and returns an instance of it.
  87352. * @param source the source JSON representation
  87353. * @param scene the scene to create the texture for
  87354. * @return the parsed texture
  87355. */
  87356. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87357. }
  87358. /**
  87359. * Option available in the Digital Rain Post Process.
  87360. */
  87361. export interface IDigitalRainPostProcessOptions {
  87362. /**
  87363. * The font to use following the w3c font definition.
  87364. */
  87365. font?: string;
  87366. /**
  87367. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87368. * This number is defined between 0 and 1;
  87369. */
  87370. mixToTile?: number;
  87371. /**
  87372. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87373. * This number is defined between 0 and 1;
  87374. */
  87375. mixToNormal?: number;
  87376. }
  87377. /**
  87378. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87379. *
  87380. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87381. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87382. */
  87383. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87384. /**
  87385. * The font texture used to render the char in the post process.
  87386. */
  87387. private _digitalRainFontTexture;
  87388. /**
  87389. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87390. * This number is defined between 0 and 1;
  87391. */
  87392. mixToTile: number;
  87393. /**
  87394. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87395. * This number is defined between 0 and 1;
  87396. */
  87397. mixToNormal: number;
  87398. /**
  87399. * Instantiates a new Digital Rain Post Process.
  87400. * @param name the name to give to the postprocess
  87401. * @camera the camera to apply the post process to.
  87402. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87403. */
  87404. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87405. }
  87406. }
  87407. declare module BABYLON {
  87408. /** @hidden */
  87409. export var brickProceduralTexturePixelShader: {
  87410. name: string;
  87411. shader: string;
  87412. };
  87413. }
  87414. declare module BABYLON {
  87415. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87416. private _numberOfBricksHeight;
  87417. private _numberOfBricksWidth;
  87418. private _jointColor;
  87419. private _brickColor;
  87420. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87421. updateShaderUniforms(): void;
  87422. get numberOfBricksHeight(): number;
  87423. set numberOfBricksHeight(value: number);
  87424. get numberOfBricksWidth(): number;
  87425. set numberOfBricksWidth(value: number);
  87426. get jointColor(): BABYLON.Color3;
  87427. set jointColor(value: BABYLON.Color3);
  87428. get brickColor(): BABYLON.Color3;
  87429. set brickColor(value: BABYLON.Color3);
  87430. /**
  87431. * Serializes this brick procedural texture
  87432. * @returns a serialized brick procedural texture object
  87433. */
  87434. serialize(): any;
  87435. /**
  87436. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87437. * @param parsedTexture defines parsed texture data
  87438. * @param scene defines the current scene
  87439. * @param rootUrl defines the root URL containing brick procedural texture information
  87440. * @returns a parsed Brick Procedural BABYLON.Texture
  87441. */
  87442. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87443. }
  87444. }
  87445. declare module BABYLON {
  87446. /** @hidden */
  87447. export var cloudProceduralTexturePixelShader: {
  87448. name: string;
  87449. shader: string;
  87450. };
  87451. }
  87452. declare module BABYLON {
  87453. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87454. private _skyColor;
  87455. private _cloudColor;
  87456. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87457. updateShaderUniforms(): void;
  87458. get skyColor(): BABYLON.Color4;
  87459. set skyColor(value: BABYLON.Color4);
  87460. get cloudColor(): BABYLON.Color4;
  87461. set cloudColor(value: BABYLON.Color4);
  87462. /**
  87463. * Serializes this cloud procedural texture
  87464. * @returns a serialized cloud procedural texture object
  87465. */
  87466. serialize(): any;
  87467. /**
  87468. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87469. * @param parsedTexture defines parsed texture data
  87470. * @param scene defines the current scene
  87471. * @param rootUrl defines the root URL containing cloud procedural texture information
  87472. * @returns a parsed Cloud Procedural BABYLON.Texture
  87473. */
  87474. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87475. }
  87476. }
  87477. declare module BABYLON {
  87478. /** @hidden */
  87479. export var fireProceduralTexturePixelShader: {
  87480. name: string;
  87481. shader: string;
  87482. };
  87483. }
  87484. declare module BABYLON {
  87485. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87486. private _time;
  87487. private _speed;
  87488. private _autoGenerateTime;
  87489. private _fireColors;
  87490. private _alphaThreshold;
  87491. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87492. updateShaderUniforms(): void;
  87493. render(useCameraPostProcess?: boolean): void;
  87494. static get PurpleFireColors(): BABYLON.Color3[];
  87495. static get GreenFireColors(): BABYLON.Color3[];
  87496. static get RedFireColors(): BABYLON.Color3[];
  87497. static get BlueFireColors(): BABYLON.Color3[];
  87498. get autoGenerateTime(): boolean;
  87499. set autoGenerateTime(value: boolean);
  87500. get fireColors(): BABYLON.Color3[];
  87501. set fireColors(value: BABYLON.Color3[]);
  87502. get time(): number;
  87503. set time(value: number);
  87504. get speed(): BABYLON.Vector2;
  87505. set speed(value: BABYLON.Vector2);
  87506. get alphaThreshold(): number;
  87507. set alphaThreshold(value: number);
  87508. /**
  87509. * Serializes this fire procedural texture
  87510. * @returns a serialized fire procedural texture object
  87511. */
  87512. serialize(): any;
  87513. /**
  87514. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87515. * @param parsedTexture defines parsed texture data
  87516. * @param scene defines the current scene
  87517. * @param rootUrl defines the root URL containing fire procedural texture information
  87518. * @returns a parsed Fire Procedural BABYLON.Texture
  87519. */
  87520. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87521. }
  87522. }
  87523. declare module BABYLON {
  87524. /** @hidden */
  87525. export var grassProceduralTexturePixelShader: {
  87526. name: string;
  87527. shader: string;
  87528. };
  87529. }
  87530. declare module BABYLON {
  87531. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87532. private _grassColors;
  87533. private _groundColor;
  87534. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87535. updateShaderUniforms(): void;
  87536. get grassColors(): BABYLON.Color3[];
  87537. set grassColors(value: BABYLON.Color3[]);
  87538. get groundColor(): BABYLON.Color3;
  87539. set groundColor(value: BABYLON.Color3);
  87540. /**
  87541. * Serializes this grass procedural texture
  87542. * @returns a serialized grass procedural texture object
  87543. */
  87544. serialize(): any;
  87545. /**
  87546. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87547. * @param parsedTexture defines parsed texture data
  87548. * @param scene defines the current scene
  87549. * @param rootUrl defines the root URL containing grass procedural texture information
  87550. * @returns a parsed Grass Procedural BABYLON.Texture
  87551. */
  87552. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87553. }
  87554. }
  87555. declare module BABYLON {
  87556. /** @hidden */
  87557. export var marbleProceduralTexturePixelShader: {
  87558. name: string;
  87559. shader: string;
  87560. };
  87561. }
  87562. declare module BABYLON {
  87563. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87564. private _numberOfTilesHeight;
  87565. private _numberOfTilesWidth;
  87566. private _amplitude;
  87567. private _jointColor;
  87568. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87569. updateShaderUniforms(): void;
  87570. get numberOfTilesHeight(): number;
  87571. set numberOfTilesHeight(value: number);
  87572. get amplitude(): number;
  87573. set amplitude(value: number);
  87574. get numberOfTilesWidth(): number;
  87575. set numberOfTilesWidth(value: number);
  87576. get jointColor(): BABYLON.Color3;
  87577. set jointColor(value: BABYLON.Color3);
  87578. /**
  87579. * Serializes this marble procedural texture
  87580. * @returns a serialized marble procedural texture object
  87581. */
  87582. serialize(): any;
  87583. /**
  87584. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87585. * @param parsedTexture defines parsed texture data
  87586. * @param scene defines the current scene
  87587. * @param rootUrl defines the root URL containing marble procedural texture information
  87588. * @returns a parsed Marble Procedural BABYLON.Texture
  87589. */
  87590. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87591. }
  87592. }
  87593. declare module BABYLON {
  87594. /** @hidden */
  87595. export var normalMapProceduralTexturePixelShader: {
  87596. name: string;
  87597. shader: string;
  87598. };
  87599. }
  87600. declare module BABYLON {
  87601. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87602. private _baseTexture;
  87603. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87604. updateShaderUniforms(): void;
  87605. render(useCameraPostProcess?: boolean): void;
  87606. resize(size: any, generateMipMaps: any): void;
  87607. get baseTexture(): BABYLON.Texture;
  87608. set baseTexture(texture: BABYLON.Texture);
  87609. /**
  87610. * Serializes this normal map procedural texture
  87611. * @returns a serialized normal map procedural texture object
  87612. */
  87613. serialize(): any;
  87614. /**
  87615. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87616. * @param parsedTexture defines parsed texture data
  87617. * @param scene defines the current scene
  87618. * @param rootUrl defines the root URL containing normal map procedural texture information
  87619. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87620. */
  87621. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87622. }
  87623. }
  87624. declare module BABYLON {
  87625. /** @hidden */
  87626. export var perlinNoiseProceduralTexturePixelShader: {
  87627. name: string;
  87628. shader: string;
  87629. };
  87630. }
  87631. declare module BABYLON {
  87632. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87633. time: number;
  87634. timeScale: number;
  87635. translationSpeed: number;
  87636. private _currentTranslation;
  87637. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87638. updateShaderUniforms(): void;
  87639. render(useCameraPostProcess?: boolean): void;
  87640. resize(size: any, generateMipMaps: any): void;
  87641. /**
  87642. * Serializes this perlin noise procedural texture
  87643. * @returns a serialized perlin noise procedural texture object
  87644. */
  87645. serialize(): any;
  87646. /**
  87647. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87648. * @param parsedTexture defines parsed texture data
  87649. * @param scene defines the current scene
  87650. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87651. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87652. */
  87653. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87654. }
  87655. }
  87656. declare module BABYLON {
  87657. /** @hidden */
  87658. export var roadProceduralTexturePixelShader: {
  87659. name: string;
  87660. shader: string;
  87661. };
  87662. }
  87663. declare module BABYLON {
  87664. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87665. private _roadColor;
  87666. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87667. updateShaderUniforms(): void;
  87668. get roadColor(): BABYLON.Color3;
  87669. set roadColor(value: BABYLON.Color3);
  87670. /**
  87671. * Serializes this road procedural texture
  87672. * @returns a serialized road procedural texture object
  87673. */
  87674. serialize(): any;
  87675. /**
  87676. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87677. * @param parsedTexture defines parsed texture data
  87678. * @param scene defines the current scene
  87679. * @param rootUrl defines the root URL containing road procedural texture information
  87680. * @returns a parsed Road Procedural BABYLON.Texture
  87681. */
  87682. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87683. }
  87684. }
  87685. declare module BABYLON {
  87686. /** @hidden */
  87687. export var starfieldProceduralTexturePixelShader: {
  87688. name: string;
  87689. shader: string;
  87690. };
  87691. }
  87692. declare module BABYLON {
  87693. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87694. private _time;
  87695. private _alpha;
  87696. private _beta;
  87697. private _zoom;
  87698. private _formuparam;
  87699. private _stepsize;
  87700. private _tile;
  87701. private _brightness;
  87702. private _darkmatter;
  87703. private _distfading;
  87704. private _saturation;
  87705. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87706. updateShaderUniforms(): void;
  87707. get time(): number;
  87708. set time(value: number);
  87709. get alpha(): number;
  87710. set alpha(value: number);
  87711. get beta(): number;
  87712. set beta(value: number);
  87713. get formuparam(): number;
  87714. set formuparam(value: number);
  87715. get stepsize(): number;
  87716. set stepsize(value: number);
  87717. get zoom(): number;
  87718. set zoom(value: number);
  87719. get tile(): number;
  87720. set tile(value: number);
  87721. get brightness(): number;
  87722. set brightness(value: number);
  87723. get darkmatter(): number;
  87724. set darkmatter(value: number);
  87725. get distfading(): number;
  87726. set distfading(value: number);
  87727. get saturation(): number;
  87728. set saturation(value: number);
  87729. /**
  87730. * Serializes this starfield procedural texture
  87731. * @returns a serialized starfield procedural texture object
  87732. */
  87733. serialize(): any;
  87734. /**
  87735. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87736. * @param parsedTexture defines parsed texture data
  87737. * @param scene defines the current scene
  87738. * @param rootUrl defines the root URL containing startfield procedural texture information
  87739. * @returns a parsed Starfield Procedural BABYLON.Texture
  87740. */
  87741. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87742. }
  87743. }
  87744. declare module BABYLON {
  87745. /** @hidden */
  87746. export var woodProceduralTexturePixelShader: {
  87747. name: string;
  87748. shader: string;
  87749. };
  87750. }
  87751. declare module BABYLON {
  87752. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87753. private _ampScale;
  87754. private _woodColor;
  87755. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87756. updateShaderUniforms(): void;
  87757. get ampScale(): number;
  87758. set ampScale(value: number);
  87759. get woodColor(): BABYLON.Color3;
  87760. set woodColor(value: BABYLON.Color3);
  87761. /**
  87762. * Serializes this wood procedural texture
  87763. * @returns a serialized wood procedural texture object
  87764. */
  87765. serialize(): any;
  87766. /**
  87767. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87768. * @param parsedTexture defines parsed texture data
  87769. * @param scene defines the current scene
  87770. * @param rootUrl defines the root URL containing wood procedural texture information
  87771. * @returns a parsed Wood Procedural BABYLON.Texture
  87772. */
  87773. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87774. }
  87775. }